function HideUnhide(element_id){var tmp=document.getElementById(element_id);tmp.style.display=(getElementComputedStyle(tmp,'display') =='block')?'none':((getElementComputedStyle(tmp,'display') =='none')? 'block':'none');}
function getElementComputedStyle(elem, prop) { //Вычисляет стиль(prop) эл-та (elem) исходя из css (а не html тега style)
  if (typeof elem!="object") elem = document.getElementById(elem);
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+
  if (document.defaultView && document.defaultView.getComputedStyle)
  {
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop);
  }
  // external stylesheet for Explorer and Opera 9
  if (elem.currentStyle)
  {
    var i;
    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);
    return elem.currentStyle[prop];
  }
  return "";
}


function help_window(name,url,left,top,width,height,toolbar,menubar,statusbar,scrollbar,resizable)
{toolbar_str=toolbar?'yes':'no';menubar_str=menubar?'yes':'no';statusbar_str=statusbar?'yes':'no';scrollbar_str=scrollbar?'yes':'no';resizable_str=resizable?'yes':'no';window.open(url,name,'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);}
function onlydigs(){if((event.keyCode<46)||(event.keyCode>57)){if(!(event.keyCode==8))if(!(event.keyCode==9))event.returnValue=false;}}
function calculate(){document.getElementById('USD').value=usd2uahAsk;document.getElementById('EUR').value=eur2uahAsk;document.getElementById('RUB').value=rub2uahAsk;document.getElementById('inUSD').value=Math.round(document.getElementById('price').value*document.getElementById('days').value*eur2uahAsk*(1/usd2uahAsk)*100)/100;document.getElementById('inEUR').value=Math.round(document.getElementById('price').value*document.getElementById('days').value*100)/100;document.getElementById('inUAH').value=Math.round(document.getElementById('price').value*document.getElementById('days').value*eur2uahAsk*100)/100;document.getElementById('inRUB').value=Math.round(document.getElementById('price').value*document.getElementById('days').value*eur2uahAsk*(1/rub2uahAsk)*100)/100;var tmp=document.getElementById('discount');tmp.style.display=(document.getElementById('days').value>6)?'block':'none';document.getElementById('results').style.display=(document.getElementById('inUSD').value>0)?'inline':'none';}
function startShowingTime(){var serverTime=document.getElementById('servertime').innerHTML;var timeArray=serverTime.split(':');window.h=timeArray[0];window.h++;window.h--;window.i=timeArray[1];window.i++;window.i--;window.s=timeArray[2];}
function showTime(){if(window.h==undefined)startShowingTime();s++;if(s>59){s=0;i++;}
if(i>59){i=0;h++;}
if(h>23){h=0;}
if(i<10)var strtime=h+":0"+i;else var strtime=h+":"+i;if(s<10)strtime=strtime+":0"+s;else strtime=strtime+":"+s;
document.getElementById('servertime').innerHTML=strtime;
if (document.getElementById('timezone1')) {
	hours=parseInt(h); //kiev
	if(hours>23){hours=hours-23;}
	if(i<10)var strtime=hours+":0"+i;else var strtime=hours+":"+i;if(s<10)strtime=strtime+":0"+s;else strtime=strtime+":"+s;
	document.getElementById('timezone1').innerHTML=strtime;
}
if (document.getElementById('timezone2')) {
	hours=parseInt(h)+6; //tokio
	if(hours>23){hours=hours-23;}
	if(i<10)var strtime=hours+":0"+i;else var strtime=hours+":"+i;if(s<10)strtime=strtime+":0"+s;else strtime=strtime+":"+s;
	document.getElementById('timezone2').innerHTML=strtime;
}
if (document.getElementById('timezone3')) {
	hours=parseInt(h)-7; //new york -5 (kiev +2)
	if(hours>23){hours=hours-23;}
	if(hours<0){hours=hours+23;}
	if(i<10)var strtime=hours+":0"+i;else var strtime=hours+":"+i;if(s<10)strtime=strtime+":0"+s;else strtime=strtime+":"+s;
	document.getElementById('timezone3').innerHTML=strtime;
}
if (document.getElementById('timezone4')) {
	hours=parseInt(h)-1; //Rome
	if(hours>23){hours=hours-23;}
	if(hours<0){hours=hours+23;}
	if(i<10)var strtime=hours+":0"+i;else var strtime=hours+":"+i;if(s<10)strtime=strtime+":0"+s;else strtime=strtime+":"+s;
	document.getElementById('timezone4').innerHTML=strtime;
}


var t=setTimeout('showTime()',1000);}

function addLoadEvent(func,first) {  
  var oldonload = window.onload;  
  if (typeof window.onload != 'function') {  
	    window.onload = func;  
  } else {  
		  if (first) {
			   window.onload = function() { func(); if (oldonload) { oldonload(); } }
		  }
		  else {
			   window.onload = function() { if (oldonload) { oldonload(); } func(); } 

		  }

  }  
} 


function check_booking_form(alertMsg) {
	var firstname=document.getElementsByName('firstname')[0].value.length;
	var lastname=document.getElementsByName('lastname')[0].value.length;
	var age=document.getElementsByName('age')[0].value.length;
	var phone=document.getElementsByName('phone')[0].value.length;
	var email=document.getElementsByName('email')[0].value.length;
	var capcha=document.getElementsByName('capcha')[0].value.length;
	var rules_ok=document.getElementsByName('rules_ok')[0].checked;
	
	if (firstname>0 && lastname>0 && age>0 && phone>0 && email>0 && capcha==5 && rules_ok)
		return(true);
	else {
		alert(alertMsg);
		return(false);
	}

}

function check_message_form() {
		if (document.getElementById('name').value.length<2) {
			return false;
		}
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
		if (!emailPattern.test(document.getElementById('email').value)) {
			return false;
		}
		if (document.getElementById('phone').value.length<7) {
			return false;
		}
		if (document.getElementById('content').value.length<7) {
			return false;
		}

		document.forms['message'].submit();
}


