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;
if (selected.toUpperCase() != "ALL","AS" ,"SP", "EU", "AF", "CA", "CB", "ME", "NA", "SA"){
	selectedArray = eval(selected + "Array");
	inForm.city.length = 0;
	for (var i=0; i < selectedArray.length; i++){
		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()=="CA", "NA", "SA") && (selected1.indexOf("-")!=-1)){
	selectedArray = eval(selected + "Array");
	inForm.city.length = 0;
	for (var i=0; i < selectedArray.length; 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(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 (document.HTNBanner.aid.value){
    aid = document.HTNBanner.aid.value;
    }

    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 HTNgotoURL(id, country, city, lang){
aid = "1000";
if (id != ''){
aid = id;
}
//var URL = "http://www.hoteltravel.com/agents/passthrough.asp?";
if (document.HTNBanner.urllink == null){ 
URL = '';
}else{ URL = document.HTNBanner.urllink.value}
if ((URL != '') || (URL != 'http://www.hoteltravel.com/'))
{
	if (document.getElementById("iframeHTNSearchPartner")!=null){
        window.frames["iframeHTNSearchPartner"].location = URL + '?AId='+aid+'&lng='+lang+'&co='+country+'&c='+city+'&or=ra&s=true&pb=true';
    }else{
		window.location =  "http://www.hoteltravel.com/agents/passthrough.asp?rt=s&a=" + aid + "&co=" + country.toUpperCase() + "&c=" + city.toUpperCase() + "&or=&lng=" + lang.toLowerCase();
	}
}else{
    window.location =  "http://www.hoteltravel.com/agents/passthrough.asp?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/hoteltravel_ads_160_140.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 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(){
     //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');
     htmlout += '<div align="center" style="height:20px; padding-top:25px;padding-bottom:2px;"><select onchange="HTNchangecity()" name="country" class="HTNfromtext" style="padding:0px;margin:0px; width:116px;font:normal 11px Tahoma; height:18px;">'; 
     htmlout += selectedArray + '</select></div>';   
     htmlout += '<div align="center" style="height:20px;padding-bottom:2px;"><select name="city" class="HTNfromtext" style="padding:0px;margin:0px;width:116px;font:normal 11px Tahoma; height:18px;"><option value="all" selected ="selected">-- Select city --</option></select></div>';
     htmlout += '<div align="center" style="padding-top:2px;padding-bottom:4px;text-align:center;"><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="http://www.hoteltravel.com/partner/images/botton_go.gif" alt="Book Now" border="0" /></a></div>';
     div.innerHTML = htmlout;
}

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 (visible == "hidden"){
            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 (visible == "hidden"){
            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 (visible == "hidden"){
            ctlName.style.visibility = "hidden";
            ctlName.style.display = "none";
        } else {
            ctlName.style.visibility = "visible";
            ctlName.style.display = "";
        }
    }
}