// JavaScript Document
/*
Auto center window script
*/
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
myString = new String(mypage)
myRE = new RegExp("tellfriends.php", "i")
results = myString.match(myRE)
//win = window.open(mypage+'?refer='+this.location,myname,settings)
	if(results=="tellfriends.php"){ 
		return false;
	}else{
		win = window.open(mypage,myname,settings)
	}
}


function submitListGroup(){
	var hotelnamelist=document.getElementById("hotelname");
	if(hotelnamelist.value!=""){
		document.location = hotelnamelist.options[hotelnamelist.selectedIndex].value;
	}
}
function getCookie (name) {
var YourCookie = document.cookie;
var cname = name + "=";
var clen = YourCookie.length;
var cbegin = 0;

while (cbegin < clen) {
var vbegin = cbegin + cname.length;
    if (YourCookie.substring(cbegin, vbegin) == cname) {
    var vend = YourCookie.indexOf (";", vbegin);
    if (vend == -1) vend = clen;
    return unescape(YourCookie.substring(vbegin, vend));
    }
cbegin = YourCookie.indexOf(" ", cbegin) + 1;
if (cbegin == 0) break;
}
return null;
}

function Trim(STRING){
STRING = LTrim(STRING);
return RTrim(STRING);
}

function RTrim(STRING){
while(STRING.charAt((STRING.length -1))==" "){
STRING = STRING.substring(0,STRING.length-1);
}
return STRING;
}


function LTrim(STRING){
while(STRING.charAt(0)==" "){
STRING = STRING.replace(STRING.charAt(0),"");
}
return STRING;
}

function doTrim(obj){
	if(obj.length<3){ alert("Your fill-in must more than three characters");obj.focus();}
	if(chkDoubleStr(obj.value)==true){ alert("Duplicate characters, please revise it.");obj.focus();}
	return obj.value=Trim(obj.value);
}

function chkDoubleStr(STRING){
//	if(STRING.charAt(0)==" "){ return true;}
	var explode=STRING.split("");
	//var strlen=new Array();
	//var string=new Array();
	var count=new Array();
	for(i=0;i<explode.length-2;i++){
		//strlen[i]=explode[i].length;
		//string[i]=explode[i].charAt(0);
		//count[i]=0;
		if((explode[i]==explode[i+1]) && (explode[i]==explode[i+2])){
			 return true;break;
		}
/*		for(j=0;j<strlen[i];j++){
			if(j>0){
				if(explode[i].charAt(j)==string[i]){
					count[i]=count[i]+1;
					if(count[i]==3){ return true;break;}
				}else{
					count[i]=1;
				}
			}
		}
*/	}
}

 function maxlength(element, maxvalue)
     {
     var q = eval("document.pooh."+element+".value.length");
     var r = q - maxvalue;
     var msg = "Sorry, you have input "+q+" characters into the "+
       "text area box you just completed. It can return no more than "+
       maxvalue+" characters to be processed. Please abbreviate "+
       "your text by at least "+r+" characters";
     if (q > maxvalue) alert(msg);
}

// LOAD FOOTER
var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function loadFooter(langid){
	createXMLHttpRequest();
	var url;
	if(langid=='russian'){
		url = "http://www.thailandtravel.ru/languages/russian/footer.php";
	}else{
		url = "http://www.thailandtravel.ru/languages/english/footer.html";
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				document.getElementById("showfooter").innerHTML = xmlHttp.responseText;
			}
		}
	};
	xmlHttp.send(null);

}

function loadAdsSession(){
	createXMLHttpRequest();
	var url="http://ads.fargotravel.com/do.session.php";
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
			}
		}
	};
	xmlHttp.send(null);
}
function reloadspace(type){
	if(type==1){
		var leftHeight=document.getElementById("menuLeftbody").offsetHeight;
		var contentBodyHeight=(document.getElementById("contentBody").offsetHeight+510);
		var spaceHeight=leftHeight-contentBodyHeight;
		var newspaceHeight=spaceHeight+"px";
		//alert(newspaceHeight);
		if (spaceHeight>0){ document.getElementById("space").style.height=newspaceHeight;}
	}
	if(type==0){
		document.getElementById("space").style.height="0px";
	}
}

function reloadspacehotelist(type){
	if(type==1){
		var leftHeight=document.getElementById("menuLeftbody").offsetHeight;
		var contentBodyHeight=(document.getElementById("contentBody").offsetHeight);
		var spaceHeight=leftHeight-contentBodyHeight;
		var newspaceHeight=spaceHeight+"px";
		//alert(newspaceHeight);
		if (spaceHeight>0){ document.getElementById("space").style.height=newspaceHeight;}
	}
	if(type==0){
		document.getElementById("space").style.height="0px";
	}
}
//-->
