
function HandleDisplayResults(rs,cid)
{
	if (cid != rs.id)
	{ 
		if (rs.value!=undefined)
		{
		return rs.value;
		}
		else
		{
		return;
		}
	}
	if(rs.error)
	{
		// Pull the error information
		var faultCode   = rs.errorDetail.code;
		var faultString = rs.errorDetail.string;
		alert("ERROR: Code = " + faultCode + ", Fault String=" + faultString);		
	}
	else
	{		
		return rs.value;
	}
}
			
function DisplayProvResults(result)
{
	var str = '';
	var aTempArray;
	var bTempArray;
	var i;
	var head = "<SELECT id=cboProvince style='WIDTH: 208px' name=cboProvince>";
	var tail = "</SELECT>";
	var sTempArray;
	var aTempResultString = HandleDisplayResults(result,iCallID);
	var obj=document.getElementById("cboProvince");

	if (aTempResultString != null && aTempResultString != '')
	{
		// Insert value from string here
		aTempArray = aTempResultString.split('|');
		if (aTempArray != 'undefined')
		{
			for (i = 0; i<aTempArray.length; i++)
			{
				sTempArray = aTempArray[i];
				bTempArray = sTempArray.split('=');
				obj.options[obj.length] = new Option(bTempArray[1],bTempArray[0]);
				//str = str + " \<option value='" + bTempArray[0] + "'>" + bTempArray[1] +"</option>";
			}

		}
		//document.getElementById("cboProvince").innerHTML = head + str + tail;
	}
	else
	{
		obj.length = 0;
	}
}
function hideRate()
{
	var aDivContainer = document.getElementById("RateResult");
	aDivContainer.className = "txtMessage_close"	
}
function showRate()
{
	var aDivContainer = document.getElementById("RateResult");
	aDivContainer.className = "txtCustomMessage_open"	
}	
function showCollect()
{
	var aPaymentType = document.getElementById("ddlPrepaidOrCollect")
	var aCollectTextbox = document.getElementById("txtCollectAccount")
	var aCollectPrompt = document.getElementById("_05500lblCollectPrompt")
	if (aPaymentType.options[aPaymentType.selectedIndex].value == "C" )
	{
		aCollectTextbox.className = "txtCustomMessage_open";
		aCollectPrompt.className = "prompt"
	}
	else
	{
		aCollectTextbox.className = "txtMessage_close";
		aCollectTextbox.innerText = '';
		aCollectPrompt.className = "txtMessage_close"
	}
}
function showDropOffOnReference()
{
	var aDivContainer = document.getElementById("dropOffItem");
	var aDropOffMethod = document.getElementById("cboReceiveMethod");
	
	if (aDropOffMethod.selectedIndex >= 0)
	{
		if ((aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Drop Off") || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Dépôt"))
		{
			aDivContainer.className = "txtCustomMessage_open";
		}
		else
		{
			aDivContainer.className = "txtMessage_close";
		}
	}
	else
	{
		aDivContainer.className = "txtMessage_close";
	}
}
function showDropOff()
{
	var aDivContainer = document.getElementById("dropOffItem");
	var aDivContainer2 = document.getElementById("otherItem");
	var aDropOffMethod = document.getElementById("cboReceiveMethod");
	
	if (aDropOffMethod.selectedIndex >= 0)
	{
		if ((aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Drop Off") || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Dépôt"))
		{
			aDivContainer.className = "txtCustomMessage_open";
		}
		else
		{
			aDivContainer.className = "txtMessage_close";
		}
	}
	else
	{
		aDivContainer.className = "txtMessage_close";
	}
	
	if (aDropOffMethod.selectedIndex >= 0)
	{	
		if (((aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Pickup-Other") || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Pickup (Others)")) || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Cueillette - Autres"))
		{
			if (document.getElementById("txtKeepSession") == '') document.getElementById("txtSpecify").value = "";
			aDivContainer2.className = "txtCustomMessage_open";
		}
		else
		{
			aDivContainer2.className = "txtMessage_close";
		}
	}
	else
	{
		aDivContainer2.className = "txtMessage_close";
	}

}
function showShipDropOff()
{
	var aDivContainer = document.getElementById("dropOffItem");
	var aDivContainer2 = document.getElementById("otherItem");
	var aDropOffMethod = document.getElementById("_05020cboReceiveMethod");
	if (aDropOffMethod.selectedIndex >= 0)
	{
		if ((aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Drop Off") || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Dépôt"))
		{
			aDivContainer.className = "txtCustomMessage_open";
		}
		else
		{
			aDivContainer.className = "txtMessage_close";
		}
	}
	else
	{
		aDivContainer.className = "txtMessage_close";
	}
	if (aDropOffMethod.selectedIndex >= 0)
	{
		if (((aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Pickup-Other") || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Pickup (Others)")) || (aDropOffMethod.options[aDropOffMethod.selectedIndex].text == "Cueillette - Autres"))
		{
			if (document.getElementById("txtKeepSession") == '') document.getElementById("txtSpecify").value = "";
			aDivContainer2.className = "txtCustomMessage_open";
		}
		else
		{
			aDivContainer2.className = "txtMessage_close";
		}
	}
	else
	{
		aDivContainer2.className = "txtMessage_close";
	}

}
function setMaskForPostalCodeByCode(thisObj, aCountryISOCode)
{
	if (aCountryISOCode.value == "CA")
	{
		thisObj.setInputMask(">L0L-0L0"); 
	}
	else
	{
		if (aCountryISOCode.value == "US")
		{
			thisObj.setInputMask("99999"); 
		}
		else
		{
			thisObj.setInputMask(">CCCCCCCCCC"); 
		}
	}
}
function setMaskForPostalCodeByName(thisObj, aCountryName)
{
	if (aCountryName.value == "CANADA")
	{
		thisObj.setInputMask(">L0L-0L0"); 
	}
	else
	{
		if (aCountryName.value == "UNITED STATES OF AMERICA")
		{
			thisObj.setInputMask("99999"); 
		}
		else
		{
			thisObj.setInputMask(">CCCCCCCCCC"); 
		}
	}
}
function setMaskForTelephoneByCode(thisObj, aCountryISOCode)
{
	if ((aCountryISOCode.value == "CA") || (aCountryISOCode.value == "US"))
	{
		thisObj.setInputMask("###-###-#### CCCC"); 
	}
	else
	{
		thisObj.setInputMask("CCC-CCC-CCCC CCCC"); 
	}
}
function setMaskForTelephoneByName(thisObj, aCountryName)
{
	if ((aCountryName.value == "CANADA") || (aCountryName.value == "UNITED STATES OF AMERICA"))
	{
		thisObj.setInputMask("###-###-#### CCCC"); 
	}
	else
	{
		thisObj.setInputMask("CCC-CCC-CCCC CCCC"); 
	}
}
function setMaskForTelephoneWithExtByCode(thisObj, aCountryISOCode)
{
	if ((aCountryISOCode.value == "CA") || (aCountryISOCode.value == "US"))
	{
		thisObj.setInputMask("###-###-#### ####"); 
	}
	else
	{
		thisObj.setInputMask("CCC-CCC-CCCC CCCC"); 
	}
}
function setMaskForTelephoneWithExtByName(thisObj, aCountryName)
{
	if ((aCountryName.value == "CANADA") || (aCountryName.value == "UNITED STATES OF AMERICA"))
	{
		thisObj.setInputMask("###-###-#### ####"); 
	}
	else
	{
		thisObj.setInputMask("CCC-CCC-CCCC CCCC"); 
	}
}
function diableEnterKey()
{
	if (window.event.keyCode == 13) 
	{
	    event.returnValue=false; 
	    event.cancel = true;
	}
}
function showHileLocation()
{
	var aPUSelector = document.getElementById("ddlSpecify");
	var aLocation = document.getElementById("txtPickupLocation");
	var aLocationLabel = document.getElementById("_05500lblSpecify");
	
	if ((aPUSelector.value == "Pickup-Other") || (aPUSelector.value == "Pickup (Others)"))
	{
		aLocationLabel.className = "txtCustomMessage_open";
		aLocation.className = "txtCustomMessage_open";
	}
	else
	{
		aLocationLabel.className = "txtMessage_close";
		aLocation.className = "txtMessage_close";
	}
}
function PrintCI()
{
	var isOKtoPrint = document.getElementById("txtOKtoPrint");
	if (isOKtoPrint.value == '1')
	{
		window.open('wfCommercialInvoice_Print.aspx','CommercialInvoice_Print','_blank');
		isOKtoPrint.innerText = 0;
	}
}
function PrintDangerousGoods()
{
	window.open('wfDangerousGoods_Print.aspx','DangerousGoods_Print','_blank');
}

 
/*
function ResetWeight(n){
	document.getElementById("wtxtWeight").value = n;
}
function roundOffToOneDecimal(thisObj){
var n = document.getElementById(thisObj);
document.getElementById(thisObj).value = Math.round(n*10)/10;
}*/