var openedCardId=new Array()
openedCardId[0]=""

var engineTypes=new Array()
engineTypes[0]="packages";
engineTypes[1]="israel";
engineTypes[2]="flights";
engineTypes[3]="flyanddrive";
engineTypes[4]="regular";
engineTypes[5]="ski";
engineTypes[6]="link_card_1";
engineTypes[7]="link_card_2";
engineTypes[8]="link_card_3";

var _cityLoad=new Array()
var cityXML=new ActiveXObject("Microsoft.XMLDOM")
cityXML.async=false

var windowIsOpend = false
var LOADING_STR='<body dir="'+dir+'"><table><tr><td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="26" height="26" VIEWASTEXT="true" id="ShockwaveFlash11"><param name="movie" value="'+img_path+'flash/counter.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+img_path+'flash/counter.swf" width="26" height="26" type="application/x-shockwave-flash"></embed></object></td><td>'+dic.LOADING_DATA+'</td></tr></table></body>'
var today="";
var onlX=null
var _activeTimer=true
var SEATS_NUM_SCORE=1000,SEATS_NUM_START=10,CALENDAR_W=409


var tmp_lang = "HE";
try
{
	if (!isnull(lang)) 
	{
		tmp_lang = lang;
		if (lang=="RU" || lang=="PL") tmp_lang = "EN";
	}
}
catch(e)
{
	tmp_lang = "HE";
}

if (tmp_lang=="EN")
		{
			cityXML.load("/DATA/activeDestinationsByCountry.EN.xml");
		}
		else
		{
			cityXML.load("/DATA/activeDestinationsByCountry.xml");
		}

var _site_path = path;


function OpenCustomerServiceWin(){
	var top=window.screen.availHeight/2-212
	var left=window.screen.availWidth/2-358
	var CustServWin=window.open('/site/WINDOWS/CustomerService/CustomerService.html','CustServWin','height=425px,width=715px,top='+top+',left='+left)
	return CustServWin
}
function openCard(obj,ind){
	var cells=document.all['cardsTr'+ind].cells
	for(var i=0;i<cells.length;i++){
		try{
			var subcells=cells[i].childNodes(0).rows(0).cells
			for(var j=0;j<subcells.length;j++){
				if(cells[i]==obj) subcells[j].className=String(subcells[j].className).replace("_off","_on")
				else subcells[j].className=String(subcells[j].className).replace("_on","_off")
			}
		}catch(e){}
	}
	if(!isnull(openedCardId[ind])) document.getElementById(openedCardId[ind]).style.display='none'
	document.getElementById(obj.cardId).style.display=''
	openedCardId[ind]=obj.cardId
}

function showEngineCard(objId,engineCard,componentID){
	//if (objId==openedCard.id) return;

	var obj = document.getElementById(objId);
	var compID = !isnull(componentID)?componentID:"";
	//alert(compID);
	var engineType = objId.split('_')[0];
	var cards=document.getElementById(engineCard+compID).childNodes;
	for(var i=0;i<cards.length;i++){
		try{
				//alert(cards[i].id);
				if(cards[i].id==objId){
					cards[i].className=String('on');
					//alert(cards[i].id +":"+cards[i].className);
				}
				else{
					cards[i].className=String('');
					//cards[i].onmouseout = 'className=\'\';';
					//cards[i].onmouseover = 'className=\'on\';';
					//alert(cards[i].id +"else:"+cards[i].className);
				}
				if(engineTypes[i]==engineType)
					document.getElementById("se_"+engineType+compID).style.display='';
				else
					document.getElementById("se_"+engineTypes[i]+compID).style.display='none';
		}
		catch(e){//alert(e.description)
		}
	}
	//if(!isnull(engineType)) document.getElementById("se_"+engineType).style.display='none';
	//obj.style.display='';
	//openedCard=obj;
}

function swapPackageTypesDivs(value,id)
{
	var countriesSelect = document.all['countriesSelect_pse'+id]
	_cityLoad[id] = null
	if(value==""){
		countriesSelect.onclick = "fillCitiesList_Packages(this,id)"
		fillCitiesList_Packages(countriesSelect,id);
		// dispaly hotel category
		document.getElementById("HotelCategory_"+id).style.display="inline";
	}
	else{
		countriesSelect.onclick = "fillCitiesList_FlyAndDrivePackages(this,id)"
		fillCitiesList_FlyAndDrivePackages(countriesSelect,id);
		// hide hotel category
		document.getElementById("HotelCategory_"+id).style.display="none";	
	}
}
function fillCountriesList(obj,id,type,bFlyAndDrive){
	
	var select=obj
	var countries=cityXML.documentElement.selectNodes("//Country[@EN!='ISRAEL' and City/@"+type+"='1'"+(bFlyAndDrive?" and City/@FlyAndDrive='1'":" and City[not(@OnlyFlyAndDrive)] " )+"]")
	obj.length=countries.length+1
	obj[0].selected=true
	for(var i=1;i<countries.length+1;i++){
		var e = countries.nextNode();
		obj[i].text=e.getAttribute(tmp_lang)
		obj[i].value=e.getAttribute("EN")
	}	
}
function fillCitiesList(obj,id,type,bFlyAndDrive){
	
	
	if(isnull(type)) type='f'
	if(!_cityLoad[id])
	{
		_cityLoad[id] = true;
		/*if (tmp_lang=="EN")
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.EN.xml");
		}
		else
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.xml");
		}*/
		if(_cityLoad[id]) fillCountriesList(obj,id,type,bFlyAndDrive)
	}
	if(obj.value=='') return
	var select=document.getElementById('citiesSelect_'+type+'se'+id)
	//var cityes=cityXML.documentElement.selectNodes("//Country[@EN='"+obj.value+"']/City[@"+type+"='1'"+(bFlyAndDrive?" and @FlyAndDrive='1'":"")+"]")
	var cityes=cityXML.documentElement.selectNodes("//Country[@EN='"+obj.value+"']/City[@"+type+"='1'"+(bFlyAndDrive?" and @FlyAndDrive='1'":" and not(@OnlyFlyAndDrive) ")+"]");
	select.length=cityes.length+1
	select[0].selected=true
	for(var i=1;i<cityes.length+1;i++){
		var e = cityes.nextNode();
		select[i].text=e.getAttribute(tmp_lang)
		select[i].value=e.getAttribute("Code")
	}
}
function fillCitiesList_Ski(obj,id){
	
	var type='ski'
	if(!_cityLoad[id])
	{
		_cityLoad[id] = true;
		/*if (tmp_lang=="EN")
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.EN.xml");
		}
		else
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.xml");
		}*/
		if(_cityLoad[id]) fillCountriesList(obj,id,type)
	}
	if(obj.value=='') return
	var select=document.getElementById('citiesSelect_pse'+id)
	var cityes=cityXML.documentElement.selectNodes("//Country[@EN='"+obj.value+"']/City[@"+type+"='1']")
	select.length=cityes.length+1
	select[0].selected=true
	for(var i=1;i<cityes.length+1;i++){
		var e = cityes.nextNode();
		select[i].text=e.getAttribute(tmp_lang)
		select[i].value=e.getAttribute("Code")
	}
}
function fillCitiesList_Israel(obj,id){
	
	var type='p'
	if(!_cityLoad[id])
	{
		_cityLoad[id] = true;
		/*if (tmp_lang=="EN")
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.EN.xml");
		}
		else
		{
			_cityLoad[id]=cityXML.load("/DATA/activeDestinationsByCountry.xml");
		}*/
		if(!_cityLoad[id]) return
	}
	if(obj.value=='') return
	var select=document.getElementById('citiesSelect_'+type+'se'+id)
	var cityes=cityXML.documentElement.selectNodes("//Country[@EN='"+obj.value+"']/City[@"+type+"='1']")
	select.length=cityes.length+1
	select[0].selected=true
	for(var i=1;i<cityes.length+1;i++){
		var e = cityes.nextNode();
		select[i].text=e.getAttribute(tmp_lang)
		select[i].value=e.getAttribute("Code")
	}
}
function fillCitiesList_FlyAndDrivePackages(obj,id){ fillCitiesList(obj,id,'p',true);}
function fillCitiesList_Packages(obj,id){ fillCitiesList(obj,id,'p');}
function emptyList(id){
	var coll=document.all[id]
	if(!coll || coll.length==0) return
	for(var i=0;i<coll.length;i++){
		coll[i].value=""
		coll[i].name=""
	}
}
function buildCalendar(sDate,iDatesRange,ind){
	var sStr="",_contentExist=false,_firstMonth=true,_lastMonth=false,count=0;
	datesRange = !isnull(iDatesRange)?iDatesRange:1;
	today = new Date(sDate.replace(/-/g,'\/'))
	datesRange=Number(datesRange)	
	var endDate=new Date((today.getMonth()+datesRange)+"-"+today.getDate()+"-"+today.getYear())
	var tempDate=new Date("1-1-1900")
	tempDate.setMonth(today.getMonth())
	tempDate.setYear(today.getYear())
	var locTempDate=new Date((tempDate.getMonth()+1)+"-"+tempDate.getDate()+"-"+tempDate.getYear())
	sStr+="<table cellpadding='0' cellspacing='0' border='0'>\
			<tr id='searchByDateMonthes"+ind+"'>"
	for(;tempDate<=endDate;tempDate.setMonth(Number(tempDate.getMonth())+1)){
		locTempDate.setMonth(Number(locTempDate.getMonth())+1)
		if(locTempDate>endDate) _lastMonth=true
		sStr+="<td valign='top' style='display:"+(_firstMonth?"":"none")+";'>\
					<table cellpadding='0' cellspacing='1' border='0' class='calendar'>\
						<tr>\
							<td colspan='7'>\
								<table cellpadding='0' cellspacing='0' border='0'>\
									<tr class='month'>\
										<td class='calend_arrow' onclick='"+(_firstMonth?";":"showPrevMonth("+count+","+ind+")")+"'>"+(_firstMonth?"<img src='"+img_path+"trans.gif' width='13' height='12'>":"<img src='"+img_path+"search_engines/calendar_arrow_right.gif' hspace='3'>")+"</td>\
										<td class='month' width='100%' nowrap>"+dic["MONTH_"+(Number(tempDate.getMonth())+1)]+" : "+tempDate.getYear()+"</td>\
										<td class='calend_arrow' onclick='"+(_lastMonth?";":"showNextMonth("+count+","+ind+")")+"'>"+(_lastMonth?"<img src='"+img_path+"trans.gif' width='13' height='12'>":"<img src='"+img_path+"search_engines/calendar_arrow_left.gif' hspace='3'>")+"</td>\
									</tr>\
								</table>\
							</td>\
						</tr>"+monthTable(tempDate,ind)+"</table>\
				</td>"
		_contentExist=true
		_firstMonth=false
		count++
	}
	sStr+=	"</tr>\
		   </table>"
	if(_contentExist) document.write(sStr)
}

function showNextMonth(index,ind){
	document.getElementById('searchByDateMonthes'+ind).cells(index).style.display='none'
	document.getElementById('searchByDateMonthes'+ind).cells(++index).style.display=''
}
function showPrevMonth(index,ind){
	document.getElementById('searchByDateMonthes'+ind).cells(index).style.display='none'
	document.getElementById('searchByDateMonthes'+ind).cells(--index).style.display=''
}
function monthTable(dDate,ind){
	var dCurrDayInMonth=new Date("1-1-1900")
	var dLastDayInMonth=new Date("1-1-1900")
	var currDayInWeek
	var sStr=""
	with(dCurrDayInMonth){
		setYear(dDate.getYear())
		setMonth(dDate.getMonth())
		setDate(1)
	}
	with(dLastDayInMonth){
		setYear(dDate.getYear())	
		setMonth(Number(dDate.getMonth())+1)	
		setDate(0)
	}
	currDayInWeek=dCurrDayInMonth.getDay()
	sStr+="<tr class='days_in_week'>"
		for(var i=0;i<7;i++){
			sStr+="<td class='days_in_week' "+(i==0?"style='border-right:solid 0 white;'":"")+">"+dic["DAY_"+(i+1)]+"</td>"
		}
	sStr+="</tr>"
	if(currDayInWeek>0){
		sStr+="<tr class='days'>"
		for(var i=0;i<currDayInWeek;i++){
			sStr+="<td class='empty_day'>&nbsp;</td>"
		}
	}
	for(;dCurrDayInMonth<=dLastDayInMonth;dCurrDayInMonth.setDate(Number(dCurrDayInMonth.getDate())+1)){
		currDayInWeek=dCurrDayInMonth.getDay()
		if(currDayInWeek==0) sStr+="</tr><tr class='days'>"
		var sMonth=String(dCurrDayInMonth.getMonth()+1)
		if(sMonth.length<2) sMonth="0"+sMonth
		var sDay=String(dCurrDayInMonth.getDate())
		if(sDay.length<2) sDay="0"+sDay
		var sCurrDayInMonth=dCurrDayInMonth.getYear()+"-"+sMonth+"-"+sDay
		sStr+="<td class='days"+(dCurrDayInMonth<today?" notactive_day":"")+"' "
		if(dCurrDayInMonth>=today){
			sStr+=" onmouseover='this.className=\"days_over\"' onmouseout='this.className=\"days\"' \
				 onclick='runSearchByDate(\""+sCurrDayInMonth+"\","+ind+")' "
		}
		sStr+=">"+dCurrDayInMonth.getDate()+"</td>"
	}
	if(currDayInWeek<6){
		for(var i=currDayInWeek;i<6;i++){
			sStr+="<td class='empty_day'>&nbsp;</td>"
		}
		sStr+="</tr>"
	}	
	return sStr
}
function runSearchByDate(sDate,ind){
	try{ _activeTimer=false;}catch(e){}
	var emptyAction=document.getElementById("emptyAction"+ind).value
	if(emptyAction=="NOFSHONIM") emptyList('Dest_FlightsDate'+ind);
	if(emptyAction=="FLIGHTS") emptyList('Dest_PackagesDate'+ind);
	with(document){
		getElementById("OutboundDate_Start_date"+ind).value=sDate;
		getElementById("OutboundDate_End_date"+ind).value=sDate;
		getElementById("searchFormByDate"+ind).submit();
	}
}
function openCalendar(obj,id){
	var mode=obj.mode
	var formID="detailsForm_"+id
	var dealType=obj.dealType
	if(isnull(dealType)) dealType="FLIGHTS"//"PACKAGES"
	var CALENDAR_H=403;
	var top=window.screen.availHeight/2-CALENDAR_H/2
	var left=window.screen.availWidth/2-CALENDAR_W/2
	var calendarWinFeatures = "height="+CALENDAR_H+"px,width="+CALENDAR_W+"px,top="+top+",left="+left+",center=no,status=no,scrollbars=yes,resizable=no"
	var calendarWin = window.open('about:blank','calendarWin',calendarWinFeatures)
	calendarWin.document.write(LOADING_STR)
	calendarWin.document.body.style.cursor='wait'
	var formObj=document.getElementById(formID)
	formObj.action=windows_path+"CALENDAR/calendar.asp?pi="+node_pi+"&id="+id
	formObj.target="calendarWin"
	formObj.submit()
	calendarWin.focus()
}

function goToFlightPriceTemplate(id,module){ goToPriceTemplate(id,false,module);}

function goToPackagePriceTemplate(id,module){ goToPriceTemplate(id,true,module);}

function goToPriceTemplate(id,bPackages,module){
	var viewIn = ""
	if(document.getElementById('view_in_'+id)) viewIn = document.getElementById('view_in_'+id).value;
	
	var oInFlightID=document.getElementById('InFlightID_'+id)
	if(isnull(oInFlightID.value)){
		alert(dic.CHOOSE_RETURN_DATE)
		return
	}
	with(document){
		switch(module){
			case "FLIGHTS":
				isnull(viewIn)?tempAction=flights_action:tempAction=(pagePath+"?pi="+viewIn);	
				getElementById('detailsForm_'+id).action=tempAction;
				break;
			case "ISRAEL":
				isnull(viewIn)?tempAction=israel_action:tempAction=(pagePath+"?pi="+viewIn);	
				getElementById('detailsForm_'+id).action=tempAction;
				break;
			case "PACKAGES":
				isnull(viewIn)?tempAction=packages_action:tempAction=(pagePath+"?pi="+viewIn);	
				getElementById('detailsForm_'+id).action=tempAction;
				break;	
			default:
				getElementById('detailsForm_'+id).action=''
		}
		getElementById('queryName_'+id).value=(bPackages?'PackageDealDetailsRequest':'FlightDealDetailsRequest');
		getElementById('detailsForm_'+id).submit();
	}
}
function goToPriceTemplateOfFlyAndDrive(id){
	var oInFlightID=document.getElementById('InFlightID_'+id)
	if(isnull(oInFlightID.value)){
		alert(dic.CHOOSE_RETURN_DATE)
		return
	}
	with(document){
		getElementById('detailsForm_'+id).action = ""
		getElementById('queryName_'+id).value='PackageDealDetailsRequest';
		getElementById('detailsForm_'+id).submit();
	}
}
function goToFlightPassengersDetailes(){
	if(document.getElementById('num_of_passengers0').value==""){
		alert(dic.CHOOSE_PASSENGERS_NUMBER)
		return
	}
	with(document){
		getElementById('step').value='_passengers_detailes';
		getElementById('query').value='FlightPriceTemplateRequest';
		getElementById('passengers_detailes').submit();
	}
}
function submitPromotionByCacheID(id,sCacheID,sMode){
	var viewIn = ""
	if(document.getElementById('view_in_'+id) && document.getElementById('view_in_'+id).value!="DEAL") viewIn = document.getElementById('view_in_'+id).value;
		
	var seatsNum=document.getElementById('seatsNum_'+id)
	if(seatsNum && seatsNum.innerText=='0') return
	var oForm=document.getElementById('detailsForm_'+id)
	switch(sMode){
		case "FLIGHTS":
			isnull(viewIn)?tempAction=flights_action:tempAction=(pagePath+"?pi="+viewIn);
			oForm.action=tempAction;
			document.getElementById('query_'+id).value="FlightDealDetailsRequest"
			break;
		case "ISRAEL":
			isnull(viewIn)?tempAction=israel_action:tempAction=(pagePath+"?pi="+viewIn);
			oForm.action=tempAction;
			document.getElementById('query_'+id).value="PackageDealDetailsRequest"
			break
		default:
			isnull(viewIn)?tempAction=packages_action:tempAction=(pagePath+"?pi="+viewIn);
			oForm.action=tempAction;
			document.getElementById('query_'+id).value="PackageDealDetailsRequest"
	}
	
	document.getElementById('step_'+id).value="_passengers_number"
	oForm.submit()
}
function submitPromotion(id,ShowOutCalendar){
	var viewIn = ""
	if(document.getElementById('view_in_'+id) && document.getElementById('view_in_'+id).value!="DEAL") viewIn = document.getElementById('view_in_'+id).value;
	
	if(isnull(ShowOutCalendar)) ShowOutCalendar='0'
	ShowOutCalendar=String(ShowOutCalendar)
	if(ShowOutCalendar=='1'){
		document.getElementById('step_'+id).value='_search_results'
		try{
			var fareVal=document.getElementById('Fare_'+id).value
			document.getElementById('MinFare_'+id).value=fareVal
			document.getElementById('MaxFare_'+id).value=fareVal
		}catch(e){}
		switch(document.getElementById('mode_'+id).value){
			case "FLIGHTS":
				document.getElementById('query_'+id).value="FlightDealsRequestEx";
				isnull(viewIn)?tempAction=flights_action:tempAction=(pagePath+"?pi="+viewIn);
				document.getElementById('detailsForm_'+id).action = tempAction;
				break;
			case "ISRAEL":
				document.getElementById('query_'+id).value="PackageDealsRequestEx";
				isnull(viewIn)?tempAction=israel_action:tempAction=(pagePath+"?pi="+viewIn);
				document.getElementById('detailsForm_'+id).action = tempAction;
				break;
			default:
				document.getElementById('query_'+id).value="PackageDealsRequestEx";
				isnull(viewIn)?tempAction=packages_action:tempAction=(pagePath+"?pi="+viewIn);
				document.getElementById('detailsForm_'+id).action = tempAction;
		}
		document.getElementById('detailsForm_'+id).submit()
		return
	}
	// submit by cacheID
	var oCacheID=document.getElementById('CacheID_'+id)
	var oModeField=document.getElementById('mode_'+id)
	if(oCacheID && !isnull(oCacheID.value) && oCacheID.value != "0"){
		submitPromotionByCacheID(id,oCacheID.value,oModeField.value)
		return
	}
	var seatsNum=document.getElementById('seatsNum_'+id)
	if(seatsNum && seatsNum.innerText=='0') return
	var oForm=document.getElementById('detailsForm_'+id)
	var oStepField=document.getElementById('step_'+id)
	var oInFlightID=document.getElementById('InFlightID_'+id)	
	if(oModeField.value=="FLIGHTS"){
		if(!isnull(oInFlightID.value)){
			isnull(viewIn)?tempAction=flights_action:tempAction=(pagePath+"?pi="+viewIn);
			oForm.action=tempAction;
			oStepField.value="_passengers_number"
			document.getElementById('query_'+id).value="FlightDealDetailsRequest"
		} else {
			document.getElementById('query_'+id).value="FlightReturnDatesRequestEx"
			openCalendar({'mode':'RETURN'},id)
			return
		}
	}
	else{	
		if(oModeField.value=="ISRAEL"){
			if(!isnull(oInFlightID.value)){
				isnull(viewIn)?tempAction=israel_action:tempAction=(pagePath+"?pi="+viewIn);
				oForm.action=tempAction;
				oStepField.value="_passengers_number"
				document.getElementById('query_'+id).value="PackageDealDetailsRequest"
			}
			else{
				document.getElementById('query_'+id).value="PackageReturnDatesRequestEx"
				openCalendar({'mode':'RETURN'},id)
				return
			}
		}
		else{
			if(!isnull(oInFlightID.value)){
				isnull(viewIn)?tempAction=packages_action:tempAction=(pagePath+"?pi="+viewIn);
				oForm.action=tempAction;
				oStepField.value="_passengers_number"
				document.getElementById('query_'+id).value="PackageDealDetailsRequest"
			}
			else{
				document.getElementById('query_'+id).value="PackageReturnDatesRequestEx"
				openCalendar({'mode':'RETURN'},id)
				return
			}
		}
	}
	try{
		_activeTimer=false
	}catch(e){}
	oForm.submit()
	oForm.target="_parent"
}
function submitPromotionWithoutCheck(id){
	var viewIn = ""
	if(document.getElementById('view_in_'+id) && document.getElementById('view_in_'+id).value!="DEAL") viewIn = document.getElementById('view_in_'+id).value;
	
	var oForm=document.getElementById('detailsForm_'+id)
	var oStepField=document.getElementById('step_'+id)
	var oModeField=document.getElementById('mode_'+id)
	oStepField.value="_passengers_number"
	if(oModeField.value=="FLIGHTS"){
		document.getElementById('query_'+id).value="FlightDealDetailsRequest"
		isnull(viewIn)?tempAction=flights_action:tempAction=(pagePath+"?pi="+viewIn);
		oForm.action=tempAction;
	}
	if(oModeField.value=="PACKAGES"){
		document.getElementById('query_'+id).value="PackageDealDetailsRequest"
		isnull(viewIn)?tempAction=packages_action:tempAction=(pagePath+"?pi="+viewIn);
		oForm.action=tempAction;
	}
	if(oModeField.value=="ISRAEL"){
		document.getElementById('query_'+id).value="PackageDealDetailsRequest"
		isnull(viewIn)?tempAction=israel_action:tempAction=(pagePath+"?pi="+viewIn);
		oForm.action=tempAction;
	}
	
	try{
		_activeTimer=false
	}catch(e){}
	oForm.submit()
        oForm.target="_parent"
}
function runSeatsNumberTimer(id,currNum){
	if(isnull(currNum)) currNum=SEATS_NUM_START+1
	var arr=eval('timersArr'+id)
	if(currNum==0) currNum=SEATS_NUM_START+1
	currNum--
	for(var i=0;i<arr.length;i++){
		if(currNum==0){
			document.all['timerSeatsNum_'+arr[i]].style.visibility='hidden'
			document.all['timerSeatsLabel_'+arr[i]].style.visibility='hidden'
		}
		else{
			document.all['timerSeatsNum_'+arr[i]].style.visibility='visible'
			document.all['timerSeatsLabel_'+arr[i]].style.visibility='visible'
		}
		
		document.all['timerNum_'+arr[i]].innerText=currNum
	}
	var score=SEATS_NUM_SCORE
	if(currNum==0) score=SEATS_NUM_SCORE*3
	if(_activeTimer) onlX=setTimeout('runSeatsNumberTimer("'+id+'",'+currNum+')',score)
}
function updateSeatsNum(id,newArr){
	var arr=eval('onlObj_'+id)
	for(var i=0;i<arr.length;i++){
		for(var j=0;j<newArr.length;j++){
			if(arr[i].obj.param1==newArr[j].param1 && arr[i].obj.param2==newArr[j].param2 && arr[i].obj.param3==newArr[j].param3 && arr[i].obj.param4==newArr[j].param4){
				arr[i].obj.innerHTML=Math.min(Number(newArr[j].AvailableSeats),10)
				document.all['seatsLabel_'+String(arr[i].obj.id).replace("seatsNum_","")].style.visibility='visible'
				break
			}
		}
	}
	seatsNumTimer(11,id)
}
function submitFlightOrPackageMainSearch(id,bPackage){
	var _yes=false
	var pr=(bPackage?'p':'f')

	if(document.all['citiesSelect_'+pr+'se'+id].value=="")
	{
		alert(dic.NOT_DESTINATION)
		try{
		document.all['countriesSelect_'+pr+'se'+id].focus()
		}
		catch(e){}
		return
	}
	if(!isnull(document.all['departureDate_'+pr+'se'+id].value)){
		document.all['OutboundDate_Start_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['OutboundDate_End_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['BestPrice_'+pr+'se'+id].value='0'
		_yes=true
	}
	if(!isnull(document.all['arrivalDate_'+pr+'se'+id].value)){
		document.all['InboundDate_Start_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
		document.all['InboundDate_End_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
	}
	try{ _activeTimer=false; }catch(e){}
	if(!_yes) document.all['OutboundDate_End_'+pr+'se'+id].value=EndRangeDateByDestRange	
	document.all['query_'+pr+'se'+id].value=(bPackage?'PackageDealsRequestEx':'FlightDealsRequestEx')
	var fObj=document.all['form_'+pr+'se'+id]
	fObj.target="_parent"
	fObj.action=(!isnull(fObj.realaction)?fObj.realaction:(bPackage?packages_action:flights_action))
	//fObj.method="GET"
	fObj.submit()
}
function submitFlightMainSearch(id){
	submitFlightOrPackageMainSearch(id,false)
}
function submitPackageMainSearch(id){
	submitFlightOrPackageMainSearch(id,true)
}
function submitIsraelMainSearch(id){
	var _yes=false
	var pr='p'
	if(document.all['citiesSelect_'+pr+'se'+id].value==""){
		alert(dic.NOT_DESTINATION)
		document.all['countriesSelect_'+pr+'se'+id].focus()
		return
	}
	if(!isnull(document.all['departureDate_'+pr+'se'+id].value)){
		document.all['OutboundDate_Start_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['OutboundDate_End_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['BestPrice_'+pr+'se'+id].value='0'
		_yes=true
	}
	if(!isnull(document.all['arrivalDate_'+pr+'se'+id].value)){
		document.all['InboundDate_Start_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
		document.all['InboundDate_End_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
	}
	try{ _activeTimer=false; }catch(e){}
	if(!_yes) document.all['OutboundDate_End_'+pr+'se'+id].value=EndRangeDateByDestRange	
	document.all['query_'+pr+'se'+id].value='PackageDealsRequestEx'
	var fObj=document.all['form_'+pr+'se'+id]
	fObj.target="_parent"
	fObj.action=(!isnull(fObj.realaction)?fObj.realaction:israel_action)
	fObj.submit()
}
function submitSkiMainSearch(id){
	var _yes=false
	var pr='p'
	if(document.all['citiesSelect_'+pr+'se'+id].value==""){
		alert(dic.NOT_DESTINATION)
		document.all['countriesSelect_'+pr+'se'+id].focus()
		return
	}
	if(!isnull(document.all['departureDate_'+pr+'se'+id].value)){
		document.all['OutboundDate_Start_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['OutboundDate_End_'+pr+'se'+id].value=document.all['departureDate_'+pr+'se'+id].value
		document.all['BestPrice_'+pr+'se'+id].value='0'
		_yes=true
	}
	if(!isnull(document.all['arrivalDate_'+pr+'se'+id].value)){
		document.all['InboundDate_Start_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
		document.all['InboundDate_End_'+pr+'se'+id].value=document.all['arrivalDate_'+pr+'se'+id].value
	}
	try{ _activeTimer=false; }catch(e){}
	if(!_yes) document.all['OutboundDate_End_'+pr+'se'+id].value=EndRangeDateBySkiDestRange	
	document.all['query_'+pr+'se'+id].value='PackageDealsRequestEx'
	var fObj=document.all['form_'+pr+'se'+id]
	fObj.target="_parent"
	fObj.action=(!isnull(fObj.realaction)?fObj.realaction:packages_action)
	fObj.submit()
}
function setArrivalAndDepartureLabels(id){
	var opt=document.all['citiesSelect_fse'+id].options
	for(var i=0;i<opt.length;i++){
		if(opt[i].selected){
			document.all['ArrivalCityDesc_fse'+id].value=opt[i].text
			break
		}
	}
	var opt=document.all['departureCitySelect_fse'+id].options
	for(var i=0;i<opt.length;i++){
		if(opt[i].selected){
			document.all['DepartureCityDesc_fse'+id].value=opt[i].text
			break
		}
	}
}
function setArrivalAndDepartureLabels_Package(id){
	var opt=document.all['citiesSelect_pse'+id].options
	for(var i=0;i<opt.length;i++){
		if(opt[i].selected){
			document.all['ArrivalCityDesc_pse'+id].value=opt[i].text
			break
		}
	}
}
function getDepartureDateFlightPackageMainSearch(id,bPackage)
{
	var pr=(bPackage?'p':'f')
	if(document.all['citiesSelect_'+pr+'se'+id].value==""){
		alert(dic.NOT_DESTINATION)
		try{
		document.all['countriesSelect_'+pr+'se'+id].focus()
		}
		catch(e){}
		return
	}
	if(bPackage)
		setArrivalAndDepartureLabels_Package(id)
	else
		setArrivalAndDepartureLabels(id)
	document.all['departureDate_'+pr+'se'+id].value=""
	document.all['arrivalDate_'+pr+'se'+id].value=""
	var CALENDAR_H=300;
	var top=window.screen.availHeight/2-CALENDAR_H/2
	var left=window.screen.availWidth/2-CALENDAR_W/2
	var calendarWinFeatures = "height="+CALENDAR_H+"px,width="+CALENDAR_W+"px,top="+top+",left="+left+",center=no,status=no,scrollbars=yes,resizable=no"
	var calendarWin=window.open('about:blank','calendarWin',calendarWinFeatures)
	calendarWin.document.write(LOADING_STR)
	calendarWin.document.body.style.cursor='wait'
	document.all['query_'+pr+'se'+id].value=(bPackage?'PackageDepartureDatesByDestRequest':'FlightDepartureDatesByDestRequest')
	var formObj=document.all['form_'+pr+'se'+id]
	formObj.action=windows_path+"FLIGHTS_SEARCH_CALENDAR/flights_search_calendar.asp?pi="+node_pi+"&sitePath="+_site_path+"&id="+id+"&mode=exit&dealType="+(bPackage?"PACKAGE":"FLIGHT")
	//formObj.action=windows_path+"FLIGHTS_SEARCH_CALENDAR/flights_search_calendar.asp?pi="+node_pi+"&id="+id+"&mode=exit&dealType="+(bPackage?"PACKAGE":"FLIGHT")
	formObj.target="calendarWin"
	formObj.submit()
	calendarWin.focus()
}
function getDepartureDateFlightMainSearch(id){
	getDepartureDateFlightPackageMainSearch(id,false)
}
function getDepartureDatePackageMainSearch(id){
	getDepartureDateFlightPackageMainSearch(id,true)

}
function getArrivalDateFlightPackageMainSearch(id,bPackage)
{	

	var pr=(bPackage?'p':'f')
	if(document.all['citiesSelect_'+pr+'se'+id].value==""){
		alert(dic.NOT_DESTINATION)
		try{
		document.all['countriesSelect_'+pr+'se'+id].focus()
		}
		catch(e){}
		return
	}
	if(document.all['departureDate_'+pr+'se'+id].value==""){
		alert(dic.CHOOSE_EXIT_DATE)
		return
	}
	if(bPackage)
		setArrivalAndDepartureLabels_Package(id)
	else
		setArrivalAndDepartureLabels(id)
	document.all['arrivalDate_'+pr+'se'+id].value=""
	var CALENDAR_H=300;
	var top=window.screen.availHeight/2-CALENDAR_H/2
	var left=window.screen.availWidth/2-CALENDAR_W/2	
	var calendarWinFeatures = "height="+CALENDAR_H+"px,width="+CALENDAR_W+"px,top="+top+",left="+left+",center=no,status=no,scrollbars=yes,resizable=no"	
	var calendarWin=window.open('about:blank','calendarWin',calendarWinFeatures)
	calendarWin.document.write(LOADING_STR)
	calendarWin.document.body.style.cursor='wait'
	document.all['query_'+pr+'se'+id].value=(bPackage?'PackageReturnDatesByDestRequest':'FlightReturnDatesByDestRequest')
	var formObj=document.all['form_'+pr+'se'+id]
	formObj.action=windows_path+"FLIGHTS_SEARCH_CALENDAR/flights_search_calendar.asp?pi="+node_pi+"&sitePath="+_site_path+"&id="+id+"&mode=return&dealType="+(bPackage?"PACKAGE":"FLIGHT")
	formObj.target="calendarWin"
	formObj.submit()
	calendarWin.focus()
}
function getArrivalDateFlightMainSearch(id){
	getArrivalDateFlightPackageMainSearch(id,false)
}
function getArrivalDatePackageMainSearch(id){
	getArrivalDateFlightPackageMainSearch(id,true)

}
function updateNightsNumber(id){
	var obj=document.all['nightsNumber_pse'+id]
	if(!obj) return
	var str=obj.innerHTML;
	var date1=document.all['departureDate_pse'+id].value
	var date2=document.all['arrivalDate_pse'+id].value
	obj.innerHTML=str.replace(/\d/g,'');
	if(isnull(date2) || isnull(date1)){
		
		obj.style.visibility='hidden'
		return
	}	
	date1=new Date(date1.replace(/-/g,'/'))
	date2=new Date(date2.replace(/-/g,'/'))
	obj.innerHTML+=String(Math.round((date2-date1)/(1000*60*60*24)))
	obj.style.visibility='visible'
}

function isIn(list,arg,delim){
	if (isnull(list) || isnull(arg)) return false;
	delim = (isnull(delim)?",":delim)
	return ((delim + list + delim).search(delim + arg + delim) >= 0);
}
function isnull(arg) {
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}
String.prototype.toFirstLetterCase=function(){
	return (this.substring(0,1).toUpperCase()+this.substring(1,this.length).toLowerCase())
}
function clearRadios(id){ return; }
function clear_fse(id){
	try{
		document.all['departureDate_fse'+id].value="";
		document.all['arrivalDate_fse'+id].value="";
		
		// reassign the initial values of the departure dates
		// START 
		var const_out_start = document.all['Const_OutboundDate_Start_fse'+id].value;
		document.all['OutboundDate_Start_fse'+id].value = const_out_start;
		// END
		var const_out_end = document.all['Const_OutboundDate_End_fse'+id].value;
		document.all['OutboundDate_End_fse'+id].value = const_out_end;	

	}catch(e){}
}
function clear_pse(id){
	try{
		document.all['departureDate_pse'+id].value="";
		document.all['arrivalDate_pse'+id].value="";
		
		// reassign the initial values of the departure dates
		// START 
		var const_out_start = document.all['Const_OutboundDate_Start_pse'+id].value;
		document.all['OutboundDate_Start_pse'+id].value = const_out_start;
		// END
		var const_out_end = document.all['Const_OutboundDate_End_pse'+id].value;
		document.all['OutboundDate_End_pse'+id].value = const_out_end;	

		updateNightsNumber(id);	
	}catch(e){}
}


// newsletter_action:	1 = subscribe
//						0 = unsubscribe
function newsletter_subscribe(action) {
	var email = document.getElementById('newsletter_email').value;
	var oXML=new ActiveXObject("Msxml2.DOMDocument");
	oXML.async=false;
	var obj = {};
	obj.exist = oXML.load("/SITE/UTILS/XX/newsletterSubsribtion.hx.asp?newsletter_action="+action+"&newsletter_email="+email);
	if(!obj.exist) alert(oXML.parseError.reason);
	alert(oXML.xml);
}


function printDeal(){
	var printDIV = document.getElementById("print_deal");
	if (printDIV != null) {
			var content = printDIV.innerHTML;
	} else {
		//alert("Could not find the printDIV section in the HTML");
		return;
	}	
	var printWin = window.open("/SITE/MODULES/PURCHASE/print_win.asp?pi="+node_pi,"printWin");
	//printWin.document.open();
	//alert(printWin.document.all('print_container'));	
	//printWin.document.write(content);
	//printWin.document.close();
	//printWin.print();
}

function validInput(obj){
	var str = obj.value.toUpperCase() 
	var strOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ _-.@0123456789$!#^%&*()-=+:,;\"'}{|/?"
	for(var i=0 ; i < str.length ; i++){
		if(strOK.indexOf(str.substring(i,i+1)) == -1){
			alert(dic.ENGLISH_CHAR_ONLY)
			obj.focus()
			return false;
		}
	}
}

function getHeaderBanners(affiliatecode){
	//alert("getHeaderBanners");
	var sBannersDiv = "";
	
	var bannersXML=new ActiveXObject("Microsoft.XMLDOM");
	bannersXML.async=false;
	oDate = new Date();

	try{
		if( bannersXML.load("/SITE/INCLUDES/getHeaderBanners.hx.asp?affiliatecode="+affiliatecode+"&pi="+home_pi+"&rn="+oDate.getMilliseconds()) )
		{
			//var header_part_div=bannersXML.documentElement.selectNodes("//header_part_div");
			var elements = bannersXML.documentElement;
			if(!isnull(elements)){
				var header_part_div = elements.selectSingleNode("//ROWSET/header_part_div");
				if(!isnull(header_part_div.text)){
				// && header_part_div.length>0){
					document.all['header_part'].innerHTML = header_part_div.text;
				}
			}
		}
		else{
			header_part  = "bannersXML error";//"<ERROR_GETHEADERBANNERS desc='"+String(bannersXML.parseError.reason).replace(/\'/gim,'`')+"'/>";
		}	
	}
	catch(e){
		//alert(e.description);
		return "javascript:void(0)";
		//header_part = "<ERROR_GETHEADERBANNERS desc='"+String(e.description).replace(/\'/gim,'`')+"'/>";
	}
}















/**************************************/
var _cityLoadSport=new Array()
function fillCitiesList_SPORT(obj,id){ fillCitiesListSport(obj,id,'p',true);}
function fillCitiesListSport(obj,id,type,bFlyAndDrive){
	
	
	if(!_cityLoadSport[id])
	{
		if (tmp_lang=="EN")
		{
			_cityLoadSport[id]=cityXML.load("/DATA/activeDestinationsByCountry.EN.xml");
		}
		else
		{
			_cityLoadSport[id]=cityXML.load("/DATA/activeDestinationsByCountry.xml");
		}
		if(_cityLoadSport[id]) fillCountriesListSport(obj,id,type,bFlyAndDrive)
	}
	if(obj.value=='') return
	var select=document.getElementById('citiesSelect_pse'+id)
	var cityes=cityXML.documentElement.selectNodes("//Country[@EN='"+obj.value+"']/City[@p='1']");
	select.length=cityes.length+1
	select[0].selected=true
	var c = 1;
	for(var i=1;i<cityes.length+1;i++){
		var e = cityes.nextNode();
		if(e.getAttribute("PackageType").indexOf("|SPORT|")>-1){
			select[c].text=e.getAttribute(tmp_lang)
			select[c].value=e.getAttribute("Code")
			c++;
		}
	}
	select.length=c
}
function fillCountriesListSport(obj,id,type,bFlyAndDrive){
	
	var select=obj
	var countries=cityXML.documentElement.selectNodes("//Country[@EN!='ISRAEL' and City/@p='1']")
	
	obj.length=countries.length+1
	obj[0].selected=true
	var c = 1;
	for(var i=1;i<countries.length+1;i++){
		var _isSport = false;
		var e = countries.nextNode();
		var ct = e.selectNodes("City[@p='1']")
		for(var j=1;j<ct.length+1;j++){
			var ee = ct.nextNode();
			if(ee.getAttribute("PackageType").indexOf("|SPORT|")>-1){
				_isSport = true;
				break;
			}
		}
		if(_isSport){
			obj[c].text=e.getAttribute(tmp_lang)
			obj[c].value=e.getAttribute("EN")
			c++;
		}
	}
	obj.length=c	
}
function ShowUrlTrip(url)
{
	var CALENDAR_H=500;
	var CALENDAR_W=750;
	var top=window.screen.availHeight/2-CALENDAR_H/2
	var left=window.screen.availWidth/2-CALENDAR_W/2	
	var calendarWinFeatures = "height="+CALENDAR_H+"px,width="+CALENDAR_W+"px,top="+top+",left="+left+",center=no,status=yes,scrollbars=no,resizable=yes"	
	var UrlTrip=window.open('/site/UrlTrip.asp?sUrl='+escape(url),'UrlTrip',calendarWinFeatures)
	
}



/////////////////////////////////////////////////////////////////////////////////////////

function checkIfAffiliate(affiliatecode,doaffildiscount){
//alert("affiliatecode = " + affiliatecode + ", doaffildiscount = " + doaffildiscount)
	
	var bannersXML=new ActiveXObject("Microsoft.XMLDOM");
	bannersXML.async=false;
	oDate = new Date();

	try{
		if( bannersXML.load("/SITE/INCLUDES/getHeaderBanners.hx.asp?affiliatecode="+affiliatecode+"&doaffildiscount="+doaffildiscount+"&pi="+home_pi+"&rn="+oDate.getMilliseconds()) )
		{
			var elements = bannersXML.documentElement;
			if(!isnull(elements)){
				var doaffildiscount_serv = elements.selectSingleNode("//ROWSET/doaffildiscount").text;
				var affiliatecode_serv = elements.selectSingleNode("//ROWSET/affiliatecode").text;
//alert("affiliatecode_serv = " + affiliatecode_serv + ", doaffildiscount_serv = " + doaffildiscount_serv)

				if(!isnull(affiliatecode_serv) && isnull(affiliatecode)){
					var s = window.location.href
					if(s.indexOf("?") > -1) s = s + "&affiliatecode=" + affiliatecode_serv
					else  s = s + "?affiliatecode=" + affiliatecode_serv
					if(!isnull(doaffildiscount_serv))  s + "&doaffildiscount=" + doaffildiscount_serv
					else   s + "&doaffildiscount=0"

					window.location.href = s

				}
				
			}
		}
	
	}
	catch(e){

	}
}

function getHeaderBanners(affiliatecode,doaffildiscount){


//alert("affiliatecode = " + affiliatecode + ", doaffildiscount = " + doaffildiscount)


	var sBannersDiv = "";
	
	var bannersXML=new ActiveXObject("Microsoft.XMLDOM");
	bannersXML.async=false;
	oDate = new Date();

	try{
		if( bannersXML.load("/SITE/INCLUDES/getHeaderBanners.hx.asp?affiliatecode="+affiliatecode+"&doaffildiscount="+doaffildiscount+"&pi="+home_pi+"&rn="+oDate.getMilliseconds()) )
		{
			var elements = bannersXML.documentElement;
			if(!isnull(elements)){
/*
				var doaffildiscount_serv = elements.selectSingleNode("//ROWSET/doaffildiscount").text;
				var affiliatecode_serv = elements.selectSingleNode("//ROWSET/affiliatecode").text;


//alert("affiliatecode_serv = " + affiliatecode_serv + ", doaffildiscount_serv = " + doaffildiscount_serv)


if(!isnull(affiliatecode_serv) && isnull(affiliatecode)){
	var s = window.location.href
	if(s.indexOf("?") > -1) s = s + "&affiliatecode=" + affiliatecode_serv
	else  s = s + "?affiliatecode=" + affiliatecode_serv
	if(!isnull(doaffildiscount_serv))  s + "&doaffildiscount=" + doaffildiscount_serv
	else   s + "&doaffildiscount=0"

	window.location.href = s

	return
}
*/
				var header_part_div = elements.selectSingleNode("//ROWSET/header_part_div");
				if(!isnull(header_part_div.text)){
					document.all['header_part'].innerHTML = header_part_div.text;
				}
			}
		}
		else{
			header_part  = "bannersXML error";
		}	
	}
	catch(e){
		return "javascript:void(0)";
	}
}