function openAskForm() {
     var tmp = document.getElementById("send_form_cont");
     checkWideScreen();     
     tmp.style.top = (myHeight/2+myTop-200) + "px";
     tmp.style.display = "block";
     return false;
}
function openHotelImg()
{
     var tmp = document.getElementById("hotelFotoContainer");
     checkWideScreen();
     tmp.style.top = (myHeight/2+myTop-245) + "px";
     tmp.style.display = "block";
     return false;
}

function checkWideScreen(){
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    myTop = window.pageYOffset;
    myLeft = window.pageXOffset;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    myTop = document.documentElement.scrollTop;
    myLeft = document.documentElement.scrollLeft;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    myTop = document.body.scrollTop;
    myLeft = document.body.scrollLeft;
  }
}

function LoadFoto(a) {	
	document.getElementById("countryFoto").src = a.href;
	i = parseInt(a.id.substr(4));
	document.getElementById("countryFoto").setAttribute("pha",i < countFotos - 1 ? i + 1 : 0);
	for (i=0; i<countFotos; i++) 
		document.getElementById("foto"+i).className = 'countryFotoNav';	
	a.className = 'countryFotoNavSelected';
	if (p = document.getElementById("aboutFoto"))
		p.innerHTML = a.title?a.title:'&nbsp;';
	return false;
}

function openHOrder(el)
{
	var top = screen.height/2-235;
	var left = screen.width/2-295;
	window.open(el.href+(el.href.indexOf('?')==-1?"?":"&")+"ref=" + escape(location.href),el.target,"scrollbars=yes,width=590,height=470,left="+left+",top="+top+",resizable=no,toolbar=0,location=0,status=0,menubar=0,directories=0").focus();
	return false;
}

function openAOrder(el)
{
	var top = screen.height/2-300;
	var left = screen.width/2-350;
	window.open(el.href+"?ref=" + escape(location.href),el.target,"scrollbars=yes,width=700,height=600,left="+left+",top="+top+",resizable=no,toolbar=0,location=0,status=0,menubar=0,directories=0").focus();
	return false;
}
function openForm()
{
	window.open("/sendmail.phtml?ref=" + escape(location.href),"_form","toolbar=no,bar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=350").focus();
	return false;
}

	function CheckForm(){	
	  var error=0;
	  var mf=document.forms['zakaz'];		
	    if (mf.fio.value=='' && error==0) {
	      alert('Заполните, пожалуйста, поле \"ФИО\"');
		  mf.fio.focus();
		  error=1;
	    }
		if (mf.email.value=='' && error==0) {
	      alert('Укажите, пожалуйста, \"E-mail\"');
		  mf.email.focus();
		  error=1;
	    }
		if (mf.about.value=='' && error==0) {
	      alert('Введите, пожалуйста, текст сообщения');
		  mf.about.focus();
		  error=1;
	    }
		if (error==0 && mf.phone.value=='' && (isEmail() == false)){
			error=1;
			mf.email.focus();
		}
		if (!mf.code.value.match(/^\d{4}$/) && error==0) {
	    alert('Введите, пожалуйста, четыре цифры кода');
		  mf.code.focus();
		  error=1;
	    }
	    if (error==0) {
	       //mf.submit();
				script = document.createElement("script");
				script.src = "/sendmail.phtml?fio="+mf.fio.value+"&email="+mf.email.value+"&ref="+escape(location.href)+"&code="+mf.code.value+"&phone="+mf.phone.value+"&about="+mf.about.value;			
				document.body.appendChild(script);				 
	    }			
	 }
	 function isEmail() {
	
		var strEmail = document.forms[0].elements("email").value;
		//Данная функция проверяет строку strEmail на соответствие формату почтового адреса.
		//При этом строка разбивается на составные части:
		//имя_пользователя@сервер
	
		if (strEmail=="") {
			alert("Введите, пожалуйста, E-mail");
			document.forms[0].elements("email").focus();
			return false;
		}
	
		var letters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		var numbers="0123456789";
		
		var name="";
		var server="";
		var strings=new Array();
		
		//разделяем строку на имя пользователя и имя сервера
		strings=strEmail.split("@");
		if (strings.length==1) {
			alert("Ошибка: e-mail должен содержать символ @");
			document.forms[0].elements("email").focus();
			return false;
		} else if (strings.length==2) {
			name=strings[0];
			server=strings[1];
		} else {
			alert("Ошибка: e-mail не может содержать более одного символа @");
			document.forms[0].elements("email").focus();
			return false;
		}
		
		//проверка имени на допустимость символов
		if (!isValid(name,letters+numbers+"._-")) {
			alert("Недопустимые символы в имени пользовател\я");
			document.forms[0].elements("email").focus();
			return false;
		}
		
		//разделяем имя сервера на составные части
		strings=server.split(".");
		if (strings.length<2) {
			alert("Нераспознанный e-mail");
			document.forms[0].elements("email").focus();
			return false;
		}
		//проверяем каждую часть на допустимые символы
		for (i=0;i<strings.length;i++) {
			if (!isValid(strings[i],letters+numbers+"_-")) {
				alert("Нераспознанный e-mail");
				document.forms[0].elements("email").focus();
				return false;
			}
		}
		
		return true;
		
	}
	
	function isValid(what,chars) {
		//проверяет, что все символы из what принадлежат множеству chars
		//если what пустая - ошибка
		while (what.charAt(0)==" ") {
			what=what.substring(1);
		}
		if (what=="") {
			return false;
		}
		bool1=false;
		for (count1=0; (count1<what.length)&&(!bool1);count1++) {
			bool2=false;
			for (count2=0; (count2<chars.length)&&(!bool2);count2++) {
				if (what.charCodeAt(count1)==chars.charCodeAt(count2)) {
					bool2=true;
				}
			}
			if (!bool2) {
				bool1=true;
			}
		}
		return !bool1;
	}

var currentSpecTour=1;
function ShowSpecTour(tour_id, is_manual_change) {
	
	if(tour_id!=currentSpecTour) {
		if(is_manual_change)
			clearInterval(intervalId);
		
		$("#tour"+currentSpecTour).fadeOut("fast",
			function(){
				$("#tour"+tour_id).fadeIn("fast");
			}
		);	
		$("#p_tour"+currentSpecTour).toggleClass("current");
		$("#p_tour"+tour_id).toggleClass("current");
		
		currentSpecTour = tour_id;
	}
	return false;
}
function NextTour() {
	if(currentSpecTour==num_pages)
		next = 1;
	else
		next = currentSpecTour+1;
	
	ShowSpecTour(next, false);
}