<!---

function _initialize() 
{
	if (typeof pageInit == "function")
            { 
             pageInit();
           // javascript:popUp('http://www.etravelprotection.com/servlet/WASCPure?accam=F028843'); 
             }


}



function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=500,left =0 ,top =0 ');"); 
}



function toggleMenu (curMenu, imgNum) {
    if (!document.getElementById)
	{
		//browser doesn't support this object
		return false;
	}

	var thisMenu = new Object(document.getElementById(curMenu));
	var imgUrl;

	if (thisMenu.style.display == "block") {
		thisMenu.style.display = "none";
		//thisMenu.style.src = "/marketing/images/plus.gif";
		imgUrl = "/marketing/images/plus.gif";
	}
	else {
		thisMenu.style.display = "block";
		imgUrl = "/marketing/images/minus.gif";
		//thisMenu.style.src = "/marketing/images/minus.gif";
	}

	document.getElementById(imgNum).src = imgUrl;
	return false;
}


function processRadio(blockName)
{	
	var thisMenu = new Object(document.getElementById(blockName))
    if (blockName == "0")
    {
       var thisMenu = new Object(document.getElementById("return1"))
       thisMenu.style.display = "none" 	   
    }
    else
    {
       var thisMenu = new Object(document.getElementById("return1"))
       thisMenu.style.display = "block"
    }
}


function toggleMenu2(formItem)
{	
	var ref=formItem.options[formItem.selectedIndex].value

    if (ref == "1")
    {
       var thisMenu = new Object(document.getElementById("return1"))
       thisMenu.style.display = "none"
	   var thisMenu = new Object(document.getElementById("return2"))
       thisMenu.style.display = "none"
    }
    else
    {
       var thisMenu = new Object(document.getElementById("one"))
       if(thisMenu.style.display == "none") {
	   		var thisMenu = new Object(document.getElementById("return2"))
       		thisMenu.style.display = "block"
	   }
	   else {
	   		var thisMenu = new Object(document.getElementById("return1"))
       		thisMenu.style.display = "block"
	   }
    }
}


function _showAges(formItem)
{	
    if (formItem.value != "0") {
		var ref=formItem.options[formItem.selectedIndex].value;
	} else {
		var ref="0";
	}

    if (ref > "0")
    {
       	var thisMenu = new Object(document.getElementById("childAge"))
       	thisMenu.style.display = "block"	   
    }
    else
    {
		var thisMenu = new Object(document.getElementById("childAge"))
       	thisMenu.style.display = "none"	
    }		
}


/* check to see if the departure city is the same as the arrival city */
function check_port (curVal, thisCity, otherCity)
{
	var selectOptions = document.getElementById(otherCity).options;
	var otherCityCode = selectOptions[selectOptions.selectedIndex].value;
	selectOptions = document.getElementById(thisCity).options;
	var thisCityCode = selectOptions[selectOptions.selectedIndex].value;
	var i = 0;
	
	if (otherCityCode == curVal)
	{
		alert('Departure city and arrival city cannot be the same.\nPlease select a different city.');
		document.getElementById(thisCity).options.selectedIndex = 0;
	}
	else
	{
		if (thisCity == 'departfrom' && thisCityCode == 'EVR')
		{
			selectOptions = document.getElementById(otherCity).options;
			for (i=0; i<selectOptions.length; i++)
			{
				if (selectOptions[i].value == 'FRI') { document.getElementById(otherCity).options.selectedIndex = i; }
			}
		}
		else if (thisCity == 'arrivefrom' && otherCityCode == 'EVR' && thisCityCode != 'FRI')
		{
			alert('Your destination must be Friday Harbor if your departure is Everett, WA');
			
			selectOptions = document.getElementById(thisCity).options;
			for (i=0; i<selectOptions.length; i++)
			{
				if (selectOptions[i].value == 'FRI') { document.getElementById(thisCity).options.selectedIndex = i; }
			}
		}
	}
}


function qs() {
	var query = top.location.search.substring(1);
	var parms = query.split('&');
	var thisArray = new Array();
	for (var i=0; i<parms.length; i++) {
	   var pos = parms[i].indexOf('=');
	   if (pos > 0) {
	      var key = parms[i].substring(0,pos);
	      var val = parms[i].substring(pos+1);
	      thisArray[key] = val;
      }
   }
   return thisArray;
}


function showValidRoutes(productRouteArray, formInputOrigin, formInputDestination, firstUpdate) {
	var locations;
	var originCity = "";
	var counter = 0;
	var operatorParm = "";
	var originList = "";
	var destList = "";
	var thisCode = "";
	var defaultOrigin = "";

	// arrays built in routeArray.jsp, which outputs to routeArray.js

	// array values per row:
	// [0] - origin
	// [1] - sequence (used for sort() in routeArray.js)
	// [2] - destination
	// [3] - product code (actually operator, since we're looking for package/trans products)
	// [4] - valid dates (pairs separated by |, dates separated by :)

	// SEA is selected by default for origin dropdown
	defaultOrigin = "SEA";

	// check to make sure the origin dropdown box exists
	 
	var el = eval("document.getElementById('"+formInputOrigin+"').options");
	if ((typeof el == 'object') && (el != null)) {
		if (formInputOrigin == 'resort') { 
			// might need more Err handling
			// this is for hotel upsell from a transportation search, might be better way to grab element
			defaultOrigin = document.getElementsByName('destPort')[0].value;
		}
		else {
			// all other cases
			originCity = document.getElementById(formInputOrigin).value;
		}
	}
	else {
		// if we're here, the dropdown doesn't exist
		return;
	}

	
	// if an operator is specified, limit the origin and destination values to only products using that operator
	if (qsParm['operator'] != null) {
		operatorParm = qsParm['operator'];
	}

	// edit origin select when the page loads, but never again
	if (firstUpdate == 1) {
		document.getElementById(formInputOrigin).length = 0;
	
		for (var i=0; i<productRouteArray.length; i++) {
			locations = productRouteArray[i].split(';');
			thisCode = locations[0];

			// if no specified operator, or this entry uses the right operator, and we haven't already added it, then add it
			if (((operatorParm == "") || (locations[3].indexOf(operatorParm) >= 0)) && (originList.indexOf(thisCode) < 0)) {
				if (thisCode == defaultOrigin) {
					document.getElementById(formInputOrigin).options[counter] = new Option(nameArray[thisCode], thisCode, true, true);
				}
				else {
					document.getElementById(formInputOrigin).options[counter] = new Option(nameArray[thisCode], thisCode, false, false);
				}
				counter++;
				originList = originList + ";" + thisCode;
			}
		}
	}

	counter = 0;

	if (formInputDestination != '') {
		// create destination select
		document.getElementById(formInputDestination).length = 0;
		// if this is a Package search, add a default "optional" element to the destination dropdown
		if (formInputOrigin == 'departCity') {
			document.getElementById(formInputDestination).options[0] = new Option("- Optional -", "", false, false);
			counter++;
		}
	
		for (var i=0; i<productRouteArray.length; i++) {
			locations = productRouteArray[i].split(';');
			thisCode = locations[2];
	
			// if no specified operator, or this entry uses the right operator, and we haven't already added it, then add it
			if (((operatorParm == "") || (locations[3].indexOf(operatorParm) >= 0)) && (destList.indexOf(thisCode) < 0)) {
				if (originCity != '') {
					if (locations[0] == originCity) {
						document.getElementById(formInputDestination).options[counter] = new Option(nameArray[thisCode], thisCode, false, false);
						destList = destList + ";" + thisCode;
						counter++;
					}
				}
				else {
					document.getElementById(formInputDestination).options[counter] = new Option(nameArray[thisCode], thisCode, false, false);
					destList = destList + ";" + thisCode;
					counter++;
				}
			}
		}
	}

}
function cleanCodes(form) {
	//This function makes sure any promotional or affiliate codes that are
	//entered are in the correct format.
	var tmpstring;
	if (typeof form.promotion_code != "undefined") {
	  if (form.promotion_code.value != "") {
        	tmpstring=form.promotion_code.value;
        	tmpstring=tmpstring.toUpperCase();
        	form.promotion_code.value=tmpstring;
	  }
	}
	if (typeof form.npoCode != "undefined") {	
	  if (form.npoCode.value != "") {
		tmpstring=form.npoCode.value;
		tmpstring=tmpstring.toUpperCase();
		form.npoCode.value=tmpstring;
	  }
	}
}


//--->
