var play=1;
var tek=0;
var s=0;

function submit_btn(){
	var check = 1;
	var elements = $("#request input").not(".free, input[name*=info]");
	for(var i=0;i<elements.length;i++){
		if(elements.eq(i).val()==""){
			elements.eq(i).addClass("error");
			check = 0;
		} else {
			elements.eq(i).removeClass("error");
		}
	}
	
	
	
	if(check == 1){return true} else {alert("Проверьте выделенные поля и убедитесь, что вы отметили пункты соглашения о передаче данных")};
}

$("document").ready(function(){

	$("#request").hide(); $("#request_pc").hide(); $("#show-request #request").show();
	
	$("a#show_request").click(function(){
		$("#info").hide();
		$("#request").show();
	});
	
	$("a#show_request2").click(function(){
		$("#info").hide();
		$("#request_pc").show();
		
	});

		if(window.location.hash=='#pc'){$("#info").hide(); $("#request_pc").show();}
		if(window.location.hash=='#request'){$("#info").hide(); $("#request").show();}	
		if(window.location.hash!='#request' || window.location.hash=='#pc'){$("#request").hide(); $("#request_pc").hide(); $("#show-request #request").show();}	






$("#chastnie").mouseover(function(){
	$("#podzagolovok1").toggle(500);
	$("#podzagolovok2").hide(500);
});

$("#korporat").mouseover(function(){
	$("#podzagolovok2").toggle(500);
	$("#podzagolovok1").hide(500);
});


$("#seeforma").click(function(){
	$("#formaotpravki").show(500);
	$("#seeforma").hide(500);
	
	for(i=0;i<500;i=i+10){
	setTimeout("scroll(0,1000)",i);
	}
});



$("#tipa").change(function(){
	tip=$(this).val();
	if(tip==2){
		$("#firma").show(300);
	}
	if(tip==1){
		$("#firma").hide(300);
	}
	
//$.get("/faq/ajax?page=" +tip, function(resultat){
//$("#tipb").html(resultat);
//});
});


////////////////////////////////
kol=$("#banners div").length;
txt="";
for(i=0;i<kol;i++){
n=i+1;
txt=txt+"<div>"+n+"</div>";
}
txt=txt+"<img src='/i/banners/number_pause.jpg'>";
$("#buttons").html(txt);


$("#buttons div").click(function(){
dotElement=$(this);
index=$('#buttons div').index(dotElement);
vibrat(index); tek=index++; play=0; s=1; $("#buttons img").attr("src", "/i/banners/number_play.jpg");
});


vibrat(0);
/////
$("#buttons img").click(function(){

if (s==0){
play=0; s=1; $("#buttons img").attr("src", "/i/banners/number_play.jpg"); 

}
else { play=1; s=0; setTimeout("vibrat(tek)",3010);  $("#buttons img").attr("src", "/i/banners/number_pause.jpg");

}
});


/*
var blokirovka=0;
$("#banners").hover(
function(){
	if(blokirovka==0){
	blokirovka=1;	
	$("#buttons").animate({"marginTop":"-25px"},500);
	}
	},
function(){
	if(blokirovka==0){
	blokirovka=1;	
	$("#buttons").animate({"marginTop":"0px"},500, function(){blokirovka=0;});
	}
	}
);
*/


$("#banners img").hover(function(){blokirovka=0;});



});


/////////////
function vibrat(id){
kolel=$("#banners div").length;
if(id>(kolel-1)){
id=0;
}
for(i=0;i<kolel;i++){
if(id==i){
$("#banners div").eq(i).show();
$("#banners div").eq(i).animate({'opacity':'1'},750);
}
if(id!=i){
$("#banners div").eq(i).animate({'opacity':'0'},750);
$("#banners div").eq(i).hide();
}
}
//--
$("#buttons div.current").removeClass("current");
$("#buttons div").eq(id).addClass("current");
if(play==1){
tek=id;
tek=tek+1;
setTimeout("prov("+tek+")",3000);
}
}
function prov(id){
if(play==1 && s==0){
setTimeout("vibrat("+id+")",10);
}
}
///---
function next(obj){
$(obj).next(".none").toggle("fast");
}
/////////////////////

