function isnull(arg) {
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}



////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//
//									EXTENDED SEARCH ENGINE
//
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////


/*
------------------------------------------------------------------------
GLOBALS 
-------------------------------------------------------------------------
*/
var DestinationsXML = null;
var CitiesXML=null;
var optionsArray = null;

try
{
	// XML object - countries
	DestinationsXML	= new ActiveXObject("Microsoft.XMLDOM");
	DestinationsXML.async	= false;

	// XML object - All cities 
	CitiesXML=new ActiveXObject("Microsoft.XMLDOM");
	CitiesXML.async=false;

	// select list options by flight type
	optionsArray = new Array();
		optionsArray["ALL"]		= '';
		optionsArray["REGULAR"]	= '';
		optionsArray["CHARTER"]	= '';
}
catch(e)
{
}

var global_activeRows=2;

var tmp_lang = "HE";
try
{
	if (!isnull(lang)) 
	{
		tmp_lang = lang;
		if (lang=="RU" || lang=="PL")  tmp_lang = "EN";
	}
}
catch(e)
{
	tmp_lang = "HE";
}
var _site_path = path;


/*
---------------------------------------------------------------------------
POP-UPS
---------------------------------------------------------------------------
*/
function showDetailsPopup(field_name,folder_id) 
{
	var POPUP_H=300;
	var POPUP_W=500;
	var top=window.screen.availHeight/2-POPUP_H/2
	var left=window.screen.availWidth/2-POPUP_W/2
	var features = "dialogHeight:"+POPUP_H+"px;dialogWidth:"+POPUP_W+"px"
	showModalDialog("/site/windows/REGULAR/popup.asp?pi="+node_pi+"&sitePath="+_site_path+"&lang="+lang+"&folder="+folder_id+"&field="+field_name,self,features)
	
}

function OpenAirlinesPopUp(id) 
{	
	var features = "dialogHeight:300px;dialogWidth:500px;scroll:no"
	var result = showModalDialog("/site/windows/REGULAR/AirlinesPopup.asp?stcss="+css+"&lang="+lang+"&sitePath="+_site_path+"&id="+id,self,features)
	if(result){	
		var selectListObj = document.all[id];
		if (selectListObj)
		{
			var index = findItemInSelectList(selectListObj, result.code);
			if (index>0)
			{
				selectListObj.selectedIndex = index;
			} else {
				var len = selectListObj.length
				selectListObj.length = selectListObj.length+1;
				selectListObj[len].text			= result.name;
				selectListObj[len].value		= result.code;
				selectListObj[len].selected	= true;	
			}
		}
	}
}



// flightType: ALL, CHARTER, REGULAR
// tripType: MULTITRIP, ROUNDTRIP, ONEWAY
// modify display of Flight Type radio buttons
// and Trip Type radio buttons
function setFlightTypeRules(flightType, ID, lang) 
{
	try {
		var formObj = document.all["RegExtendedSearchForm"+ID];
	} catch(e) { return; }
	
	if (flightType=="CHARTER")
	{
		// disable trip type radio buttons 
		document.all["RegDirectionTypeMultiTrip"+ID].disabled		= true;
		document.all["RegDirectionTypeRoundTrip"+ID].disabled		= false;
		document.all["RegDirectionTypeOneWay"+ID].disabled			= true;		
		// hide airlines select lists and link
		formObj["Airline"].selectedIndex				= 0;		
		formObj["Airline"].disabled						= true;
		formObj["Class"].selectedIndex					= 0;		
		formObj["Class"].disabled						= true;
		document.all["AdditionalAirlines"+ID].style.display		= "none";
		document.all["AdditionalAirlinesAlter"+ID].style.display = "inline";
	} else {
		// enable trip type radio buttons 
		document.all["RegDirectionTypeMultiTrip"+ID].disabled		= false;
		document.all["RegDirectionTypeRoundTrip"+ID].disabled		= false;
		document.all["RegDirectionTypeOneWay"+ID].disabled			= false;	
		// show airlines select lists and link
		formObj["Airline"].disabled					= false;
		formObj["Airline"].selectedIndex			= 0;		
		formObj["Class"].disabled					= false;
		formObj["Class"].selectedIndex				= 0;		
		document.all["AdditionalAirlines"+ID].style.display		= "inline";
		document.all["AdditionalAirlinesAlter"+ID].style.display= "none";
	}

	// reset non-stop flights check box
	formObj["NonStopFlights"].checked = false;
	// DEFAULT SETTINGS:
	// set Round Trip radio button checked
	document.all["RegDirectionTypeRoundTrip"+ID].checked = true;
	// set destination fields for Round Trip
	setDestinationFields("ROUNDTRIP", flightType, ID, lang);
}

// FOR EXTENDED SEARCH ENGINE
// hide/display the destination rows.
// each destination has two TRs: one for the select lists and the calendar
// and another one above it for the text labels and the "additional destinations" links.
// Handled document objects :
//	1.	destinations select lists :	DestinationFrom, DestinationTo  
//	2.	destinations texts & links:	RowLinks, RowLinksAlter 
//	3.	calendar image & Input field: openCalButt, RegDate	
	


function setDestinationFields(tripType, flightType, ID, lang) 
{
	//alert(flightType+"-"+tripType)
	var activeRows=1;
	switch (tripType) {
		case 'ONEWAY':
			activeRows = 1;
			break;
		case 'ROUNDTRIP':	
			activeRows = 2;
			break;
		case 'MULTITRIP':
			activeRows = 5;			
			break;
	}
	if (global_activeRows<activeRows) global_activeRows = activeRows;
	
	for (var i=1;i<=global_activeRows;i++)
	{
		try 
		{
			if (i<=activeRows)
			{
				// ADDITIONAL DESTINATIONS
				// disable additional destinations in Charter or in Round Trip (disable second row) 
				if (flightType=="CHARTER")					    
				{	
					document.all["LinksRowFrom"+i+ID].style.display			= "none";
					document.all["LinksRowTo"+i+ID].style.display			= "none";
					document.all["LinksRowAlterFrom"+i+ID].style.display	= "inline";
					document.all["LinksRowAlterTo"+i+ID].style.display		= "inline";
				} else {
					document.all["LinksRowFrom"+i+ID].style.display			= "inline";
					document.all["LinksRowTo"+i+ID].style.display			= "inline";
					document.all["LinksRowAlterFrom"+i+ID].style.display	= "none";
					document.all["LinksRowAlterTo"+i+ID].style.display		= "none";
				}
	
				// DESTINATION & CALENDAR
				document.all["DestinationRow"+i+ID].style.display		= "inline";
			} else {
				// additional destinations
				document.all["LinksRowFrom"+i+ID].style.display			= "none";
				document.all["LinksRowTo"+i+ID].style.display			= "none";
				document.all["LinksRowAlterFrom"+i+ID].style.display	= "none";
				document.all["LinksRowAlterTo"+i+ID].style.display		= "none";
				// Destination & Calendar
				document.all["DestinationRow"+i+ID].style.display		= "none";
			}
		} catch(e){}
	}
	global_activeRows = activeRows;
	if (tripType=="ONEWAY")
	{
		document.all["FillSecondRow2"+ID].style.display	= "inline";
	} else {
		document.all["FillSecondRow2"+ID].style.display	= "none";
	}
	// fill destinations select lists
	getExtendedSearchEngineDestinations(flightType, ID, lang);
}

/*
------------------------------------------------------------------------
Request Destinations: Cities
-------------------------------------------------------------------------
*/
// fill the cities list according to a selected country
function getExtendedSearchEngineDestinations(flightType, ID, lang)
{
//alert(flightType);
	try {
		var formObj = document.all["RegExtendedSearchForm"+ID];
	} catch(e) { return; }

	if (isnull(lang)) lang = "HE";
	if (isnull(flightType)) flightType = formObj["RegFlightType"].value;

	// load once the destinations XML
	if(isnull(optionsArray[flightType]))
	{
		var obj = {};
		obj.exist = false;
		switch (flightType)
		{
			case "ALL":
				obj.exist = DestinationsXML.load("/shared/CharterAndRegularCities."+lang+".xml");
			break;
			case "REGULAR":
				obj.exist = DestinationsXML.load("/shared/CharterAndRegularCities."+lang+".xml");
				//obj.exist = DestinationsXML.load("/shared/RegularCities.100."+lang+".xml");
			break;
			case "CHARTER":
				obj.exist = DestinationsXML.load("/shared/CharterCities.100."+lang+".xml");
			break;
		}	
		if(obj.exist)
		{
			CitiesXML.loadXML(DestinationsXML.xml);
			var citiesNodes = CitiesXML.documentElement.selectNodes("//cities/city");
			createSelectListOptions(flightType, citiesNodes);			
		}
	} 
	fillSelectLists(flightType, ID, lang);
}

// create select list options array for each flight type
function createSelectListOptions(flightType, citiesNodes)
{
	var langOps="EN";
	lang=="HE"?langOps="EN":langOps="HE";

	var counter = 0;
	var tempLength = citiesNodes.length+1;
	optionsArray[flightType] = new Array();
	
	for(var j=1;j<tempLength;j++)
	{
		var city = citiesNodes.nextNode();	

		// get city text
		try {
			var cityText = city.getAttribute(lang);
			if(isnull(cityText)) throw new Error()
		} catch(e) {
			try {
				var cityText = city.getAttribute(langOps);
				if(isnull(cityText)) throw new Error()
			} catch(e) {
				var cityText = false;
			}
		}

		// get city code
		try {
			var cityCode = city.getAttribute("code");
		} catch(e) {
			var cityCode = false;
		}

		// get country text
		try {
			var countryText = city.getAttribute("country_"+lang);
			if(isnull(countryText)) throw new Error()
		} catch(e) {
			try {
				var countryText = city.getAttribute("country_"+langOps);
				if(isnull(countryText)) throw new Error()
			} catch(e) {
				var countryText = false;
			}
		}
		
		if (cityText && cityCode && countryText)
		{	
			var tempObj={};
			tempObj.text	= cityText;
			tempObj.code	= cityCode;
			tempObj.countryText	= countryText;
			optionsArray[flightType][counter] = tempObj;
			counter++;
		}
	}
}


//	1. replace destinations select lists when flight type changes
//	2. fill empty select lists according to flight type 
function fillSelectLists(flightType, ID, lang)
{	
	try {
		var formObj = document.all["RegExtendedSearchForm"+ID];
	} catch(e) { return; }

	// go over active destinations rows 
	for (var i=1;i<=global_activeRows;i++)
	{	
		// reset date field
		formObj["RegDate"+i].value='';
		
		var selectListObjFrom	= formObj["DestinationFrom"+i];
		var selectListObjTo		= formObj["DestinationTo"+i];
		if (selectListObjFrom && selectListObjTo)
		{	
			// reset select lists 
			selectListObjFrom.selectedIndex = 0;
			selectListObjFrom[0].text	= "---";
			selectListObjFrom[0].value	= "";
			selectListObjFrom[0].selected = true;
			
			selectListObjTo.selectedIndex = 0;
			selectListObjTo[0].text	= "---";
			selectListObjTo[0].value	= "";
			selectListObjTo[0].selected = true;
			
			if (selectListObjFrom.currentList != flightType && 
				selectListObjTo.currentList	  != flightType)
			{	
				selectListObjFrom.currentList	= flightType;
				selectListObjTo.currentList		= flightType;
				
				// go over destinations list and fill required select lists
				var len = optionsArray[flightType].length;
				selectListObjFrom.length = len+1;	
				selectListObjTo.length = len+1; 
				for (var j=0;j<len;j++)
				{	
					var text = optionsArray[flightType][j].text;
					var code = optionsArray[flightType][j].code;
					var countryText = optionsArray[flightType][j].countryText;
					
					selectListObjFrom[(j+1)].text	= text+", "+countryText;
					selectListObjFrom[(j+1)].value	= code;
					
					selectListObjTo[(j+1)].text  = text+", "+countryText;
					selectListObjTo[(j+1)].value = code;
				}
			}
		}
	} // end going over destinations rows

	// after filling select lists, set Tel Aviv in From1 and To2 rows 
	// when flight type is CHARTER or if trip type is ROUNDTRIP
	var roundTrip	= document.all["RegDirectionTypeRoundTrip"+ID].checked;
	var tripType	= '';
	if (roundTrip)	tripType = "ROUNDTRIP";
	if (tripType=="ROUNDTRIP" || flightType=="CHARTER")
	{
		// Set row 1, destination FROM
		var selectListObjFrom1	= formObj["DestinationFrom1"];			
		var index = findItemInSelectList(selectListObjFrom1, "TLV");
		if (index>0)
		{
			selectListObjFrom1.selectedIndex = index;
		} else {
			selectListObjFrom1.length = selectListObjFrom1.length+1;
			var len = selectListObjFrom1.length-1;
			selectListObjFrom1[len].text		= "תל-אביב";
			selectListObjFrom1[len].value		= "TLV";
			selectListObjFrom1[len].selected	= true;	
		}
		// Set row 2, destination TO 
		var selectListObjTo2	= formObj["DestinationTo2"];
		var index = findItemInSelectList(selectListObjTo2, "TLV");
		if (index>0)
		{
			selectListObjTo2.selectedIndex = index;
		} else {
			selectListObjTo2.length = selectListObjTo2.length+1;
			var len = selectListObjTo2.length-1;
			selectListObjTo2[len].text		= "תל-אביב";
			selectListObjTo2[len].value		= "TLV";
			selectListObjTo2[len].selected	= true;	
		}
	}	
}

function OpenDestinationsPopUp(objName, ind, id) 
{	
	
	//alert(objName+"\n"+ind+"\n"+id)
	try {
		var formObj = document.all["RegExtendedSearchForm"+id];
	} catch(e) { return; }

	
	var features = "dialogHeight:250px;dialogWidth:550px;scroll:no;"
	var result = showModalDialog("/site/windows/REGULAR/DestinationsPopup.asp?stcss="+css+"&lang="+lang+"&sitePath="+_site_path+"&objName="+objName+"&ind="+ind+"&id="+id, self, features)
	if(result){	
		var selectListObj = formObj[objName+ind];
		if (selectListObj)
		{
			var index = findItemInSelectList(selectListObj, result.code);
			if (index>0)
			{
				selectListObj.selectedIndex = index;
			} else {	
				var len = selectListObj.length
				selectListObj.length = selectListObj.length+1;
				selectListObj[len].text		= result.name;
				selectListObj[len].value	= result.code;
				selectListObj[len].selected = true;
			}
			setRoundTripReturnValues(result.code, result.name, objName, ind, id);
		}
	}
}

function setRoundTripReturnValues(code, text, callingField, ind, id)
{
	try 
	{
		var formObj = document.all["RegExtendedSearchForm"+id];
	} catch(e) { return; }
	// reset date input field
	var dateInput = formObj["RegDate"+ind];
	if (dateInput) dateInput.value = '';
	
	var roundTrip = document.all["RegDirectionTypeRoundTrip"+id];	
	if (roundTrip)
	{ 
		if (roundTrip.checked)
		{
			
			ind = 3-ind; // ind = 1 or 2 
			// reset second destination row date input field
			var dateInput = formObj["RegDate"+ind];
			if (dateInput) dateInput.value = '';
			if (callingField=="DestinationFrom")
			{
				var targetObj	= formObj["DestinationTo"+ind];
				var textObj		= formObj["TextDestinationTo"+ind];
			} else {
				var targetObj	= formObj["DestinationFrom"+ind];
				var textObj		= formObj["TextDestinationFrom"+ind];
			}
			if (targetObj)
			{
				var index = findItemInSelectList(targetObj, code);
				if (index>0)
				{
					targetObj.selectedIndex = index;
				} else {
					targetObj.length = targetObj.length+1;
					var len = targetObj.length-1;
					targetObj[len].text		= text;
					targetObj[len].value	= code;
					targetObj[len].selected = true;
				}
			}
		}
	}
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS FOR SEARCH RESULTS PAGE 
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// set an item as selected on an existing select list
// used in the Search Results page.
function setSelectedItems(requestArray, ID)
{
	/* see the request array
	var str='';
	for (var i=0;i<requestArray.length;i++)
	{
		str += requestArray[i].key+" = "+requestArray[i].value+" : "+requestArray[i].fieldType+"\n";
	}
	document.write("<textarea>"+str+"</textarea>")
	*/
	
	
	try {
		var formObj = document.all["RegExtendedSearchForm"+ID];
	} catch(e) { return; }
	for (var i=0;i<requestArray.length;i++)
	{
		try {
			var element = formObj[requestArray[i].key];
//			alert(requestArray[i].key+" : "+element)
		} catch(e){}
		if (element)
		{
			if (!isnull(requestArray[i].value) && 
				requestArray[i].value!="ALL" && 
				requestArray[i].value!="0")
			{
				// set values for the select lists: 
				// destinations, passengers, airline, airline class
				if (requestArray[i].fieldType=="selectList")
				{	
					var index = findItemInSelectList(element, requestArray[i].value);
//alert(i);
					if (index>0)
					{	
						element.selectedIndex = index;
					} 
					else 
					{	
						// if item was not found in the list then get it from the request
						if (i<requestArray.length-1)
						{
							if (!isnull(requestArray[i].value))
							{	
//alert(requestArray[i].key + ":" + requestArray[i].value)
								// get text value of this item
								var index = findItemInArray(request, "Text"+requestArray[i].key);
								if (index > 0)
								{
									var len = element.length;
									element.length = element.length+1;
									element[len].text	= requestArray[index].value;
									element[len].value	= requestArray[i].value;
									element[len].selected = true;
								}
								
														
							}
						}
					}
				} 
				else // fieldType is not a selectList
				{
					// set selected date
					element.value = requestArray[i].value;
				}
			}
		}
	}
}
function findItemInSelectList(selectList, itemValue)
{	
	for (var k=0;k<selectList.length;k++)
	{
		if (selectList[k].value == itemValue)
		{
			return k;
		}
	}
	return 0;
}

function findItemInArray(arr, itemName)
{	
	for (var k=0;k<arr.length;k++)
	{
		if (arr[k].key == itemName)
		{
			return k;
		}
	}




	return 0;
}


function swapDisplay(iconObj, id)
{
	var obj = document.all[id];
	if (obj.style.display=='' || obj.style.display=='inline')
	{
		iconObj.src=(iconObj.src).replace(/_on/,"_off");
		obj.style.display = "none";
	} else {
		iconObj.src=(iconObj.src).replace(/_off/,"_on");
		obj.style.display = "inline";
	}
}

// AIRLINES LOGOS 
//------------------------------------------------------------------
// in case an airline logo image has failed to load,
// hide the image and display the airline's name
function ImageLoadFailed(imgObj) 
{
	try {
		var nameDiv = imgObj.parentNode.previousSibling;
		window.event.srcElement.style.display='none';	//hide image
		if ((nameDiv.name).indexOf("missingLogo")>-1)	
			nameDiv.style.display = "inline";	// display the airline name
	} catch(e){}
}

//------------------------------------------------------------------





function ShowPrices(cache_id)
{
	
	var POPUP_H=300;
	var POPUP_W=500;
	var features = "scroll:no;dialogHeight:"+POPUP_H+"px;dialogWidth:"+POPUP_W+"px"
	//alert('_site_path\\css='+ _site_path + '\\'+ css)
	showModalDialog("/site/windows/REGULAR/Price.asp?stcss="+css+"&pi="+node_pi+"&sitePath="+_site_path+"&CacheID="+cache_id,self,features)
}

function ShowRules(cache_id)
{
	
	var POPUP_H=550;
	var POPUP_W=500;
	var features = "dialogHeight:"+POPUP_H+"px;dialogWidth:"+POPUP_W+"px;scroll:no;"
	showModalDialog("/site/windows/REGULAR/Rules.asp?pi="+node_pi+"&sitePath="+_site_path+"&lang="+lang+"&stcss="+css+"&CacheID="+cache_id,self,features)
}

function closeDiv(obj){
		obj.style.display = 'none'
		obj.innerHTML=''
}
function putFram(obj,AirplaneType,FlightNumber,AirlineName, MealType){
	var content="\
	<table cellpadding='0' cellspacing='0' width='100%' dir='"+dir+"'>"
	if(!isnull(AirlineName)){	
		content+="\
		<tr>\
			<td align='"+alignOps+"' class='dirDivText' nowrap>"+dic.AIRLINE_NAME+":</td>\
			<td align='"+align+"' class='dirDivTime' style='padding-"+align+":5' nowrap>"+AirlineName+"</td>\
		</tr>"
	}
	if(!isnull(AirplaneType)){	
		content+="\
		<tr>\
			<td align='"+alignOps+"' class='dirDivText' nowrap>"+dic.AIRPLANE_TYPE+":</td>\
			<td align='"+align+"' class='dirDivTime' style='padding-"+align+":5' nowrap>"+AirplaneType+"</td>\
		</tr>"
	}
	
	/*
	
	if(!isnull(FlightNumber))
	{
		content+="\
		<tr>\
			<td align='"+alignOps+"' class='dirDivText' nowrap>"+dic.FLIGHT_NUMBER+":</td>\
			<td align='"+align+"' class='dirDivTime' style='padding-"+align+":5' nowrap>"+FlightNumber+"</td>\
		</tr>"
	}
	
	*/
		
	if(!isnull(MealType)){	
		content+="\
		<tr>\
			<td align='"+alignOps+"' class='dirDivText' nowrap>"+dic.MEAL_TYPE+":</td>\
			<td align='"+align+"' class='dirDivTime' style='padding-"+align+":5' nowrap>"+MealType+"</td>\
		</tr>"
	}	
	content+="</table>"
	obj.style.display = 'inline';
	document.all['contTD'].innerHTML = content;
	obj.innerHTML = document.all['parentDiv'].innerHTML;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 






//----------------------------------------------------------------------
//	SUBMIT	EXTENDED SERACH ENGINE
//----------------------------------------------------------------------
function SubmitRegularFlightsExtendedEngine(id) 
{
	try {
		var formObj = document.all["RegExtendedSearchForm"+id];
	} catch(e) { return; }

	var flightType	= formObj['FlightType'].value;
	var roundTrip	= document.all['RegDirectionTypeRoundTrip'+id].checked;
	var onewayTrip	= document.all['RegDirectionTypeOneWay'+id].checked;
	var multiTrip	= document.all['RegDirectionTypeMultiTrip'+id].checked;
	// ROUNDTRIP -------------------------------------------------
	if (roundTrip)
	{
		for (var i=1;i<=2;i++)
		{
			if (isnull(formObj['DestinationFrom'+i].value)||
				isnull(formObj['DestinationTo'+i].value))
			{
				alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
				return;	
			}
			if (isnull(formObj['RegDate'+i].value)) 		
			{
				alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
				return;
			}
		}
	}
	// ONEWAY ---------------------------------------------------
	if (onewayTrip)
	{
		if (isnull(formObj['DestinationFrom1'].value)||
			isnull(formObj['DestinationTo1'].value))
		{
			alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
			return;	
		}
		if (isnull(formObj['RegDate1'].value)) 		
		{
			alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
			return;
		} 
	}
	// MULTITRIP -------------------------------------------------
	if (multiTrip)
	{
		var destinations = 0;
		for (var i=1;i<=5;i++)
		{
			if (!isnull(formObj['DestinationFrom'+i].value)&&
				!isnull(formObj['DestinationTo'+i].value)	 &&
				!isnull(formObj['RegDate'+i].value))
			{
				destinations++;
			} else {
				if (!isnull(formObj['DestinationFrom'+i].value)||
					!isnull(formObj['DestinationTo'+i].value)	||
					!isnull(formObj['RegDate'+i].value))
				{
					if (isnull(formObj['RegDate'+i].value))
						alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
					else 
						alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
					return;
				}
			}			
		}	 
	}	
	// submit
	if (destinations<2)
	{
		alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
		return;	
	}
	if (preventUNN(formObj, id))
	{ 

		if (flightType=="CHARTER")
		{
			formObj['DestCode'].value			= formObj['DestinationTo1'].value;
			formObj['query'].value				= 'FlightDealsRequestEx';
			formObj['OutboundDate_Start'].value	= formObj['RegDate1'].value;
			formObj['OutboundDate_End'].value	= formObj['RegDate1'].value;   
			formObj['BestPrice'].value			= '0'
			formObj['InboundDate_Start'].value	= formObj['RegDate2'].value;
			formObj['InboundDate_End'].value	= formObj['RegDate2'].value;

			//formObj.action = flights_action;
			formObj.action = regular_action;
		}  else {
			formObj.action = regular_action;
		}


		// -------------------------------------------------------------------------  
		// new modified on 03/2006 for treating the ROUNDTRIP as MULTITRIP with 2 destinations
		// when DestinationTo1 != DestinationFrom2 
		//try{
		//	if (roundTrip)
		//	{	
		//		if (formObj['DestinationTo1'].value  != formObj['DestinationFrom2'].value)
		//		{
		//			formObj["DirectionType"].value = "MULTITRIP";
		//		}
		//	}
		//}catch(e){}

		// set destination text descriptions as values in hidden text fields 
		setHiddenTexts(formObj);
//alert(document.location.href)

formObj.target="_parent";

		if(document.location.href.indexOf("component.asp")>-1 || document.location.href.indexOf("yad2Regular.asp")>-1)
		{
//alert("in")
			if (top.location != self.location) {
				formObj.target='_top';
			}
		}		formObj.submit();
	}
}

function setHiddenTexts(formObj)
{
	// destinations
	for (var i=1;i<=5;i++)
	{
		var destFrom = formObj["DestinationFrom"+i];
		if (destFrom.selectedIndex>0)
		{
			formObj["TextDestinationFrom"+i].value	= destFrom[destFrom.selectedIndex].text;
		}
		var destTo = formObj["DestinationTo"+i];
		if (destTo.selectedIndex>0)
		{
			formObj["TextDestinationTo"+i].value	= destTo[destTo.selectedIndex].text;
		}
	}
	// airline 
	var airline = formObj["Airline"];
	if (airline.selectedIndex>0)
	{
		formObj["TextAirline"].value = airline[airline.selectedIndex].text;
	}
	// flight class
	var flightClass = formObj["Class"];
	if (flightClass.selectedIndex>0)
	{
		formObj["TextClass"].value = flightClass[flightClass.selectedIndex].text;
	}
}


var monthLength=12;
function OpenCalendarPopUp(objName, ind, id, mode) 
{	
	if (!fillingDatesRules(ind, id)) return;

	try {
		var formObj = document.all["RegExtendedSearchForm"+id];
	} catch(e) { return; }

	
	



	if (Number(ind)>1)
	{
		var previousDate = formObj["RegDate"+(Number(ind)-1)].value;
	}  else {
		var previousDate = '';
	}
	var DestCode	= formObj['DestinationTo1'].value;
	var flightType	= formObj["FlightType"].value;
	
	var roundTrip	= document.all["RegDirectionTypeRoundTrip"+id].checked;
	var oneway		= document.all["RegDirectionTypeOneWay"+id].checked;
	var multiTrip	= document.all["RegDirectionTypeMultiTrip"+id].checked;
	if (roundTrip)	var tripType = "ROUNDTRIP";
	if (oneway)		var tripType = "ONEWAY";
	if (multiTrip)	var tripType = "MULTITRIP";
	
	// determine if the calendar will perform a charter query
	var bFromTelAviv = formObj["DestinationFrom1"].value=="TLV";
	if (bFromTelAviv && tripType=="ROUNDTRIP" && flightType!="REGULAR")
	{
		var bRunCharter = true;
	} else {
		var bRunCharter = false;	
	}
	
	
	if (flightType=="REGULAR")
	{
		mode = "exit";
	}
	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 features = "dialogHeight:400px;dialogWidth:500px;scroll:no;"
	var calendarURL = "/site/windows/REGULAR/regularFlights_search_calendar.asp?bRunCharter="+bRunCharter+"&pi="+node_pi+"&sitePath="+_site_path+"&DestCode="+DestCode+"&mode="+mode+"&ind="+ind+"&id="+id+"&previousDate="+previousDate+"&flightType="+flightType+"&tripType="+tripType+"&fse=false";
	
//window.open(calendarURL)
	var result = showModalDialog(calendarURL, self, features);
	if(!isnull(result))
	{
		formObj[objName].value = result;		
	}
}



function fillingDatesRules(ind, id)
{
	try {
		var formObj = document.all["RegExtendedSearchForm"+id];
	} catch(e) { return; }

	var destFromObj = formObj['DestinationFrom'+ind];
	var destToObj	= formObj['DestinationTo'+ind];
	var oneway = document.all["RegDirectionTypeOneWay"+id].checked;
	
	if (destFromObj)
	{
		if (isnull(destFromObj.value)) 
		{
			alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
			return false;	
		}
	}
	if (destToObj)
	{
		if (isnull(destToObj.value)) 
		{
			alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
			return false;	
		}
	}
	if (ind>1 || oneway)
	{
		var dateObj	= formObj['RegDate'+(ind-1)];
		if (dateObj)
		{
			if (isnull(dateObj.value)) 
			{
				alert(dic.REGULAR_FLIGHTS_FILL_DATES_BY_ORDER_ERROR);
				return false;	
			}
		}
	}
	return true;
}
































////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//
//									FAST SEARCH ENGINE 
//
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/*
------------------------------------------------------------------------
GLOBALS 
-------------------------------------------------------------------------
*/
var FSEDestinationsXML=null
var FSElocalCitiesXML = null
var FSECitiesList = null

try{

	// XML object - countries
	FSEDestinationsXML	= new ActiveXObject("Microsoft.XMLDOM");
	FSEDestinationsXML.async	= false;

	// XML object - cities 
	FSElocalCitiesXML=new ActiveXObject("Microsoft.XMLDOM");
	FSElocalCitiesXML.async=false;

	// store results - cities
	FSECitiesList=new Array();

}
catch(e)
{
}


function setDestinationFieldsFastSE(flightType, ID, lang)
{
	// reset first destination row date input field
	var dateInput = document.all["RegDateTo"+ID];
	if (dateInput) dateInput.value = '';
	// reset second destination row date input field
	var dateInput = document.all["RegDateFrom"+ID];
	if (dateInput) dateInput.value = '';
	
	// set destination rows links				
	if (flightType=="CHARTER")
	{
		document.all["RowLinksTo"+ID].style.display			= "none";
		document.all["RowLinksAlterTo"+ID].style.display	= "inline";
		document.all["RowLinksFrom"+ID].style.display		= "none";
		document.all["RowLinksAlterFrom"+ID].style.display	= "inline";
	} else {
		document.all["RowLinksTo"+ID].style.display			= "inline";
		document.all["RowLinksAlterTo"+ID].style.display	= "none";
		document.all["RowLinksFrom"+ID].style.display		= "inline";
		document.all["RowLinksAlterFrom"+ID].style.display	= "none";
	}
	fillFastSearchEngineDestinations(flightType, ID, lang);
}



/*
------------------------------------------------------------------------
Request Destinations: Cities
-------------------------------------------------------------------------
*/
// fill the cities list according to a selected country
function fillFastSearchEngineDestinations(flightType, ID, lang)
{

	var formObj = document.all["RegFastSearchForm"+ID];


	if (isnull(lang)) lang = "HE";
	if (isnull(flightType)) 
	{
		flightType = formObj["RegFlightType"].value;
	}
	// load once the destinations XML file 
	if(!FSECitiesList[flightType])
	{
		var obj = {};
		switch (flightType)
		{
			case "ALL":
				obj.exist = FSEDestinationsXML.load("/shared/CharterAndRegularCities."+lang+".xml");
			break;
			case "REGULAR":
				obj.exist = FSEDestinationsXML.load("/shared/CharterAndRegularCities."+lang+".xml");
				//obj.exist = FSEDestinationsXML.load("/shared/RegularCities.100."+lang+".xml");
			break;
			case "CHARTER":
				obj.exist = FSEDestinationsXML.load("/shared/CharterCities.100."+lang+".xml");
			break;
		}				
		if(obj.exist) 
		{
			obj.xml	= FSEDestinationsXML.xml;
			FSECitiesList[flightType] = obj;
		}
	} 
	// load cities XML object from FSECitiesList array
	FSElocalCitiesXML.loadXML(FSECitiesList[flightType].xml);
	fillSelectListsFastSE(flightType, ID, lang);
	
}


function fillSelectListsFastSE(flightType, ID, lang)
{

	var formObj = document.all["RegFastSearchForm"+ID];

	var langOps="EN";
	lang=="HE"?langOps="EN":langOps="HE";

	// fill the destinations select lists (FROM and TO) 
	var selectListObjTo		= formObj["DestinationTo"];
	var selectListObjFrom	= formObj["DestinationFrom"];
	if (selectListObjFrom && selectListObjTo)
	{
		// clear destinations
		selectListObjTo.length=1;
		selectListObjTo[0].value="";
		selectListObjTo[0].text="";						
		selectListObjTo[0].selected=true;
		 
		selectListObjFrom.length=1;
		selectListObjFrom[0].value="";
		selectListObjFrom[0].text="";						
		selectListObjFrom[0].selected=true;

		if (selectListObjFrom.currentList	!= flightType && 
			selectListObjTo.currentList		!= flightType)
		{
			var oCities = FSElocalCitiesXML.documentElement.selectNodes("//cities/city");
			var tempLength = oCities.length+1;
			
			selectListObjFrom.length	= tempLength;
			selectListObjTo.length		= tempLength;

			// fill the select list		
			for(var j=1;j<tempLength;j++)
			{
				var city = oCities.nextNode();

				// get city text
				try {
					var cityText = city.getAttribute(lang);
					if(isnull(cityText)) throw new Error()
				} catch(e) {
					try {
						var cityText = city.getAttribute(langOps);
						if(isnull(cityText)) throw new Error()
					} catch(e) {
						var cityText = false;
					}
				}
				
				// get country text
				try {
					var countryText = city.getAttribute("country_"+lang);
					if(isnull(countryText)) throw new Error();
				} catch(e) {
					try {
						var countryText = city.getAttribute("country_"+langOps);
						if(isnull(countryText)) throw new Error();
					} catch(e) {
						var countryText = false;
					}
				}

				// get city code
				try {
					var cityCode = city.getAttribute("code");
				} catch(e) {
					var cityCode = false;
				}
				if (cityText && cityCode && countryText)
				{
					selectListObjFrom[j].text	= cityText+", "+countryText;
					selectListObjFrom[j].value	= cityCode;
					selectListObjTo[j].text		= cityText+", "+countryText;
					selectListObjTo[j].value	= cityCode;
				}	
			}
			selectListObjFrom.currentList	= flightType;
			selectListObjTo.currentList		= flightType;
		}
	}
}


function setRoundTripReturnValuesFastSE(code, text, targetObjName, id)
{
	//alert("code="+code+"\ntext="+text+"\ntargetObjName="+targetObjName+"\nid="+id);
	var formObj = document.all["RegFastSearchForm"+id];


	// onchange event in the "Destination TO" select list 
	if (targetObjName=="DestinationFrom")
	{
		// reset first destination row date input field
		var dateInput = formObj["RegDateTo"];
		if (dateInput) dateInput.value = '';
		// reset second destination row date input field
		var dateInput = formObj["RegDateFrom"];
		if (dateInput) dateInput.value = '';	
	}
	// onchange event in the "Destination FROM" select list 
	if (targetObjName=="DestinationTo")
	{
		// reset second destination row date input field
		var dateInput = formObj["RegDateFrom"];
		if (dateInput) dateInput.value = '';	
	}
	
	if (targetObjName=="DestinationFrom")
	{
		var selectObj = formObj[targetObjName];
		if (selectObj)
		{
		
			var index = findItemInSelectList(selectObj, code);
			if (index>0)
			{
				selectObj.selectedIndex = index;
			} else {
				selectObj.length = selectObj.length+1;
				var len = selectObj.length-1;
				selectObj[len].text		= text;
				selectObj[len].value	= code;
				selectObj[len].selected = true;
			}
		}
	}
	

	// set destination FROM as the destination TO
	/*
	var flightType = formObj["FlightType"].value;
	if (flightType)
	{ 
		if (flightType=="CHARTER" && targetObjName=="DestinationFrom")
		{   
			var selectObj = formObj[targetObjName];
			if (selectObj)
			{
				selectObj.length	= 1;		
				selectObj[0].value	= code;
				selectObj[0].text	= text;
				selectObj[0].selected	= true; 	
				selectObj.readonly		= true;
			}
		}	
	}
	*/
}

function OpenDestinationsPopUpFastSE(objName, id) 
{	
	//alert(objName+"\n"+id)
	var formObj = document.all["RegFastSearchForm"+id];
	
	
	
	var features = "dialogHeight:250px;dialogWidth:550px;scroll:no;"
	var result = showModalDialog("/site/windows/REGULAR/DestinationsPopup.asp?stcss="+css+"&lang="+lang+"&sitePath="+_site_path+"&objName="+objName+"&id="+id, self, features)
	if(result){	
		var selectListObj = formObj[objName];
		if (selectListObj)
		{
			selectListObj.length = selectListObj.length+1;
			var len = selectListObj.length-1;
			selectListObj[len].text	 = result.name;
			selectListObj[len].value = result.code;
			selectListObj[len].selected = true;

			if (objName=="DestinationFrom")
			{
				// reset first destination row date input field
				var dateInput = formObj["RegDateFrom"];
				if (dateInput) dateInput.value = '';
			} else {
				// reset second destination row date input field
				var dateInput = formObj["RegDateTo"];
				if (dateInput) dateInput.value = '';	
			}
		}
	}
}





//----------------------------------------------------------------------
//	SUBMIT FAST SEARCH ENGINE
//----------------------------------------------------------------------

function fillingDatesRulesFastSE(objName, id)
{	
	var formObj		= document.all['RegFastSearchForm'+id];
	
	if (objName=="RegDateTo")
	{
		var destToObj = formObj['DestinationTo'];
		if (destToObj)
		{
			if (isnull(destToObj.value)) 
			{
				alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
				return false;	
			}
			else return true;
		}
	}

	if (objName=="RegDateFrom")
	{
		var destFromObj = formObj['DestinationFrom'];
		if (destFromObj)
		{
			if (isnull(destFromObj.value)) 
			{
				alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
				return false;	
			}
			var dateObj	= formObj['RegDateTo'];
			if (dateObj)
			{
				if (isnull(dateObj.value)) 
				{
					alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
					return false;	
				}
				else return true;
			}
		}
	}
}


function SubmitRegularFlightsFastSE(id) 
{		
	var formObj		= document.all['RegFastSearchForm'+id];
	var flightType	= formObj['FlightType'].value;
	
	// must fill first row destination
	if (isnull(formObj['DestinationTo'].value))
	{
		alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
		return;
	}
	formObj['DestCode'].value = formObj['DestinationTo'].value;
	
	// must fill first row date
	if (isnull(formObj['RegDateTo'].value)) 		
	{
		alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
		return;
	}
	formObj['InboundDate_Start'].value		= formObj['RegDateFrom'].value;
	formObj['InboundDate_End'].value		= formObj['RegDateFrom'].value;
		

	// empty second row = oneway trip
	if (isnull(formObj['DestinationFrom'].value) && 
		isnull(formObj['RegDateFrom'].value))
	{
		formObj['DirectionType'].value="ONEWAY";
	}  
	else 
	{	// prevent partly filled second row 
		// empty destination
		if (isnull(formObj['DestinationFrom'].value))
		{
			alert(dic.REGULAR_FLIGHTS_DESTINATIONS_ERROR);
			return;
		}
		// empty date
		if (isnull(formObj['RegDateFrom'].value))
		{
			alert(dic.REGULAR_FLIGHTS_DATES_ERROR);
			return;
		}
		// second row filled completely
		if (!isnull(formObj['DestinationFrom'].value) && 
			!isnull(formObj['RegDateFrom'].value))
		{
			if (formObj['DestinationTo'].value == formObj['DestinationFrom'].value)
			{
				formObj['DirectionType'].value="ROUNDTRIP";
			} else {
				formObj['DirectionType'].value="MULTITRIP";
			}
		}
		
		formObj['OutboundDate_Start'].value		= formObj['RegDateTo'].value;
		formObj['OutboundDate_End'].value		= formObj['RegDateTo'].value;
	}

	if (preventUNN(formObj, id))
	{ 
		formObj['query'].value					= 'FlightDealsRequestEx';
		formObj['BestPrice'].value				= '0';
		formObj.action = regular_action;
		
		FillAdditionalFieldsOfFastSE(id)
		
		formObj.submit();
	}
}

function FillAdditionalFieldsOfFastSE(id){
	var formObj		= document.all['RegFastSearchForm'+id];
	var trip = formObj['DirectionType'].value;
	formObj['DestinationTo1'].value = formObj['DestinationTo'].value
	formObj['DestinationFrom1'].value = "TLV"
	formObj['RegDate1'].value = formObj['RegDateTo'].value
	
	var destTo = formObj["DestinationTo"];
	if (destTo.selectedIndex>0)
	{
		formObj["TextDestinationTo1"].value	= destTo[destTo.selectedIndex].text;
	}
	//formObj["TextDestinationFrom1"].value = dic.TEL_AVIV
	
	if(trip != "ONEWAY"){
		formObj['DestinationTo2'].value = "TLV"
		formObj['DestinationFrom2'].value = formObj['DestinationFrom'].value
		formObj['RegDate2'].value = formObj['RegDateFrom'].value
		
		var destFrom = formObj["DestinationFrom"];
		if (destFrom.selectedIndex>0)
		{
			formObj["TextDestinationFrom2"].value	= destFrom[destFrom.selectedIndex].text;
		}
		//formObj["TextDestinationTo2"].value = dic.TEL_AVIV
	}
}


////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//
//							SHARED SUBMIT FUNCTIONS
//
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
// PASSENGERS -----------
// UNN = Unaccompanied Child
// prevent the selection of a Child/Infant without Senior/Adult 
function preventUNN(form, id) {
	var snn = form['SeniorNumber'];
	var adt = form['AdultNumber'];
	var yth = form['YouthNumber'];
	var cnn = form['ChildNumber'];
	var inf = form['InfantNumber'];

	var totalAdults = adt.value + snn.value;
	if (inf.value>totalAdults)
	{	
		alert(dic.REGULAR_FLIGHTS_INFANT_ERROR);
		return false;
	}
	if (yth.value==0 && adt.value==0 && snn.value==0) {
		alert(dic.REGULAR_FLIGHTS_SELECT_PASSENGER_ERROR);
		return false;
	}
	return true;
}





////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//
//							SHARED CALENDAR FUNCTIONS
//
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
function zeroPad(sStr,iLeng,bBegin){
	for(var i=0;i<(iLeng-String(sStr).length);i++)
		if(bBegin) sStr="0"+sStr
		else sStr=sStr+"0"
	return 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=''
}

var monthCurrent=1
function initImages(){
	if(monthLength>2) 
		nextMonthImg.style.display='';
}

function setFlightDate(sDate)
{
	returnValue=sDate;
	window.close()	
}


//arr is array of objects, defined in calendar.xsl
function RegularFlightsCalendar()
{
	var count=0
	function monthTable(dDate){
		//return "month"
		var dCurrDayInMonth=new Date("1-1-1900")
		var dLastDayInMonth=new Date("1-1-1900")
		var currDayInWeek
		var sStr=""
					
		dCurrDayInMonth.setYear(dDate.getYear())
		dLastDayInMonth.setYear(dDate.getYear())
					
		dCurrDayInMonth.setMonth(dDate.getMonth())
		dLastDayInMonth.setMonth(Number(dDate.getMonth())+1)
					
		dCurrDayInMonth.setDate(1)
		dLastDayInMonth.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
					
			var className="days", onclick="", style="", additional=""
			
			
			if((previousDateObject!=null && dCurrDayInMonth<previousDateObject) || dCurrDayInMonth<today){
				className+=" notactive_day"
			}
			else{
				if(flightType == "CHARTER"){
					if(charterDates.length>0 && sCurrDayInMonth==charterDates[0].Date)
					{
						className+=" charter_day";
						onclick="setFlightDate(\""+sCurrDayInMonth+"\");";
						style+="cursor:hand;";
						charterDates.shift();
					}
					else{
						className+=" notactive_day";
					}
				}
				else{
					onclick="setFlightDate(\""+sCurrDayInMonth+"\");"
					style+="cursor:hand;";
					
					if(charterDates.length>0 && sCurrDayInMonth==charterDates[0].Date)
					{
						className+=" charter_day";
						charterDates.shift();
					}
					if(specialDays.length!=0 && sCurrDayInMonth == specialDays[0])
					{
						className+=" regular_flight_day";
						specialDays.shift();
					}
				}
			}

			sStr+="<td class='"+className+"' onclick='"+onclick+"' style='"+style+"' "
			sStr+=additional
			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
	}
			
			
	var sStr="",_contentExist=false;
	var today,endDate
	today = new Date(todayDate.replace(/-/g,'\/'))
	endDate = new Date(todayDate.replace(/-/g,'\/'))
	endDate.setYear(endDate.getYear()+1)
	if(flightType=="CHARTER")
	{
		if(charterDates.length==0)
		{
			return ""
		}
		else
		{
			today = new Date(charterDates[0].Date.replace(/-/g,'\/'))
			endDate = new Date(charterDates[charterDates.length-1].Date.replace(/-/g,'\/'))
		}
	}
	

	var tempDate=new Date("1-1-1900")
	if(!isnull(previousDate)){
		tempDate.setMonth(previousDateObject.getMonth())
		tempDate.setYear(previousDateObject.getYear())
	}
	else{
		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' align='center'>\
				<tr id='searchByDateMonthes'>"
					var monthCount=0
					for(;tempDate<=endDate;tempDate.setMonth(Number(tempDate.getMonth())+1))
					{
						locTempDate.setMonth(Number(locTempDate.getMonth())+1)
						sStr+="<td valign='top' monthIndex='"+monthCount+"' id='monthTD_"+monthCount+"' style='padding:7px;display:"+(monthCount>1?'none':'')+";'>\
									<table cellpadding='0' cellspacing='1' border='0' class='calendar'>\
										<tr>\
											<td colspan='7'>\
												<table cellpadding='0' cellspacing='0' border='0' width='100%'>\
													<tr class='month'>\
														<td class='month' width='100%' nowrap align='center''>"+dic["MONTH_"+(Number(tempDate.getMonth())+1)]+" : "+tempDate.getYear()+"</td>\
													</tr>\
												</table>\
											</td>\
										</tr>"+monthTable(tempDate)+"</table>\
								</td>"
						monthCount++
						_contentExist=true
					}
					if(flightType=="CHARTER") monthLength=monthCount
	sStr+=	"</tr>\
			</table>"
			
	if(_contentExist) return sStr
	else return ""

}


var monthCurrent=1
function nextMonth(){
	monthCurrent++;
	document.all["monthTD_"+(monthCurrent-2)].style.display='none';
	document.all["monthTD_"+monthCurrent].style.display='';
	prevMonthImg.style.display='';
	if(monthCurrent==(monthLength-1)) nextMonthImg.style.display='none';
}
function prevMonth(){
	monthCurrent--;
	document.all["monthTD_"+(monthCurrent+1)].style.display='none';
	document.all["monthTD_"+(monthCurrent-1)].style.display='';
	nextMonthImg.style.display='';
	if(monthCurrent==1) prevMonthImg.style.display='none';
}


// Mark the selected day when user clicks on it
// When another day is selected Roll-Back the previouly selected day's class.
var prev_day_obj=null; // This object holds the previously selected day object
function markSelectedDay(day_obj) {
	var curr_class = day_obj.className;
	var new_class = "selected_day";	// class to mark the selected day - defined in each css_<filename>.css
	if (prev_day_obj != null) {
		prev_day_obj.className = curr_class;
	} 
	prev_day_obj = day_obj;
	day_obj.className = new_class;
}



////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//
//						FAST SEARCH ENGINE CALENDAR FUNCTIONS
//
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
var monthLength=12;
function OpenCalendarPopUpFastSE(objName, id, mode) 
{	
	
	var formObj		= document.all['RegFastSearchForm'+id];
	if (!fillingDatesRulesFastSE(objName, id)) return;
	
	if (objName=="RegDateFrom")
	{
		var previousDate = formObj["RegDateTo"].value;
	}	
	var DestCode = formObj['DestinationTo'].value;
	


	// determine if the calendar will perform a charter query
	if (flightType!="REGULAR")
	{
		var bRunCharter = true;
	} else {
		var bRunCharter = false;	
	}
	
	var flightType = formObj["FlightType"].value;
	if (flightType=="REGULAR")
	{
		mode = "exit";
	}
	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 features = "dialogHeight:400px;dialogWidth:500px;scroll:no;"
	var calendarURL = "/site/windows/REGULAR/regularFlights_search_calendar.asp?bRunCharter="+bRunCharter+"&pi="+node_pi+"&sitePath="+_site_path+"&DestCode="+DestCode+"&mode="+mode+"&id="+id+"&previousDate="+previousDate+"&flightType="+flightType+"&fse=true";
	

	if(!isnull(result))
	{
		formObj[objName].value = result;
	}
}



var chIframe = null;
var currRegSeId = "";
function OpenChildsAgesPopup(id){
    currRegSeId = id;
    var o = document.getElementById("RegChildNumber"+id);
    var ca = document.getElementById("ChildsAges");
    
    if(o.value == "0")
    {
        ca.value="";
        //return;
    }
    /*if(!chIframe)
    {
        chIframe = document.createElement("iframe");
        //chIframe.style="width:410px;height:60px;position:absolute;display:none;";
        chIframe.src = "about:blank;";
        chIframe.frameBorder="0";
        chIframe.scrolling="no";
        o.parentElement.appendChild(chIframe);
        chIframe.style.borderWidth = "0";
        chIframe.style.width = "414px";
        chIframe.style.height = "99px";
        chIframe.style.position = "absolute";
        chIframe.style.display = "none";
        chIframe.style.marginTop = "2px";
        chIframe.style.marginRight = "-150px";
    }
    chIframe.src="/site/windows/regular/ChildAges.asp?lang="+lang+"&Childs="+o.value+"&Ages="+ca.value ;
    chIframe.style.display="";
	*/
	var features = "dialogHeight:120px;dialogWidth:420px;scroll:no;"
	var childsUrl = "/site/windows/regular/ChildAges.asp?lang="+lang+"&Childs="+o.value+"&Ages="+ca.value ;
	var result = showModalDialog(childsUrl, self, features);
	if(!isnull(result))
	{
		var resArr = result.split("___");
		SetChildAges(resArr[0],resArr[1]);
	}
}
function SetChildAges(res,val){
    var o = document.getElementById("RegChildNumber"+currRegSeId);
    var ca = document.getElementById("ChildsAges");
    
    o.value = val;
    ca.value=res;
    //chIframe.style.display="none";
}