// Javascript for Netscape
var arrAllVendors		= null;
var cookieDays			= 90;
var CruiseSearchStatus;


/***************************************************
*
*
***************************************************/
function GoDiscovery(strUrl)
{
	if (parent != null)
	{
		parent.document.location = strUrl;
	}
	else
	{
		document.location = strUrl;
	}
}

/***************************************************
*
*
***************************************************/
function SetSelected(cbVendorCategory, cbCruiseVendor, cbShip )
{
	//set selected options
	if (g_currentCategory == -1)
	{
		cbVendorCategory.options[0].selected = true;
	}
	else
	{
		for (var idx1 = 0; idx1 < cbVendorCategory.options.length; idx1++)
		{
			if (cbVendorCategory.options[idx1].value == g_currentCategory)
			{
				cbVendorCategory.options[idx1].selected = true;
				break;
			}
		}		
	}
	
	if (g_currentVendor == -1)
	{
		cbCruiseVendor.options[0].selected = true;
	}
	else
	{
		for (var idx2 = 0; idx2 < cbCruiseVendor.options.length; idx2++)
		{
			if (cbCruiseVendor.options[idx2].value == g_currentVendor)
			{
				cbCruiseVendor.options[idx2].selected = true;
				break;
			}
		}
	}
	
	if (g_currentShip == -1)
	{
		cbShip.options[0].selected = true;
	}
	else
	{
		for (var idx3 = 0; idx3 < cbShip.options.length; idx3++)
		{
			if (cbShip.options[idx3].value == g_currentShip)
			{
				cbShip.options[idx3].selected = true;
				break;
			}
		}
	}
}

/***************************************************
*
*
***************************************************/
function LoadRoyalOlympiaCombos(cbVendorCategory, cbCruiseVendor, cbShip, caller)
{
	var arrCategories = eval('ArrayCategoryObjects'); //get ahold of combo data
	if (arrCategories == null)
	{
		return;
	}

	var vendorsArr = null;
	for (var i = 0; i < arrCategories.length; i++)
	{
		if(arrCategories[i].ID == g_currentCategory)
		{
			vendorsArr = arrCategories[i].VendorArray;
			break;
		}
	}
	if (vendorsArr == null)
	{
		alert('cannot find any vendors for category' + g_currentCategory);
		return;
	}
	
	for (var j = 0; j < vendorsArr.length; j++)
	{
		if (vendorsArr[j].ID == g_currentVendor)
		{
			var arrShips = vendorsArr[j].ShipArray;
			FillCombo2(cbShip, arrShips);
			break;
		}
	}
	for (var idx3 = 0; idx3 < cbShip.options.length; idx3++)
	{
		if (cbShip.options[idx3].value == g_currentShip)
		{
			cbShip.options[idx3].selected = true;
			break;
		}
	}
}

/***************************************************
*
*
***************************************************/
function OnRoyalStartupLoad(ShipID)
{	
	var cbShip		= null;
	cbShip			= getElement(ShipID);
	LoadRoyalOlympiaCombos(null, null, cbShip, 'OnRoyalStartupLoad');
}

/***************************************************
*
*
***************************************************/
function AddNewElement(arrObjects, object)
{
	var found = false;
	for (var idx=0; idx < arrObjects.length; idx++)	
	{
		if (arrObjects[idx].ID == object.ID)
		{
			found = true;
			return;
		}
	}
	
	arrObjects[arrObjects.length] = object;
	return arrObjects;
}

var newwindow;
			
/***************************************************
*
*
***************************************************/
function poptastic(url, width, height)
{
	newwindow = window.open(url, 'name', 'height=' + height + ',width=' + width + ', resizable=0, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function adjustHeight(frame)
{
    try 
    {
        document.getElementById(frame).height = (document.getElementById(frame).contentWindow.document.body.scrollHeight + 30) + "px";
    }
    catch(e)
    {
        document.getElementById(frame).height = 1700 + "px";
    }
}

function adjustHeightBoth(searchFrame, frame, tableName)
{
    try 
    {
        if (document.getElementById(frame) != null)
        {
            document.getElementById(frame).height = document.getElementById(frame).contentWindow.document.body.scrollHeight;
            if (searchFrame != null && tableName != null)
            {
                if (document.getElementById(frame).height > 700)
                {
                    document.getElementById(searchFrame).height = (document.getElementById(frame).height) + "px";
                    var searchframe1 = document.getElementById(searchFrame);
                    if (searchframe1.contentDocument)
                    {    // Firefox
                        _obj = searchframe1.contentDocument;
                    }
                    else if (searchframe1.contentWindow)
                    {
                        // Internet Explorer
                        _obj = searchframe1.contentWindow.document;
                    }
                    _obj.getElementById(tableName).style.height = document.getElementById(frame).height + "px";
                }
                else
                {
                    document.getElementById(searchFrame).height = 700;
                }
            }
        }
        else if (document.getElementById(searchFrame) != null)
        {
            document.getElementById(searchFrame).height = 1700 + "px";
        }
    }
    catch(e)
    {       
        if (document.getElementById(frame) != null)
        {
            document.getElementById(frame).height = 1700; 
            if (searchframe != null)
            {
                document.getElementById(searchFrame).height = 1700;
                var searchframe1 = document.getElementById(searchFrame);
                if (searchframe1.contentDocument)
                {    // Firefox
                    _obj = searchframe1.contentDocument;
                }
                else if (searchframe1.contentWindow)
                {
                    // Internet Explorer
                    _obj = searchframe1.contentWindow.document;
                }
                _obj.getElementById(tableName).style.height = 1700 + "px";
            }
        }
        else if (document.getElementById(searchFrame) != null)
        {
            document.getElementById(searchFrame).height = 1700 + "px";
        }
    }
}

function adjustFrameHeightFromChild(frame)
{
    try
    {
        if (window.parent.document.getElementById(frame) != null)
            window.parent.document.getElementById(frame).height = window.parent.document.getElementById(frame).contentWindow.document.body.scrollHeight;
    }
    catch(e)
    {
        if (window.parent.document.getElementById(frame) != null)
            window.parent.document.getElementById(frame).height = 1600;
    }
}

function doscroll()
{
    try
    {
        parent.window.scroll(0,0);
    }
    catch(err)
    {
    }
}
/***************************************************
*
*
***************************************************/
   
function CruiseDetails(strFile, intShipID, intItnID, depFrom, depTo, vndID, sailingNumber, skinID, strLayout)
{
	var strUrl		= strFile;
	Querystring(null);
	if (intShipID != null && intShipID != '')
	{
	    var arrURL = strUrl.split('?');
	    if (arrURL.length == 1)
	        strUrl += "?SID=" + intShipID;
	    else
	        strUrl += "&SID=" + intShipID;
	}
	if (intItnID != null && intItnID != '')
	{
	    var arrURL = strUrl.split('?');
	    if (arrURL.length == 1)
	        strUrl += "?IID=" + intItnID;
	    else
	        strUrl += "&IID=" + intItnID;
	}
	if (vndID != null && vndID != '')
	{
	    var arrURL = strUrl.split('?');
	    if(arrURL.length == 1)
	        strUrl += "?VID=" + vndID;
	    else
	        strUrl += "&VID=" + vndID;
	}
	if (sailingNumber != null && sailingNumber != '')
	{
	    var arrURL = strUrl.split('?');
	    if (arrURL.length == 1)
	        strUrl += "?SNO=" + sailingNumber;
	    else
	        strUrl += "&SNO=" + sailingNumber;
	}
	if (depFrom != null && depFrom != '')
	{
	    var arrURL = strUrl.split('?');
	    if (arrURL.length == 1)
	        strUrl += "?DF=" + depFrom;
	    else
	        strUrl += "&DF=" + depFrom;
	}
	if (depTo != null && depTo != '')
	{
	    var arrURL = strUrl.split('?');
	    if(arrURL.length == 1)
	        strUrl += "?DT=" + depTo;
	    else
	        strUrl += "&DT=" + depTo;
	}
		
	// inform the parent
	try
	{
		window.parent.initParams(vndID, intShipID);
	}
	catch(e){ }
    
	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('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 (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);
	}
	else if (Querystring_get('lphone', null) != null)
	{
	    var arrURL = strUrl.split('?');
	    if(arrURL.length == 1)
	        strUrl += "?Phone=" + Querystring_get('lphone', null);
	    else if (strUrl.indexOf("Phone=") < 0)
	        strUrl += "&Phone=" + Querystring_get('lphone', null);
	}
	
	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);
	}
		
	{
		var cbDest		= getElement("ZoneDropDown");
		var	cbMonth		= getElement("DateDropDown");
		var cbLen		= getElement("LenDropDown");
		var cbVnd		= getElement("VndDropDown");
		var cbShp		= getElement("ShipsDropDown");
		var cbSort		= getElement("SortDropDown");
		var cbPort		= getElement("PortDropDown");
		var cbSenior	= getElement("Seniors");
		var cbMilitary	= getElement("Military");
		var cbPP    	= getElement("PastPassenger");
		var cbPC    	= getElement("PromoCode");
		var cbZip1		= getElement("Zip1");
		var cbEO		= getElement("EO");
		var cbPID       = getElement("PID");
		
    	Querystring(null);
    	if (cbDest != null && cbDest.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CD=" + escape(cbDest.value);
	        else
	            strUrl += "&CD=" + escape(cbDest.value);
	    }
	    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);
	    }
	    else 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);
	    }
	
	    if (cbLen != null && cbLen.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CL=" + escape(cbLen.value);
	        else
	            strUrl += "&CL=" + escape(cbLen.value);
	    }
	    else 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 (cbVnd != null && cbVnd.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CV=" + escape(cbVnd.value);
	        else
	            strUrl += "&CV=" + escape(cbVnd.value);
	    }
	    else 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('vid', null) != null)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CV=" + Querystring_get('vid', null);
	        else
	            strUrl += "&CV=" + Querystring_get('vid', null);
	    }
	    
	    if (cbShp != null && cbShp.value != '' && strUrl.indexOf("CSP=") < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CSP=" + escape(cbShp.value);
	        else
	            strUrl += "&CSP=" + escape(cbShp.value);
	    }
	    if (strUrl.indexOf('CSP=') < 0)
	    {
	        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 (cbSort != null && cbSort.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CST=" + escape(cbSort.value);
	        else
	            strUrl += "&CST=" + escape(cbSort.value);
	    }
	    if (strUrl.indexOf('CST=') < 0)
	    {
	        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 (cbPort != null && cbPort.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?CP=" + escape(cbPort.value);
	        else
	            strUrl += "&CP=" + escape(cbPort.value);
	    }
	    if (strUrl.indexOf('CP=') < 0)
	    {
	        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 (cbSenior != null && (cbSenior.checked == 'true' || cbSenior.checked == 'false' ))
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?SN=" + escape(cbSenior.value);
	        else
	            strUrl += "&SN=" + escape(cbSenior.value);			
		}
		else if ((cbSenior != null && cbSenior.value != null && cbSenior.value != '')) // drop-down
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?SN=" + escape(cbSenior.value);
	        else
	            strUrl += "&SN=" + escape(cbSenior.value);
		}
		if (Querystring_get('sn', null) != null && strUrl.indexOf('SN=') < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?SN=" + Querystring_get('sn', null);
	        else
	            strUrl += "&SN=" + Querystring_get('sn', null);
	    }
		
		if (cbMilitary != null && (cbMilitary.checked == 'true' || cbMilitary.checked == 'false' ))
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?MT=" + escape(cbMilitary.value);
	        else
	            strUrl += "&MT=" + escape(cbMilitary.value);
		}
		else if (cbMilitary != null && cbMilitary.value != null && cbMilitary.value != '') // drop-down
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?MT=" + escape(cbMilitary.value);
	        else
	            strUrl += "&MT=" + escape(cbMilitary.value);
		}
		if (Querystring_get('mt', null) != null && strUrl.indexOf('MT=') < 0)	    
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?MT=" + Querystring_get('mt', null);
	        else
	            strUrl += "&MT=" + Querystring_get('mt', null);
	    }
		
		if (cbPP != null && (cbPP.checked == 'true' || cbPP.checked == 'false' ))
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?PP=" + escape(cbPP.value);
	        else
	            strUrl += "&PP=" + escape(cbPP.value);
		}
		else if (cbPP != null && cbPP.value != null && cbPP.value != '') // drop-down
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?PP=" + escape(cbPP.value);
	        else
	            strUrl += "&PP=" + escape(cbPP.value);
		}	
		if (Querystring_get('pp', null) != null && strUrl.indexOf('PP=') < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?PP=" + Querystring_get('pp', null);
	        else
	            strUrl += "&PP=" + Querystring_get('pp', null);
	    }
	    
	    if (cbPC != null && cbPC.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?PC=" + escape(cbPC.value);
	        else
	            strUrl += "&PC=" + escape(cbPC.value);
	    }
	    if (Querystring_get('pc', null) != null && strUrl.indexOf('PC=') < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?PC=" + Querystring_get('pc', null);
	        else
	            strUrl += "&PC=" + Querystring_get('pc', null);
	    }
	    
	    if (cbZip1 != null && cbZip1.value != '')
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?ZP1=" + escape(cbZip1.value);
	        else
	            strUrl += "&ZP1=" + escape(cbZip1.value);
	    }
	    if (Querystring_get('zp1', null) != null && strUrl.indexOf('ZP1=') < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?ZP1=" + Querystring_get('zp1', null);
	        else
	            strUrl += "&ZP1=" + Querystring_get('zp1', null);
	    }
	    else if (Querystring_get('st1', null) != null && strUrl.indexOf('ZP1=') < 0)
	    {
	        var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?ZP1=" + Querystring_get('st1', null);
	        else
	            strUrl += "&ZP1=" + Querystring_get('st1', null);
	    }
			
		if (cbEO != null && (cbEO.checked == 'true' || cbEO.checked == 'false'))
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?EO=" + escape(cbEO.value);
	        else
	            strUrl += "&EO=" + escape(cbEO.value);
		}
		else if ((cbEO != null && cbEO.value != null && cbEO.value!='')) // drop-down
		{
		    var arrURL = strUrl.split('?');
	        if (arrURL.length == 1)
	            strUrl += "?EO=" + escape(cbEO.value);
	        else
	            strUrl += "&EO=" + escape(cbEO.value);			
		}		
		else 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('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('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 (skinID != null && skinID != '')
	{
	    var arrURL = strUrl.split('?');
        if (arrURL.length == 1)
            strUrl += "?Skin=" + skinID;
        else
            strUrl += "&Skin=" + skinID;	    
	}
	
	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('grouponly', null) != null && Querystring_get('grouponly', 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('xml', null) != null)
	{
	    var arrURL = strUrl.split('?');
        if (arrURL.length == 1)
            strUrl += "?xml=" + Querystring_get('xml', null);
        else
            strUrl += "&xml=" + Querystring_get('xml', null);   
	}    
	
	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('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('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);
	}
	//HOME - Must be the last QS param
	if (Querystring_get('home', null) != null)
	{
	   var arrURL = strUrl.split('?');
	    if (arrURL.length == 1)
	        strUrl += "?Home=" + Querystring_get('home', null);
	    else
	        strUrl += "&Home=" + Querystring_get('home', null);
	}
	
	var form1		= getElement("Form1");
	form1.target	= "_self";
	form1.action	= strUrl;
	form1.submit();
}

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]).toLocaleLowerCase()

	    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) 
    {
        if (this.params['L' + key] != null)
            value = this.params['L' + key]
        else
            value=default_;
    }
	
    return value
}

/***************************************************
*
*
***************************************************/
function PageClick(pageNo1, type1, path1)
{
	var strUrl				= path1 + "?PG=" + pageNo1 + "&Ref=PG";
	
	var hasFrames = false;
	try { 
		hasFrames = (parent != null && parent.frames != null && parent.frames[1] != null && parent.location.host == parent.frames[1].location.host);
	} catch(e) {}
	
	
		var strLeftPanelState	= GetLastState() + "&" + GetQueryString();
		strUrl					+= "&" + strLeftPanelState;
		var frm					= getElement('Form1');
		frm.action				= strUrl;
		frm.target				= "_self";
		frm.submit();
	
}

/***************************************************
*
*
***************************************************/
function GetLastState()
{
	var strLastState = "";
	
	var cbLSN		= getElement("LSN");
	
	if(cbLSN != null && cbLSN.value != '')
	{		
		if(strLastState != "")strLastState += "&";
		strLastState += "LSN=" + cbLSN.value;
	}
	
	var cbLMT		= getElement("LMT");
	if(cbLMT != null && cbLMT.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LMT=" + cbLMT.value;
	}
	
	var cbLPP		= getElement("LPP");
	if(cbLPP != null && cbLPP.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LPP=" + cbLPP.value;
	}
	
	var cbLZP1		= getElement("LZP1");
	if(cbLZP1 != null && cbLZP1.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LZP1=" + cbLZP1.value;
	}
	
	var cbLZP2		= getElement("LZP2");
	if(cbLZP2 != null && cbLZP2.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LZP2=" + cbLZP2.value;
	}
	
	var cbLPC		= getElement("LPC");
	if(cbLPC != null && cbLPC.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LPC=" + cbLPC.value;
	}

	var cbLCD		= getElement("LCD");
	if(cbLCD != null && cbLCD.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCD=" + cbLCD.value;
	}
	
	var cbLCP		= getElement("LCP");
	if(cbLCP != null && cbLCP.value != '' && cbLCP.value != '-1')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCP=" + cbLCP.value;
	}
	
	var cbLCL		= getElement("LCL");
	if(cbLCL != null && cbLCL.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCL=" + cbLCL.value;
	}
	
	var cbLDF		= getElement("LDF");
	if(cbLDF != null && cbLDF.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LDF=" + cbLDF.value;
	}
	
	var cbLDT		= getElement("LDT");
	if(cbLDT != null && cbLDT.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LDT=" + cbLDT.value;
	}
	
	var cbLCV		= getElement("LCV");
	if(cbLCV != null && cbLCV.value != '' && cbLCV.value != '-1')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCV=" + cbLCV.value;
	}
	
	var cbLCSP		= getElement("LCSP");
	if(cbLCSP != null && cbLCSP.value != '' && cbLCSP.value != '-1')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCSP=" + cbLCSP.value;
	}
	
	var cbLSO		= getElement("LSO");
	if(cbLSO != null && cbLSO.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LSO=" + cbLSO.value;
	}
	
	var cbLRef		= getElement("LRef");
	if(cbLRef != null && cbLRef.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LRef=" + cbLRef.value;
	}
	
	var cbLPIN		= getElement("LPIN");
	if(cbLPIN != null && cbLPIN.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LPIN=" + cbLPIN.value;
	}
	
	var cbLCC		= getElement("LCompCruises");
	if(cbLCC != null && cbLCC.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCompCruises=" + cbLCC.value;
	}	

	var cbLLID		= getElement("LLID");
	if(cbLLID != null && cbLLID.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LLID=" + cbLLID.value;
	}
	
	var cbLEO		= getElement("LEO");
	if(cbLEO != null && cbLEO.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LEO=" + cbLEO.value;
	}
	
	var cbLMS		= getElement("LMS");
	if(cbLMS != null && cbLMS.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LMS=" + cbLMS.value;
	}
	
	var cbLPhone		= getElement("LPhone");
	if(cbLPhone != null && cbLPhone.value != '')
	{
		if (strLastState != "") strLastState += "&";
		    strLastState += "LPhone=" + cbLPhone.value;
	}
	
	var cbLCST		= getElement("LCST");
	if(cbLCST != null && cbLCST.value != '')
	{
		if(strLastState != "")strLastState += "&";
		strLastState += "LCST=" + cbLCST.value;
	}
	
	return strLastState;
}

/***************************************************
*
*
***************************************************/
function Compare(maxCruises)
{
		var frm			= getElement('Form1');
		var elements = document.getElementsByTagName("*");
		var totalCruiseToCompare = 0;
		for (var i=0; i<elements.length; i++)
		{
			if (elements[i] != null && elements[i].id != null && elements[i].id.length > 8)
				if (elements[i].id.substring(0,8) == "Compare_")
					if (elements[i].checked == true)
						totalCruiseToCompare++;
		}
		
		if (totalCruiseToCompare <= 0)
		{
			alert('There are no cruises selected.');
			return;
		}
			
		if (maxCruises != null && maxCruises != undefined)
		{
		    if (totalCruiseToCompare > maxCruises)
		    {
			    alert('Please select ' + maxCruises + ' or less cruises to compare.');
			    return;
		    }
		}
		else
		{
		    if (totalCruiseToCompare > 6)
		    {
			    alert('Please select 6 or less cruises to compare.');
			    return;
		    }
		}

    	frm.target	= "_self";
		frm.submit();
}

/***************************************************
*
*
***************************************************/
function getFullDate(cbMonthID, cbDayID, cbYearID)
{
	var cbYear	= getElement(cbYearID);
	var cbMonth	= getElement(cbMonthID);
	var cbDay	= getElement(cbDayID);
	
	var date	= new Date();
	var strDate = date.getMonth() + "/" + date.getDate() + "/" + date.getYear();
		
	if(cbMonth != null && cbDay != null && cbYear != null)
	{
		strDate = (parseInt(cbMonth.value) + 1) + "/" + cbDay.value + "/" + cbYear.value;
	}

	return escape(strDate);
}


function SortBySelection(selectionId, path1)
{
    var strUrl				= "/CS/forms/cruiseresultpage.aspx?LCST=" + selectionId;
	
	var hasFrames = false;
	try { 
		hasFrames = (parent != null && parent.frames != null && parent.frames[1] != null && parent.location.host == parent.frames[1].location.host);
	} catch(e) {}
		
	    var lastState = GetLastState();
	    
	    if (lastState.indexOf("CST=") > 0)
	    {
	        var args = lastState.split('&') //parse out name/value pairs separated via &
	        lastState = '';
            //split out each name=value pair
            for (var i = 0; i<args.length; i++)
            {
	            var pair = args[i].split('=');
	            if (pair[0].indexOf("CST") == -1)
	            {
	                lastState += '&' + pair[0] + '=' + pair[1];
	            }
	        }
	    }
	    else
	    {
	        lastState = '&' + lastState;
	    }
		var strLeftPanelState	= lastState + '&' + GetQueryString();
		strUrl					+= strLeftPanelState;
		var frm					= getElement('Form1');
		frm.action				= strUrl;
		frm.target				= "_self";
		frm.submit();
}

