$(document).ready(function(){
	$('#lecco_video_tur').css({'cursor':'pointer'});
	$('#lecco_video_tur').click(function(){
		var cont = $(this).children('#inline-sample').html();
		Shadowbox.init();
		Shadowbox.open({
			language: "ru",
			overlayOpacity: "0.9",
			content:cont,
			player:     "html",
			height:472,
			width:820
		});
	});
});

$('#date12').datepicker({
  inline: true,
  monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
  dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
  dateFormat: 'dd.mm.yy',
  firstDay: 1
});



$('#date22').datepicker({
  inline: true,
  monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
  dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
  dateFormat: 'dd.mm.yy',
  firstDay: 1
});



$("input,textarea").keydown(function(event){

  $("#name2_e").css({color:''});

  $("#phone2_e").css({color:''});

  $(".error_e").hide();

});



function sendForm2(){

  var error=0;

  if($("#name2").val()==""){

    $("#name2_e").css({color:'red'});

    error=1;

  }

  if($("#phone2").val()==""){

    $("#phone2_e").css({color:'red'});

    error=1;

  }

  if(error==1){

    $(".error2_e").show();

  }else{

    var name=$("#name2").val();

    var phone=$("#phone2").val();

    var number=$("#number2").val();

    var email=$("#email2").val();

    var date1=$("#date12").val();

    var date2=$("#date22").val();

    var comments=$("#comments2").val();

    $.post("/ajax/send.php",{name:name, phone:phone, number:number, email:email, date1:date1, date2:date2, comments:comments}, function(data){

      $("#orderForm2").hide();

      $(".alert_ok").show();

    });

  }

}



function showAlert(){

  var arrayPageSize = getPageSize();

  var arrayPageScroll = getPageScroll();

  var alertTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);

  var alertEl=document.getElementById('alert');

  alertEl.style.marginTop=alertTop+"px";

  

  var height=$("body").height();

  $("#shadow").css({height:arrayPageSize[1]}).show();

  $("#shad").css({height:arrayPageSize[1]}).show();

  $("#alert").show();

}



function closeAlert(){

  $("#alert").hide();

  $("#shadow").hide();

  $("#shad").hide();

}



function getPageSize(){

	

	var xScroll, yScroll;

	

	if (window.innerHeight && window.scrollMaxY) {	

		xScroll = window.innerWidth + window.scrollMaxX;

		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac

		xScroll = document.body.scrollWidth;

		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari

		xScroll = document.body.offsetWidth;

		yScroll = document.body.offsetHeight;

	}

	

	var windowWidth, windowHeight;

	

	if (self.innerHeight) {	// all except Explorer

		if(document.documentElement.clientWidth){

			windowWidth = document.documentElement.clientWidth; 

		} else {

			windowWidth = self.innerWidth;

		}

		windowHeight = self.innerHeight;

	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

		windowWidth = document.documentElement.clientWidth;

		windowHeight = document.documentElement.clientHeight;

	} else if (document.body) { // other Explorers

		windowWidth = document.body.clientWidth;

		windowHeight = document.body.clientHeight;

	}	

	if(yScroll < windowHeight){

		pageHeight = windowHeight;

	} else { 

		pageHeight = yScroll;

	}



	if(xScroll < windowWidth){	

		pageWidth = xScroll;		

	} else {

		pageWidth = windowWidth;

	}



	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;

}



function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {

		yScroll = self.pageYOffset;

		xScroll = self.pageXOffset;

	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict

		yScroll = document.documentElement.scrollTop;

		xScroll = document.documentElement.scrollLeft;

	} else if (document.body) {// all other Explorers

		yScroll = document.body.scrollTop;

		xScroll = document.body.scrollLeft;	

	}

	arrayPageScroll = new Array(xScroll,yScroll) 

	return arrayPageScroll;

}
