var animate=0;
function open_close(n) {
  if(animate==0){
    animate=1;
    if ($("#vac_full"+n).is(':hidden')) {
      $(".vac_full").animate({height: "hide"}, 800);
      $(".vac_a_head").removeClass("a_minus").addClass("a_plus");
      $("#vac_full"+n).animate({height: "show"}, 800,function(){animate=0;});
      $("#vac"+n).removeClass("a_plus").addClass("a_minus");
    } else {
      $("#vac_full"+n).animate({height: "hide"}, 800,function(){animate=0;});
      $("#vac"+n).removeClass("a_minus").addClass("a_plus");
    }
  }
}
  function open_vac(){
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    var alertTop = arrayPageScroll[1]+20;
    var h;
    h = document.getElementById('wrap').offsetHeight;
    document.getElementById('alles').style.height = h+ 'px';
    document.getElementById('alles').style.display = 'block';
    document.getElementById('popup').style.top=alertTop+"px";
    document.getElementById('popup').style.display = 'block';
  }
  function open_wind(id){
    var h;
    h = document.getElementById('wrap').offsetHeight;
    document.getElementById('alles').style.height = h+ 'px';
    document.getElementById('alles').style.display = 'block';
    document.getElementById('popup').style.display = 'block';
    actId=id;
  }
  
  function onlineOrder(id){
    var h;
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    var alertTop = arrayPageScroll[1]+20;
    h = document.getElementById('wrap').offsetHeight;
    document.getElementById('alles').style.height = h+ 'px';
    document.getElementById('alles').style.display = 'block';
    document.getElementById('popups').style.top=alertTop+"px";
    document.getElementById('popups').style.display = 'block';
    actId=id;
  }

  function close_wind(){
    document.getElementById('alles').style.display = 'none';
    document.getElementById('popup').style.display = 'none';
  }
  
  function close_winds(){
    document.getElementById('alles').style.display = 'none';
    document.getElementById('popups').style.display = 'none';
  }
  
  var animate=0;
  function slidePlease(){
    if(animate==0){
      animate=1;
      if($(".slider_in").css("left")=="0%"||$(".slider_in").css("left")=="0px"){
        $(".slider_in").animate({left:"-100%"},1000,function(){animate=0;});
      }else{
        $(".slider_in").animate({left:"0%"},1000,function(){animate=0;});
      }
    }
  }
  function showBlock(id){
  //  $(".c_bord_block").hide();
  //  $(".tit").show();
    $("#title"+id).hide();
    $("#block"+id).show();
  }
  function prev(){
    var next=$("#img"+actId).attr("next");
    var prev=$("#img"+actId).attr("prev");
    if(next!=0){
      var src="/getimg.php?path="+$("#img"+prev).attr("rel")+"&w=800&h=565&m=resize";  
      document.getElementById('gallery_img').src=src;
      actId=prev;
    }
  }
  function next(){
    var next=$("#img"+actId).attr("next");
    var prev=$("#img"+actId).attr("prev");
    if(next!=0){
      var src="/getimg.php?path="+$("#img"+next).attr("rel")+"&w=800&h=565&m=resize";  
      document.getElementById('gallery_img').src=src;
      actId=next;
    }
  }
  
  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;
}
  
  $(".aut_left").dblclick(function(){return false;});
  
  function onlineForm(){
    var error=0;
    $(".online_form input").css({border:"1px solid #ccc"});
    if($("#name").val()==""){error=1;$("#name").css({border:"1px solid red"});}
    if($("#phone").val()==""){error=1;$("#phone").css({border:"1px solid red"});}
    if($("#time").val()==""){error=1;$("#time").css({border:"1px solid red"});}
    if($("#address").val()==""){error=1;$("#address").css({border:"1px solid red"});}
    if($("#address2").val()==""){error=1;$("#address2").css({border:"1px solid red"});}
    if(error==0){
      var name=$("#name").val();
      var phone=$("#phone").val();
	  var email=$("#email").val();
      var time=$("#time").val();
      var address=$("#address").val();
      var address2=$("#address2").val();
      var desc=$("#desc").val();
      $("#changer").load("/ajax/mail.php",{name:name, phone:phone, email:email, time:time, address:address, address2:address2, desc: desc},function(data){
        $("#changer").html(data);
      });
    }
  }