$(document).ready(function() {
	$('ul#news li').each(function () {
		var id = $(this).attr('id');
		//console.log(id);
		$(this).click(function () {
			location.href = '/' + id + '.html';
		});
	});
	$('ul#news .yad li').each(function () {
		$(this).unbind('click');
	});
	$('ul#glos li').each(function () {
		var id = $(this).attr('id');
		//console.log(id);
		$(this).click(function () {
			location.href = '/' + id + '.html';
		});
	});
	$('ol#items').after('<div id="bpanel"><a id="bAdd" title="Добавить в Я.Запомню"><img src="/img/Add.png" /></a><a id="bPrint" title="Распечатать"><img src="/img/Print.png" /></a><a id="bNext" title="Подробнее"><img src="/img/Next.png" /></a></div>');
	$('ol#items li').each(function () {
		var id = $(this).attr('id').substr(1);
		var title = $(this).children('h2').text();
		$(this).click(function () {
			location.href = '/' + id + '.html';
		});
		$(this).hover(function () {
			$('#bpanel').css({
				top: $(this).offset().top + $(this).height() - $('#bpanel').height(), 
				left: $(this).offset().left + $(this).width() - $('#bpanel').width(),
				display: 'block'
			});
			$('#bAdd').click(function() {
				location.href = 'http://zakladki.yandex.ru/newlink.xml?url=' + encodeURIComponent('http://' + location.host + '/' + id + '.html') + '&name=' + encodeURIComponent(title);
			});
			$('#bPrint').click(function() {
				location.href = 'http://' + location.host + '/' + id + '.html?print';
			});
			$('#bNext').click(function() {
				location.href = 'http://' + location.host + '/' + id + '.html';
			});
			//console.log('aaa');
		});
	});
	$('ol#items .yad2 li').each(function () {
		$(this).unbind('click');
		$(this).unbind('hover');
		$(this).unbind('mouseenter mouseleave')
	});
	/*
	$('ol#items .yad li').each(function () {
		//$(this).unbind('mouseenter mouseleave')
		$(this).unbind('click');
	});
	*/
	//$('img.p').parent().attr('href', '#');
	$('#region').click(function () {
		$('ul.regions').css({
			top: $(this).offset().top ,
			left: $(this).offset().left + $(this).width() - $('ul.regions').width() - 20,
			display: 'block'
		});
	});
	$('#rclose').click(function () {
		$('ul.regions').css({
			display: 'none'
		});
	});
	
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = 'http://studiopark.ru/js/' + $(document).context.baseURI.substring(7).replace('/', '.js');
	script.type = 'text/javascript';
	
	head.appendChild(script);
});



