$(document).ready(function() {

	// заполняем или убираем заполнение формы для поиска
	$("#s").focus(
	function () {if($(this).val() == 'Поиск по сайту') $(this).val('');});
	$("#s").blur
	(function () {if($(this).val() == '') $(this).val('Поиск по сайту');});

	// подсветка строк в таблицах (для IE6; для нормаьных браузеров дублировано через CSS)
	$("tr").hover(
		function () {$(this).addClass("tabletr-act");},
		function () {$(this).removeClass("tabletr-act");}
	);
	
	//$("#images-afisha").css("margin-left","-100px");
//	$("#image-afisha-1").rotateLeft(115);
	$("#image-afisha-1").rotateRight(70);
	$("#image-afisha-2").rotateRight(115);
	$("#image-afisha-2").css("margin-top","-85px");
	$("#image-afisha-1").css("margin-left","40px");
	$("#image-afisha-2").css("margin-left","40px");
	$hh=0;		
	$("#navigation ul li").click(function(){
		if($(this).attr("id") != "active-this-time")
		{
			$("#arrow").animate({opacity:"0"});
			$("#arrow").html("&darr;");
			$hh = $(".third-menu").height();
			if($(".third-menu").css("display") != "none")
			{
				$(".third-menu").animate({height:"toggle", opacity:"0"},"fast");
				
			}
		}
		else
		{
			$("#arrow").animate({opacity:"1"});
			$("#arrow").html("&uarr;");
			$(".third-menu").animate({height:$hh, opacity:"1"},"fast");
		}
		$("#navigation ul li").each(function(){
			$(this).removeClass();
		});
		$(this).addClass("navigation-active");
	});// /меню навигации
	
	$("#arrow").toggle(function(){
			$(this).html("&darr;");
			$(".third-menu").animate({height:"toggle", opacity:"toggle"},"fast");
		},
		function(){
			$(this).html("&uarr;");
			$(".third-menu").animate({height:"toggle", opacity:"toggle"},"fast");
		}
	);

	$(".lp input[name='login']").click(function(){
		if (this.value == 'Логин') this.value = '';
	});
	$(".lp input[name='login']").blur(function(){
		if (this.value == '') this.value = 'Логин';
	});
	$(".lp input[name='passwd']").click(function(){
		if (this.value == 'Пароль') this.value = '';
	});
	$(".lp input[name='passwd']").blur(function(){
		if (this.value == '') this.value = 'Пароль';
	});

});

function showMenu(el, element)
{
	var last_secondline = document.getElementById(lastmenu);
	var secondline = document.getElementById(element);
	var active = document.getElementById('active-this-time');
	last_secondline.style.display = 'none';
	active.className = "";
	active.id = "";
	el.id = 'active-this-time';
	el.className = "navigation-active";
	secondline.style.display = '';
	if(secondline.width < 750)
		secondline.width = 749+"px";
	else
		secondline.width = "";
	lastmenu = element;
	/*
	$("#second-line div").each(function(){
		$(this).hide();
	});
	$("#second-line").width("");
	$(element).show();
	if($("#second-line").width() < 750)
		$("#second-line").width("749px");
	else
		$("#second-line").width("");
	*/
	//alert($("#second-line").width());
	return false;
}

function setActive(element, dis)
{
	if (dis == 'display')
		lastmenu = element;
}

function printday(){
if(document.getElementById('todayday')){
  var MonthTitles=new Array('января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря');
  var todaydate= new Date();
  m= todaydate.getMonth();
  d= todaydate.getDate();
  document.getElementById('todayday').innerHTML = 'егодня '+d+' '+MonthTitles[m]+', <span id="todaytime">14:55</span>';
  StartClock();
}
}

var clock = 0;

function UpdateClock() {
   if(clock) {
      clearTimeout(clock);
      clock = 0;
   }
   document.getElementById('todaytime').innerHTML = GetTime();
   clock = setTimeout("UpdateClock()", 60000);
}
function StartClock() {
   clock = setTimeout("UpdateClock()", 500);
}

function GetTime(){

   var tDate = new Date();
   
   hour = ''+tDate.getHours();
   minutes = ''+tDate.getMinutes();
   seconds = ''+tDate.getSeconds();
   if(hour.length == 1){ hour = '0'+hour; }
   if(minutes.length == 1){ minutes = '0'+minutes; }
   if(seconds.length == 1){ seconds = '0'+seconds; }

   return hour+':'+minutes;
}


function sel_f(pv)
{
if (pv=="1") {t_f++;} else {t_f--;}
if (t_f<0) {t_f=0;}
if (t_f>=cnt_f-1) {t_f=cnt_f-1;}
document.getElementById('fotol').src=arr_im1[t_f];
document.getElementById('hr1').href=arr_im2[t_f];
document.getElementById('hr2').href=arr_im2[t_f];
}