$(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="à&#65533;ÎàÁàÀàÂàÈá&#65533;&#65533;àÂ à.à&#65533;ÀàÏàÎàÌàÍá&#65533;><img src="/img/Add.png" /></a><a id="bPrint" title="à àÀá&#65533;ÏàÅá&#65533;Àá&#65533;Àá&#65533;&#65533;><img src="/img/Print.png" /></a><a id="bNext" title="à&#65533;ÎàÄá&#65533;ÎàÁàÍàÅàÅ"><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 .yad li').each(function () {
		//$(this).unbind('mouseenter mouseleave')
		$(this).unbind('click');
	});
	*/
	//$('img.p').parent().attr('href', '#');


	$('#region').click(function () {
    $('div.regions').css({display: 'block'});
    $('#rclose').css({display: 'block'});
  });
  
  $('#regionArw').click(function () {
    $('div.regions').css({display: 'block'});
    $('#rclose').css({display: 'block'});
  });
  
	$('#rclose').click(function () {
    $('div.regions').css({display: 'none'});
		$('#rclose').css({display: 'none'});
	});
	$(document).ready(function(){
  		$('.r_in a').click(function(e){
    		$('#region b').html($(this).html());
        $('div.regions').css({display: 'none'});
        $('#rclose').css({display: 'none'});
  		});
	})


});

