var o_popurl = "#";
var o_popwindow = 0;
var b_popwindow = 1;

function checkpopUp()
{
	
	b_popwindow = (o_popwindow) ? o_popwindow.closed : 1;
	
	if (b_popwindow) 
	{
		document.location = o_popurl;
	}
	else 
	{
		o_popwindow.focus();
	}
	
}

function popUp(s_url,s_name,s_attrib)
{
	o_popurl = s_url;
	o_popwindow = window.open(s_url,s_name,s_attrib);
	setTimeout("checkpopUp()", 500);
}

function change(id, newClass) 
{	

	try
	{
	
		var obj = getElObj(id,'',searchType+"_frame");		
	
		if (typeof(obj) != "object") 
		{
			id = YAHOO.util.Dom.get(id);
		}
		else 
		{
			id = obj;
		}
		
		var oldClassName = id.className;
		
		if(newClass.length == 0 )
		{
			YAHOO.util.Dom.removeClass(id,oldClassName);
		}
		else
		{
			YAHOO.util.Dom.replaceClass(id,oldClassName,newClass);
		}
		
	}
	
	catch(error)
	{		
	}
	
}

function hide(idLayer) 
{ 

	try 
	{
	
		if(typeof(idLayer) != "object")
		{
			try
			{
				document.getElementById(idLayer).style.display='none'; 
			}
			catch(error)
			{				
			}
		}
		else
		{	
			idLayer.style.display='none'; 
		}
	}
	catch(e)
	{		
	};
	
}

function show(idLayer) 
{
	
	try
	{
		
		if (typeof(idLayer) != "object") 
		{
			document.getElementById(idLayer).style.display = 'block';
		}
		else 
		{
			idLayer.style.display = 'block';
		}
	}
	catch(e)
	{		
	};
	
}

function showInline(idLayer) 
{ 

	try
	{

		if (typeof(idLayer) != "object") 
		{
			document.getElementById(idLayer).style.display = 'inline';
		}
		else 
		{
			idLayer.style.display = 'inline';
		}
	} 
	catch(e)
	{		
	};
	
}

function getChildrenBox()
{
	
	var re = new RegExp('(?:^|\\s+)' +'children_box' + '(?:\\s+|$)');
	var method = function(el) {return re.test(el["id"])};
	var childAgeContainer = YAHOO.util.Dom.getElementsBy(method,'',searchType+"_frame");
	
	if (childAgeContainer.length > 0) 
	{
		return childAgeContainer[0];
	}
	else 
	{
		return false;
	}
	
}

function getElObj(id,tag,root)
{
	
	var element;
	var re = new RegExp('(?:^|\\s+)' +id+ '(?:\\s+|$)');
	var method = function(el) {return re.test(el["id"])};
	var elementList = YAHOO.util.Dom.getElementsBy(method,tag,root);
	
	if (elementList.length > 0) 
	{
		element = elementList[0];
	}
		
	return element;	
	
}
			   

function loadErrorTranslation(errmsgObj)
{

	if(typeof(errmsgObj) == "undefined")
	{
		var validateError = new Object();
		validateError = {cityError:'enter a city' , dateError:'enter dates'};
	}
	
}

function checkForm(FormName, type) 
{

	var childrenBox = getChildrenBox();
	var form = document.getElementById(FormName);
	var searchForm = form;
	
	if (type == 'hotel' || type == 'saverate' || type == 'attractions')
	{ 
		
		var cityVal =  form.city.value;
		
		if(type != 'attractions')
		{
			var child = form.num_children.selectedIndex;
		}
		
	}

	if (type == 'airHotel' || type == 'air')
	{ 

		var leavingFromVal;
		var goingToVal;

		if (type == 'air')
		{
			leavingFromVal = form.leavingFrom.value
			goingToVal = form.goingTo.value
		}
		else
		{
			leavingFromVal = form.leavingFrom.value
			goingToVal = form.goingTo.value		
		}

		var child = form.num_children.selectedIndex;

	}

	if (type == 'car' || type == 'car_fd')
	{
		var pucityVal = form.pucity.value
	}

	if (type == 'lmd' || type == 'lastminute')
	{
		var toDestination = form.in_destform_state;
		var destinationCity = form.in_location_key;
	}
	else if (type != 'air')
	{	
		var chk_inVal = form.chk_in.value;
		var chk_outVal = form.chk_out.value;	
	}

	var blnPass = true;

	if (type == 'hotel' || type == 'saverate' || type == 'attractions')
	{ 

		if (cityVal == "" || cityVal == validateError.cityError) 
		{
			change("city","formWarning");
			form.city.value=validateError.cityError;
			blnPass = false;
		}
		
		if (typeof(child) != "undefined" && child != 0 && type != 'attractions')
		{	
		
			for (var i=1; i<=child; i++)
			{
			
				var selectBox = eval("form.minorsAge" + i);
		
				if (selectBox.selectedIndex == 0)
				{
					change('warn',"warning");
					childrenBox.style.display = "block";
					blnPass = false;
				}
				
			}
			
		}
		
	}

	if (type == 'airHotel' || type == 'air')
	{ 
	
		if(type == "air")
		{

			var airSearchType = form.flightType.value;

			if (airSearchType == "roundtrip" || airSearchType == "oneway")		
			{
				
				if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
				{
					change(form.leavingFrom,"formWarning");
					form.leavingFrom.value=validateError.cityError;
					blnPass = false;
				}
				
				if (goingToVal == "" || goingToVal == validateError.cityError) 
				{
					change(form.goingTo,"formWarning");
					form.goingTo.value=validateError.cityError;
					blnPass = false;
				}
				
			}
			else
			{	
				
				for ( i=1; i<=4; i++)
				{

					var flightNum = "flight" + i;
					var currFlight = document.getElementById(flightNum);
					var chk_in1 = eval("form.leavingDate" + i);
	
					if (currFlight.style.display == 'block')
					{

						var leavingFromVal = eval("form.leavingFrom" + i).value;
						var goingToVal = eval("form.goingTo" + i).value;
						
						if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
						{
							change(form.leavingFrom[i], "formWarning");
							form.leavingFrom[i].value = validateError.cityError;
							blnPass = false;
						}
						
						if (goingToVal == "" || goingToVal == validateError.cityError) 
						{
							change(form.goingTo[i], "formWarning");
							form.goingTo[i].value = validateError.cityError;
							blnPass = false;
						}
											
						if (chk_in1.value == "" || chk_in1.value == validateError.dateError || chk_in1.value == "mm/dd/yyyy" || chk_in1.value == "dd/mm/yyyy")
						{
							change(eval("form.leavingDate" + i), "formWarning");
							eval("form.leavingDate" + i).value = validateError.dateError;
							blnPass = false;
						}
	
					}
					else
					{
						chk_in1.value = "";
					}
					
				}	
							
			}

			var chk_inVal = form.chk_in.value;
			var chk_outVal = form.chk_out.value;
										
			if (airSearchType == "oneway")
			{

				if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy")			
				{
					change(form.chk_in, "formWarning");
					form.chk_in.value = validateError.dateError;
					blnPass = false;
				}
				
			}
			else if(airSearchType == "roundtrip")
			{
			
				if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy" || chk_outVal == "" || chk_outVal == validateError.dateError || chk_outVal == "mm/dd/yyyy")
				{
					change(form.chk_in,"formWarning");
					change(form.chk_out,"formWarning");
					form.chk_in.value=validateError.dateError;
					form.chk_out.value=validateError.dateError;
					blnPass = false;
				}
				
			}

		}
		else
		{

			if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
			{
				change(form.leavingFrom, "formWarning");
				form.leavingFrom.value = validateError.cityError;
				blnPass = false;
			}
			
			if (goingToVal == "" || goingToVal == validateError.cityError) 
			{
				change(form.goingTo, "formWarning");
				form.goingTo.value = validateError.cityError;
				blnPass = false;
			}
			
			if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
			{
				change(form.leavingFrom, "formWarning");
				form.leavingFrom.value = validateError.cityError;
				blnPass = false;
			}
			
			if (goingToVal == "" || goingToVal == validateError.cityError) 
			{
				change(form.goingTo, "formWarning");
				form.goingTo.value = validateError.cityError;
				blnPass = false;
			}
				
		}
										
		if(typeof(child) != "undefined" && child != 0)
		{
	
			if(type=='air')
			{
	
				for (var i=0; i<child; i++)
				{				
					
					var selectBox = eval("form.minorsAge" + i);
					
					if(selectBox.selectedIndex == 0)
					{
						change('warn', "warning");				
						childrenBox.style.display = "block";
						blnPass = false;
					}
					
				}
				
			}
			else
			{
				
				for (var i=1; i<=child; i++)
				{				
					
					var selectBox = eval("form.minorsAge" + i);
					
					if(selectBox.selectedIndex == 0)
					{
						change('warn',"warning");				
						childrenBox.style.display = "block";
						blnPass = false;
					}
					
				}	
							
			}
			
		}	
			
	}
	
	if (type == 'lmd' || type == 'lastminute')
	{	
	
		if (toDestination.selectedIndex == 0)
		{
			change('warn', 'warning');
			blnPass = false;		
		}
	
		if (destinationCity.selectedIndex == 0)
		{
			change('warn2', 'warning');
			blnPass = false;		
		}

	}
	else
	{
		
		if(type != "air")
		{

			if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy" || chk_outVal == "" || chk_outVal == validateError.dateError || chk_outVal == "mm/dd/yyyy")
			{
				change(form.chk_in, "formWarning");
				change(form.chk_out, "formWarning");
				form.chk_in.value = validateError.dateError;
				form.chk_out.value = validateError.dateError;
				blnPass = false;
			}
			
		}
		
	}
		
if(type == 'car' || type == 'car_fd')
{ 
	
		if (pucityVal == "" || pucityVal == validateError.cityError) 
		{
			change("pucity", "formWarning");
			form.pucity.value=validateError.cityError;
			blnPass = false;
		}

}

	return blnPass;

}

function displayages(childobj)
{	

	var	minorsAge = YAHOO.util.Dom.getElementsByClassName("minorsAge", "select", searchType + "_frame");
	var childAgeContainer = getChildrenBox();

	if (childobj.options[0].selected)
	{
		hide(childAgeContainer); 
		hide(minorsAge[0]); 
		hide(minorsAge[1]); 
		hide(minorsAge[2]); 
		hide(minorsAge[3]);
	}
	
	if (childobj.options[1].selected)
	{
		show(childAgeContainer); 
		showInline(minorsAge[0]); 
		hide(minorsAge[1]); 
		hide(minorsAge[2]); 
		hide(minorsAge[3]);
	}
	
	if (childobj.options[2].selected)
	{
		show(childAgeContainer); 
		showInline(minorsAge[0]); 
		showInline(minorsAge[1]); 
		hide(minorsAge[2]); 
		hide(minorsAge[3]);
	}
	
	if (childobj.options[3].selected)
	{
		show(childAgeContainer); 
		showInline(minorsAge[0]); 
		showInline(minorsAge[1]); 
		showInline(minorsAge[2]); 
		hide(minorsAge[3]);
	}
	
	if (childobj.options[4].selected)
	{
		show(childAgeContainer); 
		showInline(minorsAge[0]); 
		showInline(minorsAge[1]); 
		showInline(minorsAge[2]); 
		showInline(minorsAge[3]);
	}
	
}

function addEvent(obj, evType, fn)
{

	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, false);
		return true;
	} 
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else 
	{
		return false;
	}
	
}

function removeEvent(obj, evType, fn, useCapture)
{

	if (obj.removeEventListener)
	{
		obj.removeEventListener(evType, fn, useCapture);
		return true;
	} 
	else if (obj.detachEvent)
	{
		var r = obj.detachEvent("on"+evType, fn);
		return r;
	} 
	else 
	{
		alert("Handler could not be removed");
	}
	
}

function getViewportHeight() 
{
	
	if (window.innerHeight != window.undefined) 
	{
		alert(window.innerHeight);
		alert("a");
		return window.innerHeight;
	}
	
	if (document.compatMode == 'CSS1Compat') 
	{
		alert(document.documentElement.clientHeight);
		alert("b");		
		return document.documentElement.clientHeight;
	}
	
	if (document.body) 
	{
		alert(document.body.clientHeight);
		alert("c");		
		return document.body.clientHeight;
	}
	
	return window.undefined; 
	
}

function getViewportWidth() 
{

	if (window.innerWidth != window.undefined) 
	{
		return window.innerWidth;
	}
	
	if (document.compatMode == 'CSS1Compat') 
	{
		return document.documentElement.clientWidth;
	}

	if (document.body) 
	{
		return document.body.clientWidth;
	}

	return window.undefined; 
	
}

var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;
var gHideSelects = false;
var gTabIndexes = new Array();
var gTabbableTags = new Array("A", "BUTTON", "TEXTAREA", "INPUT");	

if (!document.all) 
{
	document.onkeypress = keyDownHandler;
}

function initPopUp() 
{
		
	theBody = document.getElementsByTagName('form')['AirSearch'];
	popmask = document.createElement('div');
	popmask.id = 'popupMask';
	popcont = document.createElement('div');
	popcont.id = 'popupContainer';
	
	popcont.innerHTML = '' +
		'<div id="popupInner">' +
			'<div id="popupTitleBar">' +
				'<div id="popupTitle"></div>' +
				'<div id="popupControls" ></div>' +
			'</div>' +
			'<div id="popupFrame" name="popupFrame"></div>' +
		'</div>';
		
	theBody.appendChild(popmask);
	theBody.appendChild(popcont);

	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popupContainer");
	gPopFrame = document.getElementById("popupFrame");	
	gPopControl = document.getElementById("popupControls");

	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);

	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) 
	{
		gHideSelects = true;
	}
	
	// Add onclick handlers to 'a' elements of class submodal or submodal-width-height-div
	var elms = document.getElementsByTagName('a');
	
	for (i = 0; i < elms.length; i++) 
	{
	
		if (elms[i].className.indexOf("submodal") == 0) 
		{ 
			
			elms[i].onclick = function()
			{
		
				var width = 400;
				var height = 200;
				var popupDiv;
			
				params = this.className.split('-');
				
				if (params.length == 3) 
				{
					width = parseInt(params[1]);
					height = parseInt(params[2]);
				}
				
				if (params.length == 4) 
				{
					width = parseInt(params[1]);
					height = parseInt(params[2]);
					popupDiv = document.getElementById(params[3]);
				}
				
				showPopWin(popupDiv,width,height,null); return false;
				
			}
			
		}
		
	}
	
}

function showPopWin(divContainer, width, height, returnFunc) 
{

	if (typeof (divContainer) != "object")
	{
		divContainer = document.getElementById(divContainer);
	}
	
	gPopupIsShown = true;
	
	disableTabIndexes();

	gPopupMask.style.display = "block";
	gPopupContainer.style.display = "block";	
	
	setPopTitle();
	
	var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
	var popupControls =  15;
	
	setMaskSize();
	
	gPopupContainer.style.width = (width + 5 + popupControls) + "px"; 
	gPopupContainer.style.height = (titleBarHeight + height)+ "px"; 

	centerPopWin((width +5+popupControls), height);

	gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
	gPopFrame.style.height = (height) + "px";
	
	gReturnFunc = returnFunc;
	
	if (gHideSelects == true) 
	{
		hideSelectBoxes();
	}
	
	if (gPopFrame.innerHTML == "")
	{
		gPopFrame.innerHTML = divContainer.innerHTML;
	}
	alert(gPopFrame.innerHTML);
	gPopControl.innerHTML = document.getElementById("close-frame").innerHTML;

}

var gi = 0;

function centerPopWin(width, height) 
{

	if (gPopupIsShown == true) 
	{
		
		if (width == null || isNaN(width)) 
		{
			width = gPopupContainer.offsetWidth;
		}
		
		if (height == null) 
		{
			height = gPopupContainer.offsetHeight;
		}
		
		var theBody = document.getElementsByTagName("BODY")[0];
		
		theBody.style.overflow = "hidden";
		
		var scTop = parseInt(theBody.scrollTop, 10);
		var scLeft = parseInt(theBody.scrollLeft, 10);
		
		gPopupMask.style.top = scTop + "px";
		gPopupMask.style.left = scLeft + "px";
	
		setMaskSize();
		
		var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);		
		var fullHeight = 200; //getViewportHeight();
		var fullWidth = getViewportWidth();
	
		gPopupContainer.style.top = (scTop + ((fullHeight - (height + titleBarHeight)) / 2)) + "px";
		gPopupContainer.style.left = (scLeft + ((fullWidth - width) / 2)) + "px";

	}
	
}

addEvent(window, "resize", centerPopWin);

window.onscroll = centerPopWin;

function setMaskSize() 
{

	var theBody = document.getElementsByTagName("BODY")[0];			
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	
	if (fullHeight > theBody.scrollHeight) 
	{
		popHeight = fullHeight;
	} 
	else 
	{
		popHeight = theBody.scrollHeight
	}
	
	gPopupMask.style.height = popHeight + "px";
	gPopupMask.style.width = theBody.scrollWidth + "px";
	
}

function hidePopWin(callReturnFunc) 
{

	gPopupIsShown = false;	
	var theBody = document.getElementsByTagName("BODY")[0];	
	theBody.style.overflow = "";
	
	restoreTabIndexes();
	
	if (gPopupMask == null) 
	{
		return;
	}
	
	gPopupMask.style.display = "none";
	gPopupContainer.style.display = "none";
	
	if (callReturnFunc == true && gReturnFunc != null) 
	{
		gReturnFunc();
	}

	if (gHideSelects == true) 
	{
		displaySelectBoxes();
	}
	
}

function setPopTitle() 
{

	if (document.getElementById("title") == null) 
	{
		return null;
	} 
	else 
	{
		document.getElementById("popupTitle").innerHTML = document.getElementById("title").innerHTML;
	}
	
}

function keyDownHandler(e) 
{
    
	if (gPopupIsShown && e.keyCode == 9) 
	{
		return false;
	}
	
}

function disableTabIndexes() 
{

	if (document.all) 
	{
	
		var i = 0;
		
		for (var j = 0; j < gTabbableTags.length; j++) 
		{

			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			
			for (var k = 0 ; k < tagElements.length; k++) 
			{
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
			
		}
		
	}
	
}

function restoreTabIndexes() 
{
	
	if (document.all) 
	{
		
		var i = 0;
		
		for (var j = 0; j < gTabbableTags.length; j++) 
		{
		
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			
			for (var k = 0 ; k < tagElements.length; k++) 
			{
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
			
		}
		
	}
	
}


var selects = document.getElementsByTagName("select");

for (var i = 0; i < selects.length; i++)
{

	if (r.intersect(YAHOO.util.Dom.getRegion(selects[i])))
	{
		selects[i].style.visibility = "hidden";
		this.hiddenSelects.push(selects[i]);
	}
	
}

function hideSelectBoxes() 
{

	for (var i = 0; i < document.forms.length; i++) 
	{
		
		for (var e = 0; e < document.forms[i].length; e++)
		{

			if (document.forms[i].elements[e].tagName == "SELECT") 
			{
			
				if (document.forms[i].elements[e].name != "airlineSearchPref" &&
				    document.forms[i].elements[e].name != "classOfService" &&
				    document.forms[i].elements[e].name != "fareType")
				{					
					document.forms[i].elements[e].style.visibility="hidden";
				}
				
			}
			
		}
		
	}
	
}

function displaySelectBoxes() 
{

	for (var i = 0; i < document.forms.length; i++) 
	{
		
		for (var e = 0; e < document.forms[i].length; e++)
		{
			
			if(document.forms[i].elements[e].tagName == "SELECT") 
			{
				document.forms[i].elements[e].style.visibility="visible";
			}
			
		}
		
	}
	
}

function clearSearchForm(type, form)
{
	if(type == "rt")
	{

		form.nearbyAirports.checked = false;
		form.leavingFrom[0].value = "";
		change(form.leavingFrom[0], '');
		form.goingTo[0].value = '';
		change(form.goingTo[0], '');
		form.leavingDate.value = 'mm/dd/yyyy';		
		change(form.leavingDate, '');
		form.dateLeavingTime.options[form.dateLeavingTime.options.length-1].selected = true;
		form.departDateFlexibility.options[0].selected = true;
		form.returningDate.value = 'mm/dd/yyyy';
		change(form.returningDate, '');
		form.dateReturningTime.options[form.dateReturningTime.options.length - 1].selected = true;
		form.returnDateFlexibility.options[form.returnDateFlexibility.options.length - 1].selected = true;		

		for(var i = 0; i <= airCalArray.length - 1; i++)
		{	
			airCalArray[i].clear();
			change(airCalArray[i], '');
		}
		
	}
	
	if(type == "mc")	
	{
		
		form.leavingDate.value = 'mm/dd/yyyy';		
		form.returningDate.value = 'mm/dd/yyyy';

		for (i = 1; i <= 4; i++)
		{

			var flightNum = "flight" + i;
			var currFlight = document.getElementById(flightNum);
		    
			if (currFlight.style.display == 'block')
		    {
				var leavingFrom = eval("form.leavingFrom" + i);
				var goingTo = eval("form.goingTo" + i);
				leavingFrom.value = "";
				change(leavingFrom, '');
				goingTo.value = "";
				change(goingTo, '');
				var leavingDate = eval("form.leavingDate" + i);
				leavingDate.value = "mm/dd/yyyy";
				change(leavingDate, '');
				var leavingTime = eval("form.leavingTime" + i);
				leavingTime.options[leavingTime.options.length - 1].selected = true;

				if (multiCalArray[i]) 
				{
					multiCalArray[i].clear();
				}
				
		    }
			
		}
		
	}
	
	if(type == "ow")
	{

		form.leavingFrom[0].value = "";
		change(form.leavingFrom[0], '');
		form.goingTo[0].value = '';
		change(form.goingTo[0], '');
		form.leavingDate.value = 'mm/dd/yyyy';		
		change(form.leavingDate, '');
		form.returningDate.value = 'mm/dd/yyyy';
		airDodCal.clear();
		change(form.returningDate, '');
		form.nearbyAirports.checked = false;
	}
	
}

function changeAirSearchType(searchType,form)
{
	
	var form = document.getElementById(form);
	
	if(searchType == "rt")  // round trip type
	{
		hide('multiCityForm');
		hide('multi_city_add');		
		show('round_way');
		show('search_options1')
		show("chk_out_lbl");
		show(form.returningDate);
		show(form.dateReturningTime);
		form.flightType[0].checked = true;
	}
	else if (searchType == "mc")
	{
		hide('round_way');
		show('multiCityForm');
		show('multi_city_add');
		form.dateTypeSelect[0].checked = true;
		form.flightType[2].checked = true;	
	}
	else	// one way
	{
		hide('multiCityForm');
		hide('multi_city_add');
		show('round_way');
		hide('search_options1');
		hide("chk_out_lbl");
		hide(form.returningDate);
		hide(form.dateReturningTime);
		hide(form.returnDateFlexibility);		
		form.dateTypeSelect[0].checked = true;
		form.flightType[1].checked = true;		
	}		
	
	clearSearchForm(searchType,form);
	
}

function addFlight()
{
	
	for (i = 1; i <= 4; i++)
	{

		var flightNum = "flight" + i;
		var currFlight = document.getElementById(flightNum);
		var mainDiv = document.getElementById('multiCityForm');

		if (currFlight.style.display == 'none')
		{
			currFlight.style.display = 'block';

			currFlightHeight = currFlight.offsetHeight;	

			if (i == 4) 
			{
				hide('multi_city_add');
			}
				
			mainDiv.scrollTop += currFlightHeight;
			break;
			
		}	
			
	}	
	
}
				  
var bodyHeight = 0;

function resizeIframe(frameid)
{

	if(typeof(frameid) != "Object")
	{

		if(!frameid.match(/_frame/))
		{
			
			if (frameid == 'hotel') 
			{
				frameid = 'hotel_frame';
			}
			
			if (frameid == 'air') 
			{
				frameid = 'air_frame';
			}
			
			if (frameid == 'customtrip') 
			{
				frameid = 'airHotel_frame';
			}
			
			if (frameid == 'car') 
			{
				frameid = 'car_frame';
			}
			
			if (frameid == 'lmd') 
			{
				frameid = 'lmd_frame';
			}
			
			if (frameid == 'activities') 
			{
				frameid = 'attractions_frame';
			}
			
		}
		
		var currentfr = document.all ? document.all[frameid] : document.getElementById(frameid);		
		
	}
	
	var parentContainer = document.all ? document.all['multi_searchbox'] : document.getElementById('multi_searchbox');
	
	if (currentfr && parentContainer)
	{
		
		currentfr.style.display = "block";
		
		if (currentfr.contentDocument && parentContainer.offsetWidth&&currentfr.parentNode.offsetHeight) //ns6 syntax
		{
			
			if (bodyHeight == 0) 
			{
				bodyHeight = currentfr.parentNode.offsetHeight;
			}
				
			currentfr.width = parentContainer.offsetWidth;
			currentfr.height = bodyHeight;
			
		}
		else if (currentfr.Document && parentContainer.scrollWidth && currentfr.parentNode.scrollHeight) //ie5+ syntax
		{
			
			if (bodyHeight == 0) 
			{
				bodyHeight = currentfr.parentNode.scrollHeight;
			}
				
			currentfr.width = parentContainer.scrollWidth;
			currentfr.height = bodyHeight;
			
		}
		
	}
	
}

function clearStateCountry()
{
	
	try
	{
		document.getElementById('state').value = "";	
		document.getElementById('country').value = "";	
	}
	catch(e)
	{	
	}
	
}

function hideAll()
{
	hide('searchboxcruise');
	hide('searchboxresort');
	hide('searchboxair');
	hide('searchboxhotel');
	hide('searchboxcar');
	hide('searchboxairhotel');
}

function flip(idLayer)
{
	
	hideAll();
	
	if (idLayer =='searchboxcruise')
	{ 
		searchType = "cruise";
		show('searchboxcruise');
	}
	
	if (idLayer == 'searchboxresort') 
	{
		searchType = "resort";
		show('searchboxresort');
	}
	
	if (idLayer=='searchboxair')
	{
		searchType = "air";
		show('searchboxair');
	}
								
	if (idLayer=='searchboxhotel')
	{
		searchType = "hotel";
		show('searchboxhotel');
	}
	
	if (idLayer=='searchboxcar')
	{
		searchType = "car";
		show('searchboxcar');
	}
	
	if (idLayer=='searchboxairhotel')
	{
		searchType = "airHotel";
		show('searchboxairhotel');
	}
	
	
}
