﻿function HTNchangecity(){
var inForm = document.HTNBanner;
var selected= document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value;
var selected1= document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].text;
var sel_city = document.HTNBanner.c.value.toUpperCase();
var intSel = 0;
var selectedArray;
if ((selected.toUpperCase() != "ALL") && (selected.toUpperCase() != "AS") && (selected.toUpperCase() != "SP") && (selected.toUpperCase() != "EU") && (selected.toUpperCase() != "AF") && (selected.toUpperCase() != "CA") && (selected.toUpperCase() != "CB") && (selected.toUpperCase() != "ME")
&& (selected.toUpperCase() != "NA") && (selected.toUpperCase() != "SA") )​{
//alert("inside ");
	selectedArray = eval(selected + "Array");
	inForm.city.length = 0;
	for (var i=0; i < selectedArray.length; i++) {
		//alert("inForm.city.options[i]=" + document.HTNBanner.country.options.length);
		eval("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
		
		if (sel_city.indexOf(inForm.city.options[i].value.toUpperCase()) == 0) {
		intSel = i;
		}
	}
}else if (((selected.toUpperCase()=="SA") || (selected.toUpperCase()=="NA")  || (selected.toUpperCase()=="CA")) && (selected1.indexOf("-")!=-1))​{
	//alert("inside SA");
	selectedArray = eval(selected + "Array");
	inForm.city.length = 0;
	for (var i=0; i < selectedArray.length; i++) {
		//alert("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
		eval("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
		if (sel_city.indexOf(inForm.city.options[i].value.toUpperCase()) == 0) {
		intSel = i;
		}
	}
}else{
			inForm.city.length = 0;
			switch (document.HTNBanner.txtLang.value.toUpperCase()){
				case "EN":
					inForm.city.options[0]=new Option('----- Select city -----', 'all');
					break;
				case "JP":
					inForm.city.options[0]=new Option('-- Select city --', 'all');
					break;
				case "CN":
					inForm.city.options[0]=new Option('-- Select city --', 'all');
					break;
				case "DE":
					inForm.city.options[0]=new Option('- Select city -', 'all');
					break;
				case "FR":
					inForm.city.options[0]=new Option('-- Choisissez une Ville --', 'all');
					break;
				case "IT":
					inForm.city.options[0]=new Option('-- Select city --', 'all');
					break;
				case "KR":
					inForm.city.options[0]=new Option('-- Select city --', 'all');
					break;
				case "ES":
					inForm.city.options[0]=new Option('-- Select city --', 'all');
					break;
				default: 
					inForm.city.options[0]=new Option('----- Select city -----', 'all');
					break;
			}
			
			inForm.city.options[1]=new Option('---------------------------', 'all');
			inForm.city.options[2]=new Option('---------------------------', 'all');
			inForm.city.options[3]=new Option('---------------------------', 'all');
		}
	inForm.city.options[intSel].selected = true;	
}

function HTNgotoURL(id, country, city, lang){
//http://www.hoteltravel.com/agents/passthrough.asp?rt=s&a=1000&co=TH&c=BKK&or=la&lng=en
//http://www.hoteltravel.com/search/search.aspx?co=TH&ci=BKK&ar=&or=la&txt=&lng=en
    //var URL = "http://www.hoteltravel.com/searchinghotel/searching.aspx?";
    //window.location = URL + "country=" + country + "&city=" + city + "&lang=" + lang + "&amp;ru=http://www.hoteltravel.com";
aid = "1000";
if (id != ''){
aid = id;
}
var URL = "http://www.hoteltravel.com/agents/passthrough.asp?";
    window.location = URL + "rt=s&a=" + aid + "&co=" + country.toUpperCase() + "&c=" + city.toUpperCase() + "&or=&lng=" + lang.toLowerCase();
    return false;
}

function HTNloadCss()
{
var lang = document.HTNBanner.txtLang.value.toLowerCase();
var sChar = "iso-8859-1";
switch (lang.toUpperCase()){
	case "JP":
		sChar="shift_jis";
		break;
	case "CN":
		sChar="gb2312";
		break;
	case "KR":
		sChar="euc-kr";
		break;
	default: 
		sChar="iso-8859-1";
		break;
}
    if ((lang.length == 0) || (lang == 'en')){
        document.write('<script type="text/javascript" src="http://www.hoteltravel.com/javascript/cityarray.js" charset="iso-8859-1"></script>');
    }else{
        document.write('<script type="text/javascript" src="http://www.hoteltravel.com/javascript/cityarray'+lang+'.js" charset="'+sChar+'" ></script>');
    }
document.write('<script type="text/javascript" src="http://www.hoteltravel.com/partner/javascript/countryarray.js"></script>');
document.write('<link href="http://www.hoteltravel.com/partner/affiliate.css" rel="stylesheet" type="text/css"/>');
}

function HTNgenList() 
{
var inForm = document.HTNBanner;
var lang = document.HTNBanner.txtLang.value;
var selectedAll= document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value.toUpperCase();
var selected= document.HTNBanner.co.value.toUpperCase();
var countryname = '';
var selectedArray;
var htmlout = '';
if (selected != '' ){
	for (var i=0; i < document.HTNBanner.country.options.length; i++){	
		if ((selected == document.HTNBanner.country.options[i].value.toUpperCase()) && (document.HTNBanner.country.options[i].text.indexOf("-") == 0)){
			countryname = document.HTNBanner.country.options[i].text;
			var tVar = "'" + selected + "', 'all', '" + lang +"'";
			selectedArray = eval(selected + "Array");
			if (selectedAll == 'ALL'){
				document.HTNBanner.country.options[i].selected = true;
				HTNchangecity();
			}
			i = document.HTNBanner.country.options.length;
			for (var j=1; j < document.HTNBanner.city.options.length; j++){
				tVar = "'" + selected + "', '" + document.HTNBanner.city.options[j].value + "', '" + lang +"'";
			}
		}
	}
}
}

function HTNgenform(sizeCode){
     //Data is indexed by user id, and represents an object where keys 
     //correspond with the app data fields.
     
     var selectedArray;
     var lang = document.HTNBanner.txtLang.value.toLowerCase();
		if ((lang.length == 0) || (lang == 'en')){
		selectedArray = eval("CountryArray");
		}else{
     	selectedArray = eval("CountryArray" + lang );
     	}
     var selected= document.HTNBanner.co.value.toUpperCase();
     var htmlout = '';
     var div = document.getElementById('HTNgenform');
if (sizeCode == "234_60"){ 
     htmlout += '<div class="BNR2form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext1">';
     htmlout += selectedArray + '</select></div>';   
     htmlout += '<div class="BNR2form02"><select name="city" class="HTNformtext1"><option value="all" selected ="selected">-- Select city --</option></select></div>';
     div.innerHTML = htmlout;
     var divbottom = document.getElementById('HTNbutton');
     divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_234_60.gif" alt="Book Now" border="0"/></a>';
}else if(sizeCode == "160_140"){
     htmlout += '<div class="BNR1form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext">'; 
     htmlout += selectedArray + '</select></div>';   
     htmlout += '<div class="BNR1form02"><select name="city" class="HTNformtext"><option value="all" selected ="selected">-- Select city --</option></select></div>';
     div.innerHTML = htmlout;
     var divbottom = document.getElementById('HTNbutton');
     divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_160_140.gif" alt="Book Now" border="0" /></a>';
}else if(sizeCode == "120_125"){
    htmlout += '<div class="BNR3form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext">'; 
    htmlout += selectedArray + '</select></div>';   
    htmlout += '<div class="BNR3form02"><select name="city" class="HTNformtext"><option value="all" selected ="selected">-- Select city --</option></select></div>';
    div.innerHTML = htmlout;
    var divbottom = document.getElementById('HTNbutton');
    divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_120_125.gif" alt="Book Now" border="0" /></a>';
}else if(sizeCode == "120_240"){
    htmlout += '<div class="BNR4form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext">'; 
    htmlout += selectedArray + '</select></div>';   
    htmlout += '<div class="BNR4form02"><select name="city" class="HTNformtext"><option value="all" selected ="selected">-- Select city --</option></select></div>';
    div.innerHTML = htmlout;
    var divbottom = document.getElementById('HTNbutton');
    divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_120_240.gif" alt="Book Now" border="0" /></a>';
}else if(sizeCode == "180_150"){
    htmlout += '<div class="BNR5form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext">'; 
    htmlout += selectedArray + '</select></div>';   
    htmlout += '<div class="BNR5form02"><select name="city" class="HTNformtext"><option value="all" selected ="selected">-- Select city --</option></select></div>';
    div.innerHTML = htmlout;
    var divbottom = document.getElementById('HTNbutton');
    divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_180_150.gif" alt="Book Now" border="0" /></a>';
}else if (sizeCode == "468_60"){ 
    htmlout += '<div class="BNR6form01"><select onchange="HTNchangecity()" name="country" class="HTNformtext1">';
    htmlout += selectedArray + '</select></div>';   
    htmlout += '<div class="BNR6form02"><select name="city" class="HTNformtext1"><option value="all" selected ="selected">-- Select city --</option></select></div>';
    div.innerHTML = htmlout;
    var divbottom = document.getElementById('HTNbutton');
    divbottom.innerHTML = '<a href="javascript:void(0);" onclick="return HTNgotoURL(document.HTNBanner.aid.value, document.HTNBanner.country.options[document.HTNBanner.country.selectedIndex].value, document.HTNBanner.city.options[document.HTNBanner.city.selectedIndex].value, document.HTNBanner.txtLang.value)" target="_blank"><img src="images/bt_booknow_468_60.gif" alt="Book Now" border="0"/></a>';
}
}

function HTNDisplay(control, visible){
    var browsername = navigator.appName;
    if (document.layers){
        browsername = "NN4";
    }
    if (document.all){
        browsername = "NN6";
    }
    if (!document.all && document.getElementById){
        browsername = "NN6";
    }
    if (browsername == "NN6"){
        var ctril;
        ctril = "document.getElementById(\"" + control + "\")";
        var ctlName;
        ctlName = eval(ctril);
        if (ctlName.style.visibility == "visible"){
            ctlName.style.visibility = "hidden";
            ctlName.style.display = "none";
        } else {
            ctlName.style.visibility = "visible";
            ctlName.style.display = "";
        }
    } else if (browsername == "NN4"){
        var ctlName;
        ctlName = eval("document." + control);
        if (ctlName.style.visibility == "visible"){
            ctlName.style.visibility = "hidden";
            ctlName.style.display = "none";
        } else {
            ctlName.style.visibility = "visible";
            ctlName.style.display = "";
        }
    } else {
        var ctlName;
        ctlName = eval("document.all." + control);
        if (ctlName.style.visibility == "visible"){
            ctlName.style.visibility = "hidden";
            ctlName.style.display = "none";
        } else {
            ctlName.style.visibility = "visible";
            ctlName.style.display = "";
        }
    }
}