var strSvcCode;
var bolOrgUSMain;
var bolDstUSMain;

function GetCurrentSvc()
{
	var oF = document.aspnetForm;
	CheckStates(oF.ctl00_contentPlaceHolderRoot_dropDownListPUState);
	CheckStates(oF.ctl00_contentPlaceHolderRoot_dropDownListDELState);
}

function ResetState(oSelect)
{
	var oF = document.aspnetForm;

	if (oSelect.name == 'ctl00$contentPlaceHolderRoot$dropDownListPUCountry')
	{	
		oF.ctl00_contentPlaceHolderRoot_dropDownListPUState.options[0].selected = true;
	}
	else
	{
		oF.ctl00_contentPlaceHolderRoot_dropDownListDelState.options[0].selected = true;
	}
}

function CheckStates(oSelect)
{
	for (var i = 0;i < oSelect.length; i++)
	{				
		if(oSelect.options[i].selected)
		{
			if (oSelect.name == "ctl00$contentPlaceHolderRoot$dropDownListPUState")
			{	
				if (ContinentalUS(oSelect.options[i].value, 'PU'))
					bolOrgUSMain = true;
				else
					bolOrgUSMain = false;
			}
			
			if (oSelect.name == "ctl00$contentPlaceHolderRoot$dropDownListDelState")
			{
				if (ContinentalUS(oSelect.options[i].value, 'DEL'))
					bolDstUSMain = true;
				else
					bolDstUSMain = false;;
			}
			break;
		}
	}
}

function ContinentalUS(strStateCode, strType)
{
	if (strStateCode == "") return false;

	var aryStates = new Array('AK','HI','PR','AB','BC','MB','NB','NF','NT','NS','ON','PE','PQ','SK','YT')  
	var bolContinentalUS = true;
	for(var i=0; i < aryStates.length; i++)
	{	
		var ret = true;
		if (strStateCode == aryStates[i])
		{
			bolContinentalUS = false;
		}
	}
	
	var strCountry;
	if ((strStateCode == 'AK' || strStateCode == 'HI') || bolContinentalUS)
		strCountry = 'US'
	else if (strStateCode == 'PR')
		strCountry = 'PR'
	else
		strCountry = 'CA'
		
	if (strType == 'PU') SetCountry(document.aspnetForm.ctl00_contentPlaceHolderRoot_dropDownListPUCountry, strCountry)
	if (strType == 'DEL') SetCountry(document.aspnetForm.ctl00_contentPlaceHolderRoot_dropDownListDelCountry, strCountry)


	return bolContinentalUS;
}

function SetCountry(ddl, strCountry)
{
	for (var i=0; i<ddl.length; i++)
	{	
		if (ddl.options[i].value == strCountry) 
		{
			ddl.options[i].selected = true;
			ddl.focus();
			break;
		}
	}
}

function ServiceLevel(ServiceLevelCode, Description)
{
	this.ServiceLevelCode = ServiceLevelCode;
	this.Description = Description;
}

function CheckIt(oSelect, sPromptValue)
{
	if (document.aspnetForm.ctl00_contentPlaceHolderRoot_hiddenFieldIsFromRateQuote.value == "Y")
	{
		alert("'" + sPromptValue + "' used to create your rate quote has been changed therefore, your rate quote may no longer be valid.")
	}
}



