function RohContent(param){var xmlPath=gHost+"xml";this.createInterestList=createInterestList;this.createDestList=createDestList;this.addInterestChange=addInterestChange;var cSeperator=",";function createInterestList(){if(param.listObj.indexOf("http")<0){var listFileName=xmlPath+param.listObj.toLowerCase()+".xml";}else{var listFileName=param.listObj.toLowerCase()+".xml";}var selectInterestValue="";var selectDestValue="";var Loc=window.location;var myLoc=Loc.toString().split("#");if(myLoc.length>1){var myParam=myLoc[1].split("_");selectInterestValue=myParam[0];if(myParam.length>1){selectDestValue=myParam[1]+"|"+myParam[2];}}$("#"+param.objName).empty();$.ajax({type:"GET",url:listFileName,dataType:"xml",success:function(xmlDoc){createInterest(xmlDoc,param.objName,param.title,param.lang,selectInterestValue);if(selectDestValue!=""){createDestList(selectInterestValue,selectDestValue);}},error:function(){}});}function createInterest(xmlDoc,objName,title,lang,selectValue){var myOptions=[];var i=0;$(xmlDoc).find("item").each(function(){myOptions[i]={optText:$(this).find("name").text(),optValue:$(this).find("code").text()};i++;});var mySort=new Sorting;var sortOptions=mySort.sortSelect(myOptions,true,lang);$("#"+objName).append("<option value=\"\">"+title+"</option>");for(var i=0;i<sortOptions.length;i++){var str="<option value=\""+sortOptions[i].optValue+"\"";if(selectValue==sortOptions[i].optValue){str+=" selected";}str+=">"+sortOptions[i].optText+"</option>";$("#"+objName).append(str);}}function addInterestChange(objName){$("#"+objName).change(function(){$("#"+param.divObj).empty();if(this.options[this.selectedIndex].value==""){$("#"+param.linkGoInt).hide();$("#"+param.objName2).html(param.ErrMsg);}else{myRoh.createDestList(this.options[this.selectedIndex].value,"");}});}function createDestList(selectInterestValue,selectDestValue){if(param.itemObj2.indexOf("http")<0){var listFileName=xmlPath+param.itemObj2.toLowerCase()+selectInterestValue.toLowerCase()+".xml";}else{var listFileName=param.itemObj2.toLowerCase()+selectInterestValue.toLowerCase()+".xml";}$("#"+param.objName2).empty();$.ajax({type:"GET",url:listFileName,dataType:"xml",success:function(xmlDoc){var newList=$("<select></select>").attr({id:param.listName2,size:"1"});$(newList).append("<option value=\"\">"+param.title2+"</option>");var mapCountry=createGroupCountry(xmlDoc,param.lang);for(var i=0;i<mapCountry.length;i++){var str="<option value=\""+mapCountry[i].optValue+"\"";if(selectDestValue==mapCountry[i].optValue){str+=" selected";}str+=">"+mapCountry[i].optText+"</option>";newList.append(str);for(var j=0;j<mapCountry[i].cities.length;j++){var str="<option value=\""+mapCountry[i].cities[j].optValue+"\"";if(selectDestValue==mapCountry[i].cities[j].optValue){str+=" selected";}str+=">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "+mapCountry[i].cities[j].optText+"</option>";newList.append(str);}}if(newList.find("option").length>1){$("#"+param.objName2).append($("<h3></h3>").attr({className:"red"}).text("Select destination"));$("#"+param.objName2).append(newList);$("#"+param.linkGoInt).show();}else{$("#"+param.linkGoInt).hide();$("#"+param.objName2).html(param.ErrMsg);}},error:function(){$("#"+param.linkGoInt).hide();$("#"+param.objName2).html(param.ErrMsg);}});}function createGroupCountry(xmlDoc,lang){var myCountry=[];var i=0;$(xmlDoc).find("item").each(function(){var country=trim($(this).find("country").text());var city=trim($(this).find("city").text());if(country==""){return;}var no=getDupCountry(myCountry,country);var pos=no;if(no==-1){myCountry[i]={optText:country,optValue:"country|"+country.toLowerCase(),cities:[]};pos=i;i++;}var cityArr=createGroupCity(myCountry[pos].cities,city);var k=myCountry[pos].cities.length;for(var j=0;j<cityArr.length;j++){myCountry[pos].cities[k]=cityArr[j];k++;}});var mySort=new Sorting;var sortCountry=mySort.sortSelect(myCountry,true,lang);var mapCountry=[];for(var k=0;k<sortCountry.length;k++){var mapCities=mapCountryCities(myCountry,sortCountry[k].optText);mapCountry[k]={optText:sortCountry[k].optText,optValue:sortCountry[k].optValue,cities:mySort.sortSelect(mapCities,true,lang)};}return mapCountry;}function mapCountryCities(countryList,country){for(var i=0;i<countryList.length;i++){if(country==countryList[i].optText){return countryList[i].cities;}}return[];}function createGroupCity(myCities,txtCity){var cityArr=[];var cities=txtCity.split(cSeperator);var i=0;for(var j=0;j<cities.length;j++){var cityText=trim(cities[j]);var cityValue="city|"+cityText.toLowerCase();if(!isDupCity(myCities,cityText)){cityArr[i]={optText:cityText,optValue:cityValue};i++;}}return cityArr;}function getDupCountry(myCountry,value){for(var j=0;j<myCountry.length;j++){if(value==myCountry[j].optText){return j;}}return-1;}function isDupCity(myCities,value){if(value==""){return true;}for(var j=0;j<myCities.length;j++){if(value==myCities[j].optText){return true;}}return false;}function trim(stringToTrim){return stringToTrim.replace(/^\s+|\s+$/g,"");}}