/* 
 * FILENAME: forms.js
 * 
 * Update History:
 * 01/26/06 KWD P6254 Added method rejectNonDigit() to restrict input
 * 				field entry to digits only.
 * 04/15/06 KWD P6611 Added setFocus() and numbersonly() methods.
 * 07/18/06 KWD P6817 Added toggleLayer() function to toggle the show/hide state of a div.
 * 09/25/06 JLS P6847 Added try/catch to getAttributeValue function to
 *              ignore exceptions thrown by the eval function.
 * 10/17/06 CEM P6650 Added setCursor, disableSelectFormFields, enableSelectFormFields
 *				to support shopping scheduler note popup
 * 03/26/07 JLS P7106 Added functions updateAllCheckboxes, 
 *				getFormElementsByName.
 * 07/19/07 KWD P7393 Added phoneCharsOnly(), updateReqFldsForBillingCountryChange() and 
 *				updateReqFldsForShippingCountryChange() methods. Also moved isPhoneNumber()
 *				over from ContactTti.jsp page.
 * 07/24/07 JLS P7413  Adding error handling to getFormElementByName.
 *              Added focusField function.  
 *              Added isEnterKeyPressed, handleSubmitFormKeyPressedEvent.
 * 03/04/09 CEM P7958 Added function to initiate the loading of the profile for the session
 *				between the browser and WAS; consume the entity value
 * 08/12/09 SGM T92599 Added method to check to see if the escape key was pressed
 * 10/23/09 SGM R00161 Add userOrigin to initiateClientToWASSession function.
 * 11/16/09 CEM R00143 Added retrieveCart js for support of auto-save cart.
 */

    /**
     *  Retrieves the form object from the array of forms.  This matches on the
     *  id attribute of the form, not the name.
     *  @param String idLookup - The id attribute value of the form to retrieve.
     */
    function getFormById(idLookup)
    {
        var forms = document.forms;
        
        for(var i = 0; i < forms.length; i++)
        {
            if(forms[i].id == idLookup)
            	return forms[i];
        }
        
        return null;
    }

    /**
     *  Retrieves the form element (intput, select, etc.) from the form 
     *  elements.
     *  @param theform - The form object that contains the elements.
     *  @param String elementName - The value assigned to the "name" attribute
     *    for the form element desired.
     */
    function getFormElementByName(theform, elementName)
    {
        var data;

		try
		{
            data = theform.elements[elementName];
            if(data.name != elementName)
            	data = null;
		}
		catch(ex)
		{
		    data = null;
		}
        
        if(data == null)
        {
            try
            {
                data = eval("theform." + elementName);
                if(data.name != elementName)
                	data = null;
            }
            catch(ex)
            {
                data = null;
            }

            if(data == null)
            {
                var elements = theform.elements;
                for(var i = 0; i < elements.length; i++)
                {
                    if(elements[i].name == elementName)
                    {
                        data = elements[i];
                        break;
                    }
                }
            }

        }

        return data;
    }
    /**
     *  Retrieves the form elements (intput, select, etc.) whose name
     *  attribute matches with the name passed in.  If no matches are
     *  found, then an empty array is returned.
     *  This function differs from getFormElementByName in that this
     *  function returns all matching elements, getFormElementByName
     *  only returns the first matching element that is found.
     *  @param theform - The form object that contains the elements.
     *  @param String name - The value assigned to the "name" attribute
     *    for the form element desired.
     *  @return an array of form elements whose name attribute value
     *          matches with the name value passed in.  If no matches
     *          exist, then an empty array is returned.
     */
    function getFormElementsByName(theform, name)
    {
    	var elements = theform.elements;
    	var ret = new Array();
    	
    	if(elements == null)
    		return ret;
    	
    	for(var elementsIndx = 0; elementsIndx < elements.length; elementsIndx++)
    	{
    	    if(elements[elementsIndx].name == name)
    	        ret[ret.length] = elements[elementsIndx];
    	}
    	
    	return ret;
    }

    /**
     *  This retrieves the value of an attribute that exists for a tag.  For
     *  any non-html attributes, this ensures the retrieval of the value for
     *  Netscape browsers.
     *  @param tagObj - The tag object containing all attributes and functions.
     *  @param String attrName - The attribute of the tag to retrieve the value
     *      of.
     *  @return String - Returns the String value assigned to the attribute for
     *      the tag object passed in.
     */
    function getAttributeValue(tagObj, attrName)
    {
		var attrValue = null; 
		
        try
        {
		    attrValue = eval("tagObj." + attrName);
		}
		catch(ex)
		{
		    // ignore exception.
		}
		
		if(attrValue == null)
		{
		    // execute a lookup of the attribute value:
		    if(tagObj.attributes)
		    {
		        var attribute = tagObj.attributes[attrName];
		        
		        if(attribute != null)
		            attrValue = attribute.value;
		    }
		}

		return attrValue;

    }


    /**
     *  Makes sure that all options in the select drop down object are 
     *  deselected.  The select object may be select-multiple or select-single.
     *  @param select - The select object to ensure that all objects are 
     *      deselected.
     */
    function deselectOptions(select)
    {
        if(select.type == "select-multiple")
        {
	        var options = select.options;
	        
	        for(var i = 0; i < options.length; i++)
	        {
	            options[i].selected = false;
	        }
	    }
	    else
	    {
	        // otherwise, this may be a faster way to deselect for select-single
	        select.selectedIndex = -1;
	    }
    }


    /**
     *  Returns an Array of the indexes (or index) that are selected for the
     *  select object passed in.  If no indexes are selected, then an empty
     *  Array object is returned.
     */
    function getSelectedIndexes(keySelect)
    {
        var indexes = new Array();

        if(keySelect.type == "select-multiple")
        {
	        var options = keySelect.options;
	        
	        for(var index = 0; index < options.length; index++)
	        {
	            if(options[index].selected)
	                indexes[indexes.length] = index;
	        }
	    }
	    else // for single select drop down boxes:
	    {
	        if(keySelect.selectedIndex != -1)
                indexes[indexes.length] = keySelect.selectedIndex;
	    }
	    
	    return indexes;
    }


    function findOptionIndex(options, value)
    {
       for(var i = 0; i < options.length; i++)
       {
           if(options[i].value == value)
               return i;
       }
       
       return null;
    }

    function swapOptions(option1, option2)
    {
       var text1, value1, defaultSelected1, selected1;
       var text2, value2, defaultSelected2, selected2;
       
       text1 = option1.text;
       value1 = option1.value;
       defaultSelected1 = option1.defaultSelected;
       selected1 = option1.selected;
       
       text2 = option2.text;
       value2 = option2.value;
       defaultSelected2 = option2.defaultSelected;
       selected2 = option2.selected2;
       
       option1.text = text2;
       option1.value = value2;
       option1.defaultSelected = defaultSelected2;
       option1.selected = selected2;
       
       option2.text = text1;
       option2.value = value1;
       option2.defaultSelected = defaultSelected1;
       option2.selected = selected1;

    }
    
	/*
	 * This function enforces 'digit-only' entry into an input field. 
	 * If a non-digit character was entered, it removes the character
	 * from the input field content as if the Backspace key had been pressed
	 * immediately following the non-digit character entry.
	 */
	function rejectNonDigit(inputFieldName, formId) 
	{

		//character class defining allowed digit entries.
		var allowedChars = /[0123456789]/;

		var form = getFormById(formId);
		var numberString = getFormElementByName(form, inputFieldName);
		var strLength = numberString.value.length;
		var lastchar = numberString.value.charAt((strLength) - 1);
	
		if(lastchar.search(allowedChars) == -1) 
		{
			numberString.value = numberString.value.substring(0, (strLength) - 1);
	    }
	}

	/**
	 * Places focus on the field associated with the field name specified within
	 * the form passed in.  Surround with try/catch block to avoid exceptions.
	 *
	 * @param focusInfo - A JSON object whose attributes are the following:
	 * [form] - The form object containing the element to place focus on.
	 * [fieldObj] - The field Object to place focus on.
	 * [fieldID] - The ID of the field for which focus should be given.
	 * [fieldName] - The name of the field to place focus on.  
	 * [selectField] - The field element being focused on can optionally have its
	 *    content selected (ie. ready for copying/cutting/replacing).  
	 *    Default = true;  true = do the selection; false = do not select field 
	 *    content.
	 *
	 * Usage: 
	 *    IF fieldObj or fieldID are specifid, then form and fieldName are not used.
	 *    Otherwise, form and fieldName are required.
	 * Example:  focusField({form:document.DynaForm, fieldName:"orderQuantity"});
	 * In the example above, the field "orderQuantity" will be focused and highlighted.
	 * Example: focusField({form:myFormObj, fieldName:"fieldNameToFocus", selectField:false});
	 * In the example above, the form object's field named "fieldNameToFocus" will
	 * only be focused, but will not be "selected".
	 */
	function focusField(focusInfo)
	{
	    var focusField = null;;
	    
	    if(focusInfo.fieldObj)
	    	focusField = focusInfo.fieldObj;
	    else if(focusInfo.fieldID)
	    	focusField = document.getElementById(focusInfo.fieldID);
	    else
		    focusField = getFormElementByName(focusInfo.form, focusInfo.fieldName);
		
		if(focusField != null)
		{    
			focusField.focus();
		
			if(focusInfo.selectField != false || focusInfo.selectField === undefined)
				focusField.select();
		}
	}
 
 	/*
	 * This function sets the focus on a form component when passed
	 * the "id" of the form and the "name" of the component.
	 *
	 */   
	  function setFocus(formID, componentID)
	  {
	  	
	  	if(formID == null || componentID == null)
	  	return;
	  	
	  	var partDetailForm = getFormById(formID);
	  	var focusElement = null;
	  	
		if (partDetailForm != null) 
		{
			focusElement = getFormElementByName(partDetailForm, componentID);
			if(focusElement != null)
			{
				focusElement.focus();
			}
		}
	  }    
 
	/*
	 * This function enforces 'digit-only' entry into an input field
	 * when passed a reference to the input field and the key event. 
	 * If a non-digit character is pressed it is rejected.
	 */
	 function numbersonly(myfield, e)
	 {
		var key;
		var keychar;
		
		if (window.event)
		   key = window.event.keyCode;
		else if (e)
		   key = e.which;
		else
		   return true;
		keychar = String.fromCharCode(key);
		
		// control keys
		if ((key==null) || (key==0) || (key==8) || 
		    (key==9) || (key==13) || (key==27) )
		   return true;
		// numbers
		else if ((("0123456789").indexOf(keychar) > -1))
		   return true;
		else
		   return false;
	}

	/**
	 * This function toggles the show/hide state of a <div> section.
	 * parameter 'whichLayer' is the div's id. 
	 */		 
	function toggleLayer(whichLayer)
	{
	    var style2 = null;
	    
		if (document.getElementById)
		{	
			// standards-compliant mechanism
			style2 = document.getElementById(whichLayer).style;
		}
		else if (document.all)
		{	// older IE mechanism
			style2 = document.all[whichLayer].style;
		}
		else if (document.layers)
		{	
			// Netscape 4 mechanism
			style2 = document.layers[whichLayer].style;
		}
		
		if(style2 && style2 != null)
			style2.display = (style2.display != "none") ? "none" : "block";
			
	}

	function show(divID)
	{
		document.getElementById(divID).style.display = 'block';
	}

	function hide(divID)
	{
		document.getElementById(divID).style.display = 'none';
	}

   /*
	* This function sets the cursor to the end of the
	* text element.
	*/
	function setCursor(textAreaElem)
	{
		textAreaElem.focus();
		if(textAreaElem.createTextRange)
		{
			var range = textAreaElem.createTextRange();
			range.moveStart('character', textAreaElem.value.length);
			range.moveEnd('character', 0);
			range.select();
		}
	}
	
   /*
	* Disables all the select form fields.
	*/
	function disableSelectFormFields()
	{
		for(lv=0; lv<document.forms.length; lv++)
		{
			for(i=0; i<document.forms[lv].elements.length; i++)
			{
				if(document.forms[lv].elements[i].type=="select-one" ||
				   document.forms[lv].elements[i].type=="select-multiple")
				{
					document.forms[lv].elements[i].style.visibility="hidden";
				}
			}
		}
	}
	
   /*
	* Enables all the select form fields.
	*/
	function enableSelectFormFields()
	{
		for(lv=0; lv<document.forms.length; lv++)
		{
			for(i=0; i<document.forms[lv].elements.length; i++)
			{
				if(document.forms[lv].elements[i].type=="select-one" ||
				   document.forms[lv].elements[i].type=="select-multiple")
				{
					document.forms[lv].elements[i].style.visibility="visible";			
				}
			}
		}
	}
	
	function getScrollWidth()
	{
	   var w = window.pageXOffset ||
	           document.body.scrollLeft ||
	           document.documentElement.scrollLeft;
	           
	   return w ? w : 0;
	} 

	function getScrollHeight()
	{
	   var h = window.pageYOffset ||
	           document.body.scrollTop ||
	           document.documentElement.scrollTop;
	           
	   return h ? h : 0;
	}	

	/**
	 * Checks/Unchecks all checkboxes with the name passed into 
	 * fieldname that belong to the form passed in.
	 * @param theform - The form object that has the checkboxes.
	 * @param fieldname - The value of the name attribute of the 
	 *        checkboxes to uncheck.
	 * @param checkedstate - true = set all checkboxes to checked state.
	 *        false = set all checkboxes to unchecked state. 
	 */
	function updateAllCheckboxes(theform, fieldname, checkedstate)
	{
	    var elements = getFormElementsByName(theform, fieldname);
	    
	    for(var indx = 0; indx < elements.length; indx++)
	    {
	        elements[indx].checked = checkedstate;
	    }
	}
	
	
	/**
	 * Checks the string value passed for containing only valid phone number characters.
	 * Valid character set is [(, ), -, +, space, digit]. Also verifies that the
	 * number of valid chars is between 10 and 23 inclusive.
	 * @param s - the string to be evaluated as a phone number.
	 * @return boolean - true if content and length are valid phone content, false otherwise. 
	 */	
	function isPhoneNumber(s)
	{
	   var i;
	   var digitIndx = 0;
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        // skip special phone number characters
	        if(c=='(' || c==')' || c=='-' || c=='+' || c==' ')
	        {
	        	continue;
	        }
	        if ((c < "0") || (c > "9"))
	        {
		        return false;
	        } 
	        
	        digitIndx++;
	    }
	    
	    if(digitIndx<10 || digitIndx > 23)
	    {
	    	return false;
	    }
	    
	    return true;
	}

	/**
	 * Function returns a boolean value indicating if a character entered is a phone number character. 
	 * Valid character set is [(, ), -, +, space, digit].
	 * @param myfield - the field for which input is being evaluated.
	 * @param e - the event object.
	 * @return boolean - true if the character entered is a valid phone number character, false otherwise. 
	 */		
	function phoneCharsOnly(myfield, e)
	 {
	 	if(numbersonly(myfield, e))
	 		return true;
	 	else
	 	{
		 	var key;
			var keychar;
			
			if (window.event)
			   key = window.event.keyCode;
			else if (e)
			   key = e.which;
			else
			   return true;
			   
			keychar = String.fromCharCode(key);
			
			// control keys
			if ((key==null) || (key==0) || (key==8) || 
			    (key==9) || (key==13) || (key==27) )
			   return true;
			// valid phone symbols
			else if ((("()-+ ").indexOf(keychar) > -1))
			   return true;
			else
			   return false;
	 	}
	}
	

  	function updateReqFldsForBillingCountryChange()
	{
	var companyCountrySelectObject = document.getElementById("companyCountry");
	var companyStateReqTag = document.getElementById("companyStateReqTag");
	var addressInfoReqTag = document.getElementById("addressInfoReqTag");
	var postalCodeReqTag = document.getElementById("postalCodeReqTag");
	var phoneReqTag = document.getElementById("phoneReqTag");

	//Adjust Billing Address Requirement tags.	
	if (companyCountrySelectObject.value == 354 || companyCountrySelectObject.value == 146)
	{
		if(companyStateReqTag != null)
		{
			getStyle(companyStateReqTag).display = "inline";
		}
		if(addressInfoReqTag != null)
		{
			getStyle(addressInfoReqTag).display = "inline";
		}
		if(postalCodeReqTag != null)
		{
			getStyle(postalCodeReqTag).display = "inline";
		}
		
		if(companyCountrySelectObject.value == 354 && phoneReqTag != null)
		{
			getStyle(phoneReqTag).display = "inline";
		}
		else
		{
			getStyle(phoneReqTag).display = "none";
		}		
	}
	else
	{
		if(companyStateReqTag != null)
		{
			getStyle(companyStateReqTag).display = "none";
		}
		if(addressInfoReqTag != null)
		{
			getStyle(addressInfoReqTag).display = "none";
		}
		if(postalCodeReqTag != null)
		{
			getStyle(postalCodeReqTag).display = "none";
		}
		if(phoneReqTag != null)
		{
			getStyle(phoneReqTag).display = "none";
		}
	}
   }
   
   function updateReqFldsForShippingCountryChange()
   {
   		// Adjust shipping requirement tags.
		var theForm = document.getElementById("workingTtiForm");
		var shippingCountrySelectObject = getFormElementByName(theForm, "shippingCountryID");
		var shippingStateReqTag = document.getElementById("companyShippingStateReqTag");
		var shippingAddressInfoReqTag = document.getElementById("shippingAddressInfoReqTag");
		var shippingPostalCodeReqTag = document.getElementById("shippingPostalCodeReqTag");
		var shippingPhoneReqTag = document.getElementById("shippingPhoneReqTag");		
	
		if (shippingCountrySelectObject.value == 354 || shippingCountrySelectObject.value == 146)
	{
		if(companyShippingStateReqTag != null)
		{
			getStyle(companyShippingStateReqTag).display = "inline";
		}
		if(shippingAddressInfoReqTag != null)
		{
			getStyle(shippingAddressInfoReqTag).display = "inline";
		}
		if(shippingPostalCodeReqTag != null)
		{
			getStyle(shippingPostalCodeReqTag).display = "inline";
		}

		if(shippingCountrySelectObject.value == 354 && shippingPhoneReqTag != null)
		{
			getStyle(shippingPhoneReqTag).display = "inline";
		}
		else
		{
			getStyle(shippingPhoneReqTag).display = "none";
		}		
	}
	else
	{
		if(companyShippingStateReqTag != null)
		{
			getStyle(companyShippingStateReqTag).display = "none";
		}
		if(shippingAddressInfoReqTag != null)
		{
			getStyle(shippingAddressInfoReqTag).display = "none";
		}
		if(shippingPostalCodeReqTag != null)
		{
			getStyle(shippingPostalCodeReqTag).display = "none";
		}
		if(shippingPhoneReqTag != null)
		{
			getStyle(shippingPhoneReqTag).display = "none";
		}
	}
   
   }	
	/**
	 * Checks to see if the ESC key is pressed.  Does not take any
	 * action.
	 * @return true = yes, the escape key was pressed.  false = no, some
	 *         other key was pressed.
	 */
	function isEscapeKeyPressed(e){
		var e = e || window.event; 
		var characterCode = e.charCode || e.keyCode;  
		if(characterCode == 27)
		{
	 		return true;
		}
		return false;
	}

   
	/**
	 * Checks to see if the enter key is pressed.  Does not take any
	 * action.
	 * @return true = yes, the enter key was pressed.  false = no, some
	 *         other key was pressed.
	 */
	function isEnterKeyPressed(e){
		var characterCode
			 if(e && e.which){
			 e = e
			 characterCode = e.which
			 }
			 else{
			 e = event
			 characterCode = e.keyCode
			 }	 
			 if(characterCode == 13){
		 	 return true;
			 }
			return false;
	}
	
	/**
	 * Detects if the enter key has been pressed, and takes the requested
	 * action specified in the info object.
	 * @param e = The event object used to generate this request.
	 * @param info = An object that clarifies actions to take for this
	 *        function.
	 *        [info.alwaysCallback] = function called every time this event is
	 *        fired.  This function is always called, regardless of 
	 *        whether or not the enter key was actually pressed.  
	 *        Parameters passed into the callback function are: 
	 *        event, info.  The info object has been updated to signify
	 *        if the enter key has been pressed or not.  Check: 
	 *        info.isEnterKeyPressed boolean variable to determine this
	 *        in your callback function.  Do not specify if there is no
	 *        callback to execute.  If both this and enterPressedCallback
	 *        are specified, then this function is executed first.
	 *        [info.enterPressedCallback] - function called only if the
	 *        enter key is pressed.  Parameters passed into this callback
	 *        function are: event, info.  The info object has been updated
	 *        to signify if the enter key has been pressed or not.  Check
	 *        the info object's isEnterKeyPressed.  Do not specify if there
	 *        is no callback to execute.  alwaysCallback is executed first,
	 *        and then this function is executed.
	 *        [info.isSubmitForm] - Required with a value of true if the 
	 *        form needs to be submitted via the "enter" key.  Otherwise
	 *        either ignore this variable, or pass in false.
	 *        [info.form] - The form object to submit.  Required if the
	 *        form must be submitted.  If isSubmitForm is true, but the
	 *        form is not passed in, then the form will not be submitted.
	 *        
	 *  Since the info object is passed into the callback functions as the
	 *  second parameter, you may set additional member variables that 
	 *  are needed by the callback methods.<br><br>
	 *  
	 *  Example:  <input type="text" onkeypress="handleSubmitFormKeyPressedEvent(event, {form:document.myform, isSubmitForm:true, alwaysCallback:myCallbackFunction});">
	 *  myCallbackFunction might look like:<br>
	 *  function myCallbackFunction(e, info)
	 *  {
	 *      if(info.isEnterKeyPressed)
	 *      {
	 *          // update form action or form fields appropriately, or
	 *          // do whatever.
	 *      }
	 *      else
	 *      {
	 *          // validate user input here, or just do whatever.
	 *      }
	 *  }
	 * 
	 *  <br><br>
     *  Example:  <input type="text" onkeypress="handleSubmitFormKeyPressedEvent(event, {form:document.myform, isSubmitForm:true});">	 
     *  In the above example, the form is simply submitted if the user pressed
     *  enter, otherwise no action is taken, and no callback functions are called.
     *  Example:  <input type="text" onkeypress="handleSubmitFormKeyPressedEvent(event, {isSubmitForm:false, enterPressedCallback: myEnterkeyCallback});">	 
     *  In the above example, the method "myEnterkeyCallback" is only called
     *  if the user pressed "enter", and the form is NOT submitted by the
     *  handleSubmitFormKeyPressedEvent method.  In this case the callback
     *  method will handle that detail if needed.
	 */
	function handleSubmitFormKeyPressedEvent(e, info)
	{
	    if(isEnterKeyPressed(e))
	    {
	        info.isEnterKeyPressed = true;
	        
	        if(info.alwaysCallback !== undefined && info.alwaysCallback != null)
	        	info.alwaysCallback(e, info);

            if(info.enterPressedCallback !== undefined && info.enterPressedCallback != null)
            	info.enterPressedCallback(e, info);

	        if(info.isSubmitForm == true && info.form !== undefined 
	        	&& info.form != null)
	        {
	            // submit the form:
	            info.form.submit();
	        }
	        
	        return false;
	    }

	    info.isEnterKeyPressed = false;
	    if(info.alwaysCallback !== undefined && info.alwaysCallback != null)
	    	info.alwaysCallback(e, info);
	    	
	    return true;
	}
	
   /**
	* The caller of this function needs to include the dojo ajax library and Cookie.js.
    */
	function initiateClientToWASSession(env,emailAddr,originEntity)
	{
		var entity = "NDC";
		var param = "?email=";
		param += emailAddr;
		if (originEntity)
		{
			param += "&originEntity=";
			param +=originEntity;
		}
		
		var options = {
			 url:    "/"+env+"/InitClientToWASSessionAction.do"+param,
             method: "GET",
             load: function(type, data, evt)
              	   {
						if(data!="")
						{
							entity=data;
						}
		           },
             sync: true
		};
		dojo.io.bind(options);
		
		var entityCookie = new SingleCookieValue("entity");
		entityCookie.setValue(entity);
	  	entityCookie.store(null,"/");
	}

	function getQuerystring(key, default_)
	{
	  if (default_==null) default_="";

	  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	  var qs = regex.exec(window.location.href);
	  if(qs == null)
	    return default_;
	  else
	    return qs[1];
	}
	
	function retrieveAutoSavedCart(urlStr)
	{
		var customerID = null;
	
		try
		{
			var indx = document.cookie.indexOf("shopping_cart_id=shopping_cart_id:");
			var shoppingCartID = null;
			if(indx>-1)
			{
				shoppingCartID = document.cookie.substring(indx+"shopping_cart_id=shopping_cart_id:".length);
				shoppingCartID = shoppingCartID.split(";")[0];
			}
	
			var options =
			{
			    url:    urlStr + "?shopping_cart_id="+shoppingCartID,
				sync: true,
	            load: function(type, data, evt)
	             	   {
						if(data!="")
						{
							customerID=data;
						}
		           }
			};
			dojo.io.bind(options);
		}
		catch(ex)
		{
			/* No action required */
		}
	
		var ezBuySelElem = document.getElementById("ezBuyAcctSelector");
		if(customerID && ezBuySelElem && ezBuySelElem.type && ezBuySelElem.type=="select-one")
		{
			
			ezBuySelElem.value = customerID;
			ezBuySelElem.disabled = true;
		}
		
		return false;
	}