
function setEngType(val){
document.forms["form1"].pkgType.value = val;
document.forms["ResPkgSearchForm"].pkgType.value = val;
document.forms["ResPkgSearchForm"].elements["engineType"].value=val;
if (val=="H"){
document.getElementById("hotelDisplay").style.display="block";
document.getElementById("activityDisplay").style.display="none";	
showRooms;
document.forms["form1"].elements["H_nights"].value="1";
}else if (val=="A"){
document.getElementById("hotelDisplay").style.display="none";		
document.getElementById("activityDisplay").style.display="block";		
document.forms["form1"].elements["activity_nights"].value="1";
}			
}
function search(){
document.forms["ResPkgSearchForm"].elements["pkgType"].value=document.forms["form1"].pkgType.value;
eval("loadDataNew_"+document.forms["form1"].pkgType.value+"()");
}

adTime=10; // seconds reminder shows
chanceAd=1; // ad will be 1 in z times (put 1 for everytime)
var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;
function initAd(){
try{
if(!ns && !ie && !w3) return;
if(ie) adDiv=eval('document.all.sponsorAdDiv.style');
else if(ns) adDiv=eval('document.layers["sponsorAdDiv"]');
else if(w3) adDiv=eval('document.getElementById("sponsorAdDiv").style');
randAd=Math.ceil(Math.random()*chanceAd);
if (ie||w3)
adDiv.visibility="visible";
else
adDiv.visibility ="show";
if(randAd==1) showAd();
}catch(ex){}
}
function showAd(){
if(adCount<adTime*10){adCount+=1;
if (ie){documentWidth =truebody().offsetWidth/2+truebody().scrollLeft+396;
documentHeight =truebody().offsetHeight/2+truebody().scrollTop;} 
else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset+396;
documentHeight=window.innerHeight/2+window.pageYOffset;} 
else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset+396;
documentHeight=self.innerHeight/2+window.pageYOffset;} 
adDiv.left=documentWidth-200+calunit;adDiv.top =documentHeight-200+calunit;
setTimeout("showAd()",100);}else closeAd();
}
function closeAd(){
if (ie||w3)
adDiv.display="none";
else
adDiv.visibility ="hide";
}
function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

var varnum=1280;
var schemaName="studio92";
var subURL="http://www.studios92.eu/"+schemaName+"";
//var schemaName="rezbase_v1";
//var subURL="http://192.168.1.120:8080/"+schemaName+"";
var airTxtArr = new Array();
var _month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
// hotel
function loadDataNew_H(){
	setFields("H");
	document.forms["ResPkgSearchForm"].action=subURL+"/packaging/reservation/ResPkgSearchCriteria.do?ActionType=ResSearchHotels";
	if (chkDates()){showError();return;}

	for (var rezgv=0; rezgv<cityTxtArr.length; rezgv++){
	if (cityArr[rezgv][1] == cur[document.forms["form1"].elements["selTown"].selectedIndex])  { if  (cityArr[rezgv][5]==scityTxtArr[document.forms["form1"].elements["selCity"].selectedIndex])
	{
		varnum=rezgv; 
	}}
	}
	document.forms["ResPkgSearchForm"].searchCityId.value		= cityArr[varnum][0];
	document.forms["ResPkgSearchForm"].searchCityName.value	= cityArr[varnum][1];
	document.forms["ResPkgSearchForm"].searchStateId.value	= cityArr[varnum][2];
	document.forms["ResPkgSearchForm"].searchCountryId.value	= cityArr[varnum][3];
	
	document.forms["ResPkgSearchForm"].cmbCty_Hotels.value	= document.forms["ResPkgSearchForm"].searchCityId.value;
	document.forms["ResPkgSearchForm"].cityLookup_Hotels.value	= document.forms["ResPkgSearchForm"].searchCityName.value;
	document.forms["ResPkgSearchForm"].cmbSte_Hotels.value	= document.forms["ResPkgSearchForm"].searchStateId.value;
	document.forms["ResPkgSearchForm"].cmbCtry_Hotels.value	= document.forms["ResPkgSearchForm"].searchCountryId.value;
	
	document.forms["ResPkgSearchForm"].cmbInYr_Hotels.value	= Number(document.forms["form1"].elements["H_InYear"].options[document.forms["form1"].elements["H_InYear"].selectedIndex].value);
	document.forms["ResPkgSearchForm"].cmbInMn_Hotels.value	= Number(document.forms["form1"].elements["H_InMonth"].options[document.forms["form1"].elements["H_InMonth"].selectedIndex].value)+1;
	document.forms["ResPkgSearchForm"].cmbInDt_Hotels.value	= Number(document.forms["form1"].elements["H_InDate"].options[document.forms["form1"].elements["H_InDate"].selectedIndex].value);	
	document.forms["ResPkgSearchForm"].cmbNgt_Hotels.value	= Number(document.forms["form1"].elements["H_nights"].options[document.forms["form1"].elements["H_nights"].selectedIndex].value);
	
	document.forms["ResPkgSearchForm"].cmbOutYr_Hotels.value	= Number(document.forms["form1"].elements["H_OutYear"].options[document.forms["form1"].elements["H_OutYear"].selectedIndex].value);
	document.forms["ResPkgSearchForm"].cmbOutMn_Hotels.value	= Number(document.forms["form1"].elements["H_OutMonth"].options[document.forms["form1"].elements["H_OutMonth"].selectedIndex].value)+1;
	document.forms["ResPkgSearchForm"].cmbOutDt_Hotels.value	= Number(document.forms["form1"].elements["H_OutDate"].options[document.forms["form1"].elements["H_OutDate"].selectedIndex].value);
		
		
	var totalAdults 	= 0;
	var totalChildren	= 0;
	var occupancyStr	= "";
	//document.forms["ResPkgSearchForm"].gstLst_Hotels.value = "";
	if(document.forms["ResPkgSearchForm"].elements["accommodationType"].value == "HS"){	
		document.forms["ResPkgSearchForm"].cmbNoRm_Hotels.value	= Number(document.forms["form1"].elements["H_Adults"].options[document.forms["form1"].elements["H_Adults"].selectedIndex].value);	
		document.forms["ResPkgSearchForm"].totRooms_Hotels.value	= Number(document.forms["form1"].elements["H_Adults"].options[document.forms["form1"].elements["H_Adults"].selectedIndex].value);
	}
	if(document.forms["ResPkgSearchForm"].elements["accommodationType"].value == "HT"){
		document.forms["ResPkgSearchForm"].cmbNoRm_Hotels.value	= Number(document.forms["form1"].elements["H_cmbNoOfRooms"].options[document.forms["form1"].elements["H_cmbNoOfRooms"].selectedIndex].value);	
		document.forms["ResPkgSearchForm"].totRooms_Hotels.value	= Number(document.forms["form1"].elements["H_cmbNoOfRooms"].options[document.forms["form1"].elements["H_cmbNoOfRooms"].selectedIndex].value);
	}
	
	if(document.forms["ResPkgSearchForm"].hotelCode_Hotels.value==""){
		document.forms["ResPkgSearchForm"].shtcd_Hotels.value="0";
	}
	if(document.forms["ResPkgSearchForm"].occupancy_Details_Hotels.value==""){
		if(document.forms["ResPkgSearchForm"].elements["accommodationType"].value == "HT"){
			document.forms["ResPkgSearchForm"].occupancy_Details_Hotels.value = "<room1Adult>1</room1Adults><room1Children>0</room1Children>";
		}
	}

//	document.forms["ResPkgSearchForm"].gstLst_Hotels.value = "1|0|-|%|%@";
//	document.forms["ResPkgSearchForm"].occupancy_Details_Hotels.value = "<room1Adult>1</room1Adults><room1Children>0</room1Children>";
//	document.forms["ResPkgSearchForm"].occupancy_Details_Hotels.value ="";
//	document.forms["ResPkgSearchForm"].totAdlt_Hotels.value	= "1";
//	document.forms["ResPkgSearchForm"].totChi_Hotels.value	= "0";
	document.forms["ResPkgSearchForm"].cmbtourOpt_Hotels.value="0";
	document.forms["ResPkgSearchForm"].pkgType.value	= "H";
	document.forms["ResPkgSearchForm"].partnerId.value	= "0";
	document.forms["ResPkgSearchForm"].partnerType.value	= "DC";	
	befSubmit('H');
	document.forms["ResPkgSearchForm"].submit();
}


//activity
function loadDataNew_A(){
	
	setFields("A");
	document.forms["ResPkgSearchForm"].action=subURL+"/packaging/reservation/ResPkgSearchCriteria.do?ActionType=ResSearchActivities";
	if (chkDates()){showError();return;}
	
	var searchStr = document.forms["form1"].hid_H_Loc.value.split("|");
	document.forms["ResPkgSearchForm"].searchCityId.value	= searchStr[0];
	document.forms["ResPkgSearchForm"].searchCityName.value	= searchStr[1];
	document.forms["ResPkgSearchForm"].searchStateId.value	= searchStr[2];
	document.forms["ResPkgSearchForm"].searchCountryId.value	= searchStr[3];
	document.forms["ResPkgSearchForm"].cmbCty_Activities.value	= document.forms["ResPkgSearchForm"].searchCityId.value;
	document.forms["ResPkgSearchForm"].cityLookup_Activities.value	= document.forms["ResPkgSearchForm"].searchCityName.value;
	document.forms["ResPkgSearchForm"].cmbCtry_Activities.value	= document.forms["ResPkgSearchForm"].searchCountryId.value;
	
	document.forms["ResPkgSearchForm"].cmbInYr_Activities.value	= Number(document.forms["form1"].elements["activity_InYear"].options[document.forms["form1"].elements["activity_InYear"].selectedIndex].value);
	document.forms["ResPkgSearchForm"].cmbInMn_Activities.value	= Number(document.forms["form1"].elements["activity_InMonth"].options[document.forms["form1"].elements["activity_InMonth"].selectedIndex].value)+1;
	document.forms["ResPkgSearchForm"].cmbInDt_Activities.value	= Number(document.forms["form1"].elements["activity_InDate"].options[document.forms["form1"].elements["activity_InDate"].selectedIndex].value);
	
	document.forms["ResPkgSearchForm"].cmbOutYr_Activities.value	= Number(document.forms["form1"].elements["activity_OutYear"].options[document.forms["form1"].elements["activity_OutYear"].selectedIndex].value);
	document.forms["ResPkgSearchForm"].cmbOutMn_Activities.value	= Number(document.forms["form1"].elements["activity_OutMonth"].options[document.forms["form1"].elements["activity_OutMonth"].selectedIndex].value)+1;
	document.forms["ResPkgSearchForm"].cmbOutDt_Activities.value	= Number(document.forms["form1"].elements["activity_OutDate"].options[document.forms["form1"].elements["activity_OutDate"].selectedIndex].value);
	
	document.forms["ResPkgSearchForm"].cmbNgt_Activities.value	= Number(document.forms["form1"].elements["activity_nights"].options[document.forms["form1"].elements["activity_nights"].selectedIndex].value);
	document.forms["ResPkgSearchForm"].actType_Activities.value	= document.forms["form1"].elements["Act_type"].options[document.forms["form1"].elements["Act_type"].selectedIndex].value;
	document.forms["ResPkgSearchForm"].pkgType.value	= "A";
	document.forms["ResPkgSearchForm"].partnerId.value	= "0";
	document.forms["ResPkgSearchForm"].partnerType.value	= "DC";	
	befSubmit('A');
	document.forms["ResPkgSearchForm"].submit();
	
}

var checkMore_new=0;
function setCharSecond(ch,img){
var tmpArr = new Array();
	for (var j=0; j<airTxtArr.length; j++){
		if (airTxtArr[j][0].toUpperCase().indexOf(ch.value.toUpperCase())==0){
			if (!showAllLoc){checkMore_new++;if (checkMore_new>10){break;}}
			tmpArr[tmpArr.length]="<tr><td class=\"stripe"+((j%2)+3)+"\" style=\"padding-left:5px;cursor:pointer;\" onMouseOver=\"altcell('ov',this)\" onMouseOut=\"altcell('ou',this,'stripe"+((j%2)+3)+"')\" onClick=\"setValSecond("+j+",'"+ch.name+"')\">"+airTxtArr[j][0]+" - "+airTxtArr[j][1]+"</td></tr>";
		}
	}
	if (!showAllLoc){
		if (checkMore_new>10){tmpArr[tmpArr.length]="<tr><td class=\"morebg\" style=\"padding-left:5px;cursor:pointer;\" onClick=\"showAllLoc=true;setCharSecond(document.forms['form1'].elements['"+ch.name+"'],'"+img+"')\" title=\"Show All\" align=\"center\"><img src=\"images/more_arrow.gif\" width=\"9\" height=\"6\" border=\"0\" hspace=\"3\" alt=\"Show All\" align=\"absmiddle\">Show All</td></tr>";}
	}
	checkMore_new=0;
	
	var outSt="";
if (tmpArr.length==0){
	outSt="<table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"3\" class=\"databorder\"><tr><td class=\"stripe4\" onClick=\"setObjPos('ixpDataFrame',0,0,180,0,'none');setObjPos('maskFrame',0,0,180,0,'none');\" align=\"center\">... No Results Available ...</td></tr></table>";
	showRes(img,outSt,1);
}else{
	outSt="<table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"4\" class=\"databorder\">"+tmpArr.join("")+"</table>";
	showRes(img,outSt,tmpArr.length);
}
tmpArr.length=0;
}

function setValSecond(index,obj){
	document.forms["form1"].elements["hid_car_Loc1"].value=airTxtArr[index].join("|");
	document.forms["form1"].elements["hid_air_Loc1"].value=airTxtArr[index].join("|");
	document.forms["form1"].elements[obj].value=airTxtArr[index][0];
			
	setObjPos('ixpDataFrame',0,0,180,0,'none');
	setObjPos('maskFrame',0,0,180,0,'none');
	showAllLoc=false;
}

function altcell(st,obj,cls){
	if (st=="ov"){
	obj.className="overclass";
	}else{
	obj.className=cls;
	}
}
