function postView(w, h, img, txt) {
	var scrnx = screen.width/2 - w/2;var scrny = screen.height/2 - h/2;

	window.open('/?openImage&img='+escape(img)+'&text='+escape(txt),'popUp','width='+w+',height='+h+',scrollbars=auto,menubar=no,toolbar=no,status=no,left='+scrnx+',top='+scrny);
	return false;
}

function openIMG(src, alt) {return postView(600, 400, src, alt);}

function ov(tr) {tr.style.backgroundColor = '#eff0e9';}
function ou(tr){tr.style.backgroundColor = '';}

$(document).ready(function() {
	$('div.menu-in ul li').hover(
		function() {
			$(this).addClass('active');
			$(this).find('ul li.b div').css('width', (($(this).width()-22) + 'px'));
			//$(this).find('ul').show('slide');
			$(this).find('ul').show();
		},
		function() {
			$(this).removeClass('active');
			$(this).find('ul').hide();
			//$(this).find('ul').hide('fade');
			//$(this).find('ul').fadeOut();
		}
	);
	try {
	$('#calView').click(function() {$('#cal').focus(); return false;});
	$("#cal").datepicker({minDate: new Date(2005, 1, 1), maxDate: '+0D', showAnim: 'slideDown', dateFormat: 'yy-mm-dd',  onSelect: function(dateText, inst) {try {location.replace('/news/'+dateText);} catch(e){location.href='/news/'+dateText;}}});
	} catch(e){}

	$('#lnkSubscribe > a').click(function() {
		if ('none' == $('#divSubscribe').css('display')) {
			var subsPos = $('#lnkSubscribe').position();
			$('#divSubscribe').show().css('top', (subsPos.top-20)).css('left', subsPos.left);
			$('#email_subscribe').focus();
		} else {
			$('#divSubscribe').hide();
		}
		return false;
	});
	$('input[class="sbutOk"]', $('#lnkSubscribe')).click(function() {
		email = $('#email_subscribe').val();
		var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (!emailReg.test(email)) {
			alert('Некорректный Email');
			return false;
		}
		$('#divSubscribe').html('Отправляем, подождите...');
		$.post('/?subscribe=news&ajax', {email: email},
			function(reply) {
				$('#divSubscribe').html(reply);
			});
		return;
	});
});

