 
// this file will keep the methods implemented in order to display the instant sailings counter
var g_currentZone	= "1";
var parentZone		= "1";
var g_defaultVnd	= "-1";
var MonthsArray		= null;
var g_currentVendor;
var g_currentShip;
var g_currentPort;
var g_currentMonth;
var g_currentLength;

/**
*
* 
*/
function OnStartupZonesLoad(ZoneDropDownID)
{	
	var cbZonesDropDown		= getElement(ZoneDropDownID);
	var zonesArray			= eval("ArrayDestObjects");
	FillCombo2(cbZonesDropDown, zonesArray);
	SetDefaultSelection(cbZonesDropDown, g_currentZone);
}

/*
*
*
*/
function FillCombo2(cb, arrayObjects)
{
	for(var i=0; i<arrayObjects.length; i++)
	{
		var oOption				= new Option(arrayObjects[i].Name, arrayObjects[i].ID)
		cb.options[cb.length]	= oOption;
	}
}

/**
*
* 
*/
function LoadVendorsStartup(vVndID, vShipID, vMonthID, vLengthID, vLabelID, parent)
{
	cbVnd			= getElement(vVndID);
	cbShip			= getElement(vShipID);
	cbMonth			= getElement(vMonthID);
	cbLength		= getElement(vLengthID);
	label			= getElement(vLabelID);
	
	var VndArray	= eval('ArrVndObj');
	
	if(VndArray  == null || (VndArray != null && VndArray.length == 0))
	{
		var oOption							= new Option(allCruiselines, "-1")
		cbVnd.options[cbVnd.length]			= oOption;
		oOption								= new Option(showAll, "-1")
		cbMonth.options[cbMonth.length]		= oOption;
		oOption								= new Option(showAll, "0|999")
		cbLength.options[cbLength.length]	= oOption;
		if(label != null)
		{
			label.innerHTML					= notFound;
		}
		return;
	}
	
	FillCombo2(cbVnd, VndArray);
	if(g_currentVendor != null)
	{
		SetDefaultSelection(cbVnd, g_currentVendor);
	}
	// fill Ships Drop Down
	VndDropDownChanged(vVndID, vShipID, vMonthID, vLengthID, vLabelID);
}

/**
*
* 
*/
function VndDropDownChanged(vVndID, vShipID, vMonthID, vLengthID, vLabelID)
{
	var cbVnd		= getElement(vVndID);
	var cbShip		= getElement(vShipID);
	var cbMonth		= getElement(vMonthID);
	var cbLength	= getElement(vLengthID);
	var label		= getElement(vLabelID);

	var VndSel		= cbVnd.value;
	VndArray		= eval('ArrVndObj');
	
	if(VndArray==null)
	{
		alert('Vendors array is NULL');
		return;
	}
	
	// fill Ships drop Down
	ClearCombo(cbShip);
	AddAllOption(cbShip, allShips);
	
	if(cbVnd.value == -1)
	{
		//load all vendors
		var arrShips = new Array();
		for(var j=0;j<VndArray.length;j++)
		{
			arrShips = arrShips.concat(VndArray[j].ShipArray);
		}
		arrShips.sort(SortAlphabetically);
		FillCombo2(cbShip, arrShips);
		if(g_currentShip != null)
		{
			setDefaultSelection(cbShip, g_currentShip);
		}
	}else
	{
		for(var j=0; j<VndArray.length; j++)
		{
			if(VndArray[j].ID == cbVnd.value)
			{
				var arrShips = VndArray[j].ShipArray;
				FillCombo2(cbShip, arrShips);
				if(g_currentShip != null)
				{
					setDefaultSelection(cbShip, g_currentShip);
				}
				break;
			}
		}
	}

	LoadMonthsStartup(vMonthID, vLengthID, vLabelID, parentZone)
}

/**
*
* 
*/
function LoadMonthsStartup(vMonthID, vLengthID, vLabelID, parent)
{
	cbMonth		= getElement(vMonthID);
	cbLength	= getElement(vLengthID);
	label		= getElement(vLabelID);
	
	for(var idx = 0; idx < VndArray.length; idx++)
	{
		if(VndArray[idx].ID == cbVnd.value)
		{
			MonthsArray = VndArray[idx].Months;
			break;
		}
	}
	
	if(MonthsArray  == null || (MonthsArray != null && MonthsArray.length==0))
	{
		ClearCombo(cbMonth);
		ClearCombo(cbLength);
		
		var oOption							= new Option(showAll, "")
		cbMonth.options[cbMonth.length]		= oOption;
		oOption								= new Option(showAll, "0|999")
		cbLength.options[cbLength.length]	= oOption;
		if(label != null)
		{
			label.innerHTML					= notFound;
		}
		return;
	}
	
	var date	= new Date();
	var month	= date.getMonth() + 1;
	date.setMonth(month);
	month		=  month + 2;

	if (month == '13')
	{
	    month = 1;
        date.setFullYear(eval(parseInt(date.getFullYear()) + 1));
	}
	    
	if (month == '14')
	{
	    month = 2;
        
	}
	
	var strSelDate= month + "/1/" + date.getFullYear();	
	if(g_currentMonth != null && g_currentMonth != "")
	{
		strSelDate = g_currentMonth;	
	}
	
	ClearCombo(cbMonth);
	MonthsArray.sort(SortMonth);
	FillCombo2(cbMonth, MonthsArray);
	SetDefaultSelection(cbMonth, strSelDate);
	
	// fill day drop down 
	var arrDays = MonthsArray[0].days;
	for(var idx=0; idx < MonthsArray.length; idx++)
	{
		if(cbMonth.value == MonthsArray[idx].ID)
		{
			arrDays = MonthsArray[idx].days;
		}
	}

	ClearCombo(cbLength);
	FillLengthCombo(cbLength, arrDays);	
	if(parent == "1" && (g_currentLength == null || g_currentLength == "")) // set default 6|9 for Caribbean
	{
		SetDefaultSelection(cbLength, "0|999");
	}

	if(g_currentLength != null && g_currentLength  != "")
	{
		SetDefaultSelection(cbLength, g_currentLength);
	}
				
	LengthDropDownChanged(vMonthID, vLengthID, vLabelID)
}

/**
*
* 
*/
function MonthDropDownChanged(vMonthID, vLengthID, vLabelID, vParent)
{
	cbMonth		= getElement(vMonthID);
	cbLength	= getElement(vLengthID);
	label		= getElement(vLabelID);
	if(MonthsArray  == null || (MonthsArray != null && MonthsArray.length==0))
	{
		var oOption							= new Option(showAll, "")
		cbMonth.options[cbMonth.length]		= oOption;
		oOption								= new Option(showAll, "0|999")
		cbLength.options[cbLength.length]	= oOption;
		if(label != null)
		{
			label.innerHTML					= notFound;
		}
		return;
	}
	
	var month		= cbMonth.options[cbMonth.selectedIndex];	
	var monthSel	= month.value;
	
	for(var idx=0; idx < MonthsArray.length; idx++)
	{
		if(monthSel == MonthsArray[idx].ID)
		{
			ClearCombo(cbLength);
			FillLengthCombo(cbLength, MonthsArray[idx].days);
			if(vParent == 1 && (g_currentLength == null || g_currentLength == "")) // set default 6|9 for Caribbean
			{
				
			}
			
			if(g_currentLength != null && g_currentLength  != "")
			{
				SetDefaultSelection(cbLength, g_currentLength);
			}
			
			LengthDropDownChanged(vMonthID, vLengthID, vLabelID)
			break;
		}
	}
}

/**
*
* 
*/
function LengthDropDownChanged(vMonthID, vLengthID, vLabelID)
{
	if(MonthsArray == null)
	{
		alert("months array null");
		return;
	}
	
	cbMonth		= getElement(vMonthID);
	cbLength	= getElement(vLengthID);
	label		= getElement(vLabelID);
	
	var month		= cbMonth.options[cbMonth.selectedIndex];	
	var monthSel	= month.value;
	
	var dayLength	= cbLength.options[cbLength.selectedIndex];	
	var dayLengthSel= dayLength.value;
	for(var idx=0; idx < MonthsArray.length; idx++)
	{
		if(monthSel == MonthsArray[idx].ID)
		{
			var DaysArray	= MonthsArray[idx].days;
			for(var dayIdx=0; dayIdx < DaysArray.length; dayIdx++)
			{
				if(dayLengthSel == DaysArray[dayIdx].ID)
				{
					if(DaysArray[dayIdx].total == 0)
					{
						if(label != null){
							label.innerHTML	= "No " + sailings + " " + found;
						}
					}else if(DaysArray[dayIdx].total == 1)
					{
						if(label != null){
							label.innerHTML	= "<b><font color='#CC0000'>" + DaysArray[dayIdx].total + "</font></b>" +  " " + sailing + " " + found;
						}
					}else
					{
						if(label != null){
							label.innerHTML	= "<b><font color='#CC0000'>" + DaysArray[dayIdx].total + "</font></b>" + " " + sailings + " " + found;
						}
					}
					break;
				}
			}
			break;
		}
	}
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

	qs = qs.replace(/\+/g, ' ') //// Turn <plus> back to <space>
	var args = qs.split('&') // parse out name/value pairs separated via &
	
	// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (name == 'home')
        {
            if (pair.length == 2)
		        value = unescape(pair[1])
		    else if (pair.length == 3)
		        value = unescape(pair[1]) + "=" + unescape(pair[2])
        }
	    else if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

function SendStatePortSearch(strFile, target)
{
	var strUrl		= strFile;
	var cbSkin		= getElement("Skin");
	var cbPIN		= getElement("PIN");
	var cbPhone		= getElement("Phone");
	var cbHome		= getElement("Home");
	var cbLID		= getElement("LID");
	
	if (cbSkin == null)
	{
		cbSkin = getElement("AG");
		if (cbSkin == null)
	    {
		    cbSkin = getElement("ClientID");
	    }
	}
	if (cbSkin != null && cbSkin.value != '' && cbSkin.value != null)
    {
        var skinId = escape(cbSkin.value);
	    if (skinId.length == 1)
	    {
	        skinId = "00" + skinId;
	    }
	    else if (skinId.length == 2)
	    {
	        skinId = "0" + skinId;
	    }
        var arrURL = strURL.split('?');
        if (arrURL.length == 1)
            strURL += "?Skin=" + skinId;
        else
            strURL += "&Skin=" + skinId;
    }
    
	Querystring(null);
	
	if (cbPIN != null && cbPIN.value!='' && cbPIN.value!=null)
    {
        var arrURL=strURL.split('?');
        if(arrURL.length==1)
        strURL += "?PIN="+escape(cbPIN.value);
        else
        strURL += "&PIN="+escape(cbPIN.value);
    }
    else if (Querystring_get('pin', null) != null)
	{
	    var arrURL=strURL.split('?');
        if(arrURL.length==1)
        strURL += "?PIN="+Querystring_get('pin', null);
        else
        strURL += "&PIN="+Querystring_get('pin', null);
	}
    
    if (cbPhone != null && cbPhone.value!='' && cbPhone.value!=null)
    {
        var arrURL=strURL.split('?');
        if (arrURL.length==1)
        strURL += "?Phone="+escape(cbPhone.value);
        else if (strURL.indexOf("Phone=") < 0)
        strURL += "&Phone=" + escape(cbPhone.value);
    }
    else if (Querystring_get('phone', null) != null)
	{
	    var arrURL=strURL.split('?');
        if (arrURL.length==1)
        strURL += "?Phone="+Querystring_get('phone', null);
        else if (strURL.indexOf("Phone=") < 0)
        strURL += "&Phone=" + Querystring_get('phone', null);
	}
    
    if (cbLID != null && cbLID.value!='' && cbLID.value!=null)
    {
        var arrURL=strURL.split('?');
        if(arrURL.length==1)
        strURL += "?LID="+escape(cbLID.value);
        else
        strURL += "&LID="+escape(cbLID.value);
    }
    else if (Querystring_get('lid', null) != null)
	{
	    var arrURL=strURL.split('?');
        if(arrURL.length==1)
        strURL += "?LID="+Querystring_get('lid', null);
        else
        strURL += "&LID="+Querystring_get('lid', null);
	}
    
	strUrl   += "&HP=true&CT=4";
		
	if (Querystring_get('vendor', null) != null)
	{
	    var arrURL=strUrl.split('?');
        if(arrURL.length==1)
        strUrl += "?vendor="+ Querystring_get('vendor', null);
        else
        strUrl += "&vendor="+ Querystring_get('vendor', null);
	}
	
	if (Querystring_get('bestdeal', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?BestDeal=" + Querystring_get('bestdeal', null);
        else
            strUrl += "&BestDeal=" + Querystring_get('bestdeal', null);
	}
	
	if (Querystring_get('so', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?SO=" + Querystring_get('so', null);
        else
            strUrl += "&SO=" + Querystring_get('so', null);
	}
	
	if (Querystring_get('eo', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?EO=" + Querystring_get('eo', null);
        else
            strUrl += "&EO=" + Querystring_get('eo', null);
	}
	
	if (Querystring_get('sn', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?SN=" + Querystring_get('sn', null);
        else
            strUrl += "&SN=" + Querystring_get('sn', null);
	}
	
	if (Querystring_get('mt', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?MT=" + Querystring_get('mt', null);
        else
            strUrl += "&MT=" + Querystring_get('mt', null);
	}
	
	if (Querystring_get('pp', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?PP=" + Querystring_get('pp', null);
        else
            strUrl += "&PP=" + Querystring_get('pp', null);
	}
	
	if (Querystring_get('st1', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?ZP1=" + Querystring_get('st1', null);
        else
            strUrl += "&ZP1=" + Querystring_get('st1', null);
	}
	
	if (Querystring_get('pc', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?PC=" + Querystring_get('pc', null);
        else
            strUrl += "&PC=" + Querystring_get('pc', null);
	}
	
	if (Querystring_get('cd', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CD=" + Querystring_get('cd', null);
        else
            strUrl += "&CD=" + Querystring_get('cd', null);
	}
	else if (Querystring_get('did', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CD=" + Querystring_get('did', null);
        else
            strUrl += "&CD=" + Querystring_get('did', null);
	}
	
	if (Querystring_get('cp', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CP=" + Querystring_get('cp', null);
        else
            strUrl += "&CP=" + Querystring_get('cp', null);
	}
	else if (Querystring_get('pid', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CP=" + Querystring_get('pid', null);
        else
            strUrl += "&CP=" + Querystring_get('pid', null);
	}
	else if (Querystring_get('ports', null) != null && Querystring_get('ports', null).toUpperCase() != 'Y' 
	    && Querystring_get('ports', null).toUpperCase() != 'N')
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CP=" + Querystring_get('ports', null);
        else
            strUrl += "&CP=" + Querystring_get('ports', null);
	}
	
	if (Querystring_get('csp', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CSP=" + Querystring_get('csp', null);
        else
            strUrl += "&CSP=" + Querystring_get('csp', null);
	}
	else if (Querystring_get('sid', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CSP=" + Querystring_get('sid', null);
        else
            strUrl += "&CSP=" + Querystring_get('sid', null);
	}
	else if (Querystring_get('ships', null) != null && Querystring_get('ships', null).toUpperCase() != 'Y' 
	    && Querystring_get('ships', null).toUpperCase() != 'N')
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CSP=" + Querystring_get('ships', null);
        else
            strUrl += "&CSP=" + Querystring_get('ships', null);
	}
	
	if (Querystring_get('cst', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CST=" + Querystring_get('cst', null);
        else
            strUrl += "&CST=" + Querystring_get('cst', null);
	}
	else if (Querystring_get('sort', null) != null && Querystring_get('sort', null).toUpperCase() != 'Y' 
	    && Querystring_get('sort', null).toUpperCase() != 'N')
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CST=" + Querystring_get('sort', null);
        else
            strUrl += "&CST=" + Querystring_get('sort', null);
	}
	
	if (Querystring_get('cl', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CL=" + Querystring_get('cl', null);
        else
            strUrl += "&CL=" + Querystring_get('cl', null);
	}
	else if (Querystring_get('len', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CL=" + Querystring_get('len', null);
        else
            strUrl += "&CL=" + Querystring_get('len', null);
	}
	
	if (Querystring_get('cv', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CV=" + Querystring_get('cv', null);
        else
            strUrl += "&CV=" + Querystring_get('cv', null);
	}
	else if (Querystring_get('lid', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CV=" + Querystring_get('lid', null);
        else
            strUrl += "&CV=" + Querystring_get('lid', null);
	}
	
	if (Querystring_get('df', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?DF=" + Querystring_get('df', null);
        else
            strUrl += "&DF=" + Querystring_get('df', null);
	}
	
	if (Querystring_get('dt', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?DT=" + Querystring_get('dt', null);
        else
            strUrl += "&DT=" + Querystring_get('dt', null);
	}
	
	if (Querystring_get('parentag', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?ParentAG=" + Querystring_get('parentag', null);
        else
            strUrl += "&ParentAG=" + Querystring_get('parentag', null);
	}
	
	if (Querystring_get('pageno', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?PageNo=" + Querystring_get('pageno', null);
        else
            strUrl += "&PageNo=" + Querystring_get('pageno', null);
	}
	else if (Querystring_get('pg', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?PageNo=" + Querystring_get('pg', null);
        else
            strUrl += "&PageNo=" + Querystring_get('pg', null);
	}
	
	if (Querystring_get('template', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?Template=" + Querystring_get('template', null);
        else
            strUrl += "&Template=" + Querystring_get('template', null);
	}
	
	if (Querystring_get('logo', null) != null && Querystring_get('logo', null) != '0')
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?Logo=" + Querystring_get('logo', null);
        else
            strUrl += "&Logo=" + Querystring_get('logo', null);
	}
	
	if (Querystring_get('look', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?Look=" + Querystring_get('look', null);
        else
            strUrl += "&Look=" + Querystring_get('look', null);
	}
	
	if (Querystring_get('includeofflinevendors', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?IncludeOfflineVendors=" + Querystring_get('includeofflinevendors', null);
        else
            strUrl += "&IncludeOfflineVendors=" + Querystring_get('includeofflinevendors', null);
	}
	
	if (Querystring_get('grouponly', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?GroupOnly=" + Querystring_get('grouponly', null);
        else
            strUrl += "&GroupOnly=" + Querystring_get('grouponly', null);
	}
	
	if (Querystring_get('adv', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?ADV=" + Querystring_get('adv', null);
        else
            strUrl += "&ADV=" + Querystring_get('adv', null);
	}	
	
	if (Querystring_get('psl', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?PSL=" + Querystring_get('psl', null);
        else
            strUrl += "&PSL=" + Querystring_get('psl', null);
	}
	
	if (Querystring_get('branch', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?Branch=" + Querystring_get('branch', null);
        else
            strUrl += "&Branch=" + Querystring_get('branch', null);
	}
	
	if (Querystring_get('cmpcruises', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CmpCruises=" + Querystring_get('cmpcruises', null);
        else
            strUrl += "&CmpCruises=" + Querystring_get('cmpcruises', null);
	}
	
	if (Querystring_get('ms', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?MS=" + Querystring_get('ms', null);
        else
            strUrl += "&MS=" + Querystring_get('ms', null);
	}
	
	if (Querystring_get('cc', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if(arrURL.length == 1)
            strUrl += "?CC=" + Querystring_get('cc', null);
        else
            strUrl += "&CC=" + Querystring_get('cc', null);
	}
	
	//Home - MUST be the last QS param
	if (cbHome != null && cbHome.value!='' && cbHome.value != null)
    {
        var arrURL = strURL.split('?');
        if (arrURL.length == 1)
            strURL += "?Home=" + escape(cbHome.value);
        else
            strURL += "&Home=" + escape(cbHome.value);
    }
    if (Querystring_get('home', null) != null && strURL.indexOf('Home=') < 0)
	{
	    var arrURL = strURL.split('?');
        if (arrURL.length == 1)
            strURL += "?Home=" + Querystring_get('home', null);
        else
            strURL += "&Home=" + Querystring_get('home', null);
	}
		
	if (cbSkin.value == "132" || Querystring_get('nw', null) == 'true' || target == "_blank")
	{
		window.open(strUrl);
	}
	else
	{
		if (target && target == "_top")
		{
			window.top.location.href = strUrl;
		}
		else
		{
			window.parent.location.href = 'http://' + self.location.host + '/cs/' + strUrl;
		}
	}
}

/**
*
* 
*/
function SendState(strFile, target)
{
	var strUrl		= strFile + "?";
	var cbDest		= getElement("ZoneDropDown");
	var cbMonth		= getElement("DateDropDown");
	var cbLen		= getElement("LenDropDown");
	var cbVnd		= getElement("VndDropDown");
	var cbShp		= getElement("ShipsDropDown");
	var cbPort		= getElement("PortDropDown");
	var cbSort		= getElement("SortDropDown");
	var cbSenior	= getElement("lfChk55p");
	var cbSkin		= getElement("Skin");
	var cbRef		= getElement("Ref");
	var cbPIN		= getElement("PIN");	
	var cbMT		= getElement("lfChkUSM");
	var cbPP		= getElement("PastPassenger");
	var cbPC		= getElement("txtPromoCode");
	var cbZP1		= getElement("selResidency");
	var cbPhone		= getElement("Phone");
	var cbHome		= getElement("Home");
	var cbLID		= getElement("LID");
	var cbEO		= getElement("EO");
	var cbVendor	= getElement("vendor");
	var cbBestDeal	= getElement("bestdeal");
		
	if (cbSkin == null)
	{
		cbSkin = getElement("AG");
		if (cbSkin == null)
	    {
		    cbSkin = getElement("ClientID");
	    }
	}		
	if (cbSkin != null && cbSkin.value!='')
	{
	    var skinId = escape(cbSkin.value);
	    if (skinId.length == 1)
	    {
	        skinId = "00" + skinId;
	    }
	    else if (skinId.length == 2)
	    {
	        skinId = "0" + skinId;
	    }
	    strUrl   += "Skin=" + skinId;
	}
		
	Querystring(null);
		
	var DestName	= "";
	if (cbDest != null && cbDest.value != '' && cbDest.value != null)
    {
        strUrl   += "&CD="	+ cbDest.value;
    }
    else if (Querystring_get('cd', null) != null)
	{
	    strUrl += "&CD=" + Querystring_get('cd', null);
	}
	else if (Querystring_get('did', null) != null)
	{
	    strUrl += "&CD=" + Querystring_get('did', null);
	}
	// add destination name 
	if (DestName != null && DestName != "")
		strUrl   += "&CDN="	+ escape(DestName);
	
	if (cbPIN != null && cbPIN.value!='' && cbPIN.value!=null)
    {
        strURL += "&PIN="+escape(cbPIN.value);
    }
    else if (Querystring_get('pin', null) != null)
	{
	    strUrl += "&PIN=" + Querystring_get('pin', null);
	}
    
    if (cbPhone != null && cbPhone.value != '' && cbPhone.value != null && strURL.indexOf("Phone=") < 0)
    {
        strURL += "&Phone=" + escape(cbPhone.value);
    }
    else if (Querystring_get('phone', null) != null && strURL.indexOf("Phone=") < 0)
	{
	    strUrl += "&Phone=" + Querystring_get('phone', null);
	}
    
    if (cbLID != null && cbLID.value!='' && cbLID.value!=null)
    {
        strURL += "&LID="+escape(cbLID.value);
    }
    else if (Querystring_get('lid', null) != null)
	{
	    strUrl += "&LID=" + Querystring_get('lid', null);
	}
	
	if (cbMonth != null && cbMonth.value != '')
	{
	    strUrl   += "&DF="	+ escape(cbMonth.value);
	}
	else if (Querystring_get('df', null) != null)
	{
	    strUrl += "&DF=" + Querystring_get('df', null);
	}
	
	if (cbLen   != null && cbLen.value!='')
	{
	    strUrl   += "&CL="	+ escape(cbLen.value);
	}
	else if (Querystring_get('cl', null) != null)
	{
	    strUrl += "&CL=" + Querystring_get('cl', null);
	}
	else if (Querystring_get('len', null) != null)
	{
	    strUrl += "&CL=" + Querystring_get('len', null);
	}	
	
	if (cbVnd   != null && cbVnd.value!='')
	{
	    strUrl   += "&CV="	+ escape(cbVnd.value);
	}
	else if (Querystring_get('cv', null) != null)
	{
	    strUrl += "&CV=" + Querystring_get('cv', null);
	}
	else if (Querystring_get('vid', null) != null)
	{
	    strUrl += "&CV=" + Querystring_get('vid', null);
	}
	
	if (cbPort  != null && cbPort.value!='')
	{
	    strUrl   += "&CP="	+ escape(cbPort.value);
	}
	if (strUrl.indexOf('CP=') < 0)
	{
	    if (Querystring_get('cp', null) != null)
	    {
	        strUrl += "&CP=" + Querystring_get('cp', null);
	    }
	    else if (Querystring_get('pid', null) != null)
	    {
	        strUrl += "&CP=" + Querystring_get('pid', null);
	    }
	    else if (Querystring_get('ports', null) != null && Querystring_get('ports', null).toUpperCase() != 'Y'
	        && Querystring_get('ports', null).toUpperCase() != 'N')
	    {
	        strUrl += "&CP=" + Querystring_get('ports', null);
	    }
	}
	
	if (cbShp   != null && cbShp.value!='') 
	{
	    strUrl   += "&CSP=" + escape(cbShp.value)
	}
	if (strUrl.indexOf('CSP=') < 0)
	{
	    if (Querystring_get('csp', null) != null)
	    {
	        strUrl += "&CSP=" + Querystring_get('csp', null);
	    }
	    else if (Querystring_get('sid', null) != null)
	    {
	        strUrl += "&CSP=" + Querystring_get('sid', null);
	    }
	    else if (Querystring_get('ships', null) != null && Querystring_get('ships', null).toUpperCase() != 'Y'
	        && Querystring_get('ships', null).toUpperCase() != 'N')
	    {
	        strUrl += "&CSP=" + Querystring_get('ships', null);
	    }
	}
	
	if (cbSort != null && cbSort.value != null && cbSort.value != '-1' && cbSort.value != '')
	{
		strUrl   += "&CST=" + escape(cbSort.value); //escape(cbSort.value);
	}
	if (strUrl.indexOf('CST=') < 0)
	{
	    if (Querystring_get('cst', null) != null)
	    {
	        strUrl += "&CST=" + Querystring_get('cst', null);
	    }
	    else if (Querystring_get('sort', null) != null && Querystring_get('sort', null).toUpperCase() != 'Y'
	        && Querystring_get('sort', null).toUpperCase() != 'N')
	    {
	        strUrl += "&CST=" + Querystring_get('sort', null);
	    }
	}
		
	if (cbSenior!=null && cbSenior.type != "select-one")
	{
	    strUrl   += "&SN="	+ escape(cbSenior.checked);
	}
	if (Querystring_get('sn', null) != null && strUrl.indexOf("SN=") < 0)
	{
	    strUrl += "&SN=" + Querystring_get('sn', null);
	}
	
    if (cbMT != null && cbMT.type != "select-one")
    {        
        strUrl   += "&MT=" + escape(cbMT.checked);
    }
    if (Querystring_get('mt', null) != null && strUrl.indexOf("MT=") < 0)
	{
	    strUrl += "&MT=" + Querystring_get('mt', null);
	}

	if (cbPP != null && cbPP.type != "select-one" && cbPP.checked)
    {
        strUrl   += "&PP=Y";
    }
    if (Querystring_get('pp', null) != null && strUrl.indexOf("PP=") < 0)
	{
	    strUrl += "&PP=" + Querystring_get('pp', null);
	}
	
	if (cbPC != null && cbPC.value != '')
	{
	    strUrl   += "&PC="  + escape(cbPC.value);
	}
	if (Querystring_get('pc', null) != null && strUrl.indexOf("PC=") < 0)
	{
	    strUrl += "&PC=" + Querystring_get('pc', null);
	}
	
	if (cbZP1 != null && cbZP1.value != '')
	{
	    strUrl   += "&ZP1="  + escape(cbZP1.value);
	}
	if (Querystring_get('zp1', null) != null && strUrl.indexOf("ZP1=") < 0)
	{
	    strUrl += "&ZP1=" + Querystring_get('zp1', null);
	}	
	else if (Querystring_get('st1', null) != null && strUrl.indexOf("ZP1=") < 0)
	{
	    strUrl += "&ZP1=" + Querystring_get('st1', null);
	}
           
	if(cbEO != null && cbEO.type != "select-one") 
	{
	    strUrl   += "&EO="	+ escape(cbEO.checked);
	}	 
	else if (Querystring_get('eo', null) != null)
	{
	    strUrl += "&EO=" + Querystring_get('eo', null);
	}
	
	if(cbSO != null && cbSO.value != '') 
	{
	    strUrl   += "&SO="	+ escape(cbSO.value);
	}
	else if (Querystring_get('so', null) != null)
	{
	    strUrl += "&SO=" + Querystring_get('so', null);
	}
	
	if (cbRef  != null && cbRef.value != '')
	{
	    strUrl   += "&Ref="  + escape(cbRef.value);
	}
	else if (Querystring_get('ref', null) != null)
	{
	    strUrl += "&Ref=" + Querystring_get('ref', null);
	}
	    
    if(cbVendor != null && cbVendor.value!='')
    {
        strUrl   += "&vendor="  + escape(cbVendor.value);
    }
    else if (Querystring_get('vendor', null) != null)
	{
	    strUrl += "&Vendor=" + Querystring_get('vendor', null);
	}
    
    if (cbBestDeal != null && cbBestDeal.value != '')
    {
        strUrl   += "&BestDeal="  + escape(cbBestDeal.value);
    }
    else if (Querystring_get('bestdeal', null) != null)
	{
	    strUrl += "&BestDeal=" + Querystring_get('bestdeal', null);
	}
	
	if (Querystring_get('parentag', null) != null)
	{
	    strUrl += "&ParentAG=" + Querystring_get('parentag', null);
	}
	
	if (Querystring_get('pageno', null) != null)
	{
	    strUrl += "&PageNo=" + Querystring_get('pageno', null);
	}
	else if (Querystring_get('pg', null) != null)
	{
	    strUrl += "&PageNo=" + Querystring_get('pg', null);
	}
	
	if (Querystring_get('template', null) != null)
	{
	    strUrl += "&Template=" + Querystring_get('template', null);
	}
	
	if (Querystring_get('look', null) != null)
	{
	    strUrl += "&Look=" + Querystring_get('look', null);
	}
	
	if (Querystring_get('includeofflinevendors', null) != null)
	{
	    strUrl += "&IncludeOfflineVendors=" + Querystring_get('includeofflinevendors', null);
	}
	
	if (Querystring_get('grouponly', null) != null)
	{
	    strUrl += "&GroupOnly=" + Querystring_get('grouponly', null);
	}
	
	if (Querystring_get('adv', null) != null)
	{
	    strUrl += "&ADV=" + Querystring_get('adv', null);
	}
	
	if (Querystring_get('psl', null) != null)
	{
	    strUrl += "&PSL=" + Querystring_get('psl', null);
	}
	
	if (Querystring_get('logo', null) != null && Querystring_get('logo', null) != '0')
	{
	    strUrl += "&Logo=" + Querystring_get('logo', null);
	}
	
	if (Querystring_get('branch', null) != null)
	{
	    strUrl += "&Branch=" + Querystring_get('branch', null);
	}
			
	if (Querystring_get('cmpcruises', null) != null)
	{
	    strUrl += "&CmpCruises=" + Querystring_get('cmpcruises', null);
	}
	
	if (Querystring_get('ms', null) != null)
	{
	    strUrl += "&MS=" + Querystring_get('ms', null);
	}
	if (Querystring_get('cc', null) != null)
	{
	    strUrl += "&CC=" + Querystring_get('cc', null);
	}
	
	//Home - MUST be the last QS Param
	if (cbHome != null && cbHome.value != '')
    {
        strUrl   += "&Home=" + escape(cbHome.value);
    }	
    else if (Querystring_get('home', null) != null)
	{
	    strUrl += "&Home=" + Querystring_get('home', null);
	}
	
	if(cbSkin.value == "132" || Querystring_get('nw', null) == 'true' || target == "_blank")
    {
        window.open(strUrl);
    }
	else
	{
		if (target && target == "_top")
		{
			window.top.location.href = strUrl;
		}
		else
		{
			window.parent.location.href = 'http://' + self.location.host + '/cs/' + strUrl;
		}
	}
}


function SortMonth(month1, month2)
{
	var arrMonth1	= month1.ID.split("/");
	var arrMonth2	= month2.ID.split("/");
	
	var varMonth1	= new Date(parseInt(arrMonth1[2]) - 1,parseInt(arrMonth1[0]) - 1,parseInt(arrMonth1[1]) - 1);
	var varMonth2	= new Date(parseInt(arrMonth2[2]) - 1,parseInt(arrMonth2[0]) - 1,parseInt(arrMonth2[1]) - 1);

	if(varMonth1 < varMonth2)
		return -1;
	
	if(varMonth1 == varMonth2)
		return 0;
	
	if(varMonth1 > varMonth2)
		return 1;
}
