window.onresize = foot_down;

$(function() {
    $('#nav').droppy({speed: 400});
  });

function doLoad(url1) {  
	$.ajax({
		url: url1,
		cache: false,
		success: function(html){
			$("div#responseHTML").html(html);
		}
	});
}

function theRotator() {
	// Устанавливаем прозрачность всех картинок в 0
	$('div#rotator ul li').css({opacity: 0.0});
 
	rotate();
	// Берем первую картинку и показываем ее (по пути включаем полную видимость)
	//$('div#rotator ul li:first').css({opacity: 1.0});
 
	// Вызываем функцию rotate для запуска слайдшоу, 5000 = смена картинок происходит раз в 5 секунд
	setInterval('rotate()',5000);
}
 
function rotate() {	
	// Берем первую картинку
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
 
	// Берем следующую картинку, когда дойдем до последней начинаем с начала
	//var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
 
	// Расскомментируйте, чтобы показвать картинки в случайном порядке
	var sibs = current.siblings();
	var rndNum = Math.floor(Math.random() * sibs.length );
	var next = $( sibs[ rndNum ] );
 
	// Подключаем эффект растворения/затухания для показа картинок, css-класс show имеет больший z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
 
	// Прячем текущую картинку
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};

$(document).ready(function() {	
	$().piroBox({
		my_speed: 400, //animation speed
		bg_alpha: 0.4, //background opacity
		slideShow : true, // true == slideshow on, false == slideshow off
		slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
		close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox

	});	
	theRotator();
	
	});

//setInterval ( "doSomething()", 7000 );

//function doSomething ( )
//{
	//rnd_img = document.getElementById('randphoto');
	//rnd_img.src = "images/photos/Rand_Photo/_"+Math.floor(Math.random()*36+1)+".jpg";
	//alert(rnd_img.src);
//}

function mclick()
{
	scat = document.getElementById('service1');
	pm =  document.getElementById('butnp1');
	
	$("#service1").slideToggle("slow");

	//if(scat){

		//if (scat.className == "artnavmenu2")
	//	{
	//		scat.className = "artnavmenu21";
	//	}else
	//	{
	//		scat.className = "artnavmenu2";
	//	}	
//	}
	
	if(pm){
		s = new String(pm.src);
		s = s.substring(s.length-9,s.length);
		
		if (s == "/plus.gif")
		{
			pm.src = "images/minus.gif";
		} else
		{		
			pm.src = "images/plus.gif";
		}		
	}
}

function nav_url(url)
{
	window.location.href=url;
}

function ord_but_over(num_)
{
	s='button'+num_;
	bt = document.getElementById(s);
	bt.src='images/button1.jpeg';
}

function ord_but_out(num_)
{
	s='button'+num_;
	bt = document.getElementById(s);
	bt.src='images/button0.jpeg';
}

function onkeyup_(e)
{
	var keynum;

	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	if (keynum==13) submit_();
}

function foot_down()
{
	ft = document.getElementById('footer');
	eb = document.getElementById('entire_body');
	inf = document.getElementById('info');
	ft.height = 1;
	blength = document.body.clientHeight - eb.clientHeight;
	//alert(blength);	
	if (blength>0) ft.height = blength;
}

function _onclk1(year_,mon_)
{
	//document.getElementById("responseHTML").style.display = 'none';
	if (mon_>=2) mon_=mon_-1; else {
		mon_=12;
		year_=year_-1;
	}
	doLoad('pcalendar.php?mon_='+mon_+'&year_='+year_);
}

function _onclk2(year_,mon_)
{
	//document.getElementById("responseHTML").style.display = 'none';
	if (mon_<=11) mon_=mon_+1; else {
		mon_=1;
		year_=year_+1;
	}
	doLoad('pcalendar.php?mon_='+mon_+'&year_='+year_);
}

function _onmover1(sender)
{
	sender.style.backgroundColor='#aaaaaa';
	sender.style.border="1px solid black";
}

function _onmout1(sender)
{
	sender.style.backgroundColor='transparent';
	sender.style.border='none';
}

function _onclk_cont()
{
	window.location.href="/contacts.php";
}

function _onclk(sender,year,month,day)
{
	window.location.href="/order.php?year="+year+"&month="+month+"&day="+day;
}

function _onmover(sender)
{
	sender.style.backgroundColor='#cccccc';
	sender.style.backgroundImage='url(/images/calborder.gif)';
}

function _onmout(sender)
{
	sender.style.backgroundColor='transparent';
	sender.style.backgroundImage='none';
}

function h_in(num)
{
	s='hdr'+num;
	hdr = document.getElementById(s);
	//alert(hdr.style.backgroundColor);
	hdr.style.backgroundColor = 'transparent';
	//alert(hdr.style.backgroundColor);
}

function h_out(num)
{
	s='hdr'+num;
	hdr = document.getElementById(s);
	//alert(hdr.style.backgroundColor);
	hdr.style.backgroundColor = 'transparent';
	//alert(hdr.style.backgroundColor);
}

function nh_in(num)
{
	s='ihdr'+num;
	hdr = document.getElementById(s);
	val='';
	if (num==0) {val='/images/main_1.png';};
	if (num==1) {val='/images/gallery_1.png';};
	if (num==2) {val='/images/service_1.png';};	
	if (num==3) {val='/images/cont_1.png';};
	if (num==4) {val='/images/inf_1.png';};	
	if (num==5) {val='/images/order_1.png';};	
	hdr.src = val;
}

function nh_out(num)
{
	s='ihdr'+num;
	hdr = document.getElementById(s);
	val='';
	if (num==0) {val='/images/main_0.png';};
	if (num==1) {val='/images/gallery_0.png';};
	if (num==2) {val='/images/service_0.png';};	
	if (num==3) {val='/images/cont_0.png';};
	if (num==4) {val='/images/inf_0.png';};	
	if (num==5) {val='/images/order_0.png';};	
	hdr.src = val;
}

function chg_wnd_size(wdth, hght)
{
	window.resizeTo(wdth, hght);
}

function sbmt(op_id)
{
	act_type = document.getElementById("ACTION_TYPE");
	mainform = document.getElementById("MFORM");
	
	act_type.value = op_id;
	mainform.submit();
}

function out()
{
	act_type = document.getElementById("ACTION_TYPE");
	alert(act_type.text);
}

