<!-- Begin
var o = null;
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

var browser
function beginEditing(menu)
{
	finish();
	//if(menu[menu.selectedIndex].value == "editable")
        //alert(menu.selectedIndex)
	if(menu.selectedIndex==0)
	{
		o = new Object();
		o.editOption = menu[menu.selectedIndex];
		o.editOption.old = o.editOption.text;
		
		if(o.editOption.text != "_")
		{
			if(o.editOption.text=="<--Specify Other Province-->")
				o.editOption.text = "_";
			else
				o.editOption.text += "_";
		}
		menu.blur();
		menu.focus();
		browser=navigator.appName;
		if (browser=="Microsoft Internet Explorer")
			{menu.onkeydown = keyDownHandler;}
		menu.onkeypress = keyPressHandler;
		//menu.onkeypress = keyPressHandler;
		//menu.onkeydown = keyDownHandler;

	}
	function keyDownHandler(e)
	{	
		var keyCode = (isNN)?e.which:event.keyCode;
		o.editOption.text = o.editOption.text.substring(0,o.editOption.text.length+2);
                
		if (browser=="Microsoft Internet Explorer")
			return (keyCode!=8 || keyPressHandler(e));
		else
			return false
	}
	function keyPressHandler(e)
	{
		
		menu.selectedIndex=0 //for firfox
		var option = o.editOption;
		var keyCode = (isNN)?e.which:event.keyCode;
		if(keyCode==8 || keyCode==37)
		{
			if(option.text.length>0)
			{
				option.text = option.text.substring(0,option.text.length-2)+"_";
				//document.getElementById('d').innerHTML=option.text.length
				return false;
			}
			
		}
		else if(keyCode==13){
			finish();
		} 
		else if(keyCode!=0)
		{
			option.text = option.text.substring(0,option.text.length-1) + String.fromCharCode(keyCode) + "_";
                        
			//document.getElementById('d').innerHTML=option.text.length-1
			menu[menu.selectedIndex].value =option.text.substring(0,option.text.length-1)
			if (browser=="Microsoft Internet Explorer")
				return false;
			
		}
		
		return false;
	}
	function finish()
	{
		if(o!=null)
		{
			option = o.editOption;
			if(option.text.length > 1)
			{
				option.text = option.text.substring(0,option.text.length-1);
				
			}	
			else
				option.text = option.old;
				menu.onkeypress = null;
				menu.onkeydown = null;
				o = null;
		}
	}
}

function getValue(id,txt_id)
{
	//alert("hi");
	//editable_ ="cbodetails" ;
	//alert(document.getElementById(id).options[document.getElementById(id).selectedIndex].text);

	document.getElementById(txt_id).value = document.getElementById(id).options[0].text;
}

/*function toggleProvinceList(countryList_id, provinceList_id, requiredProvince_id, event)
{
  var countryList=document.getElementById(countryList_id);
  var provinceList=document.getElementById(provinceList_id);
 //alert(countryList[countryList.selectedIndex].text)
  if(countryList[countryList.selectedIndex].text != "Canada")
  { 
    //<label id="requiredProvince"><font color="#FF0000">*</font></label>
    document.getElementById(requiredProvince_id).innerHTML="";
    var origSelectedText=provinceList.options[provinceList.selectedIndex].text;
    var origSelectedVal=provinceList.options[provinceList.selectedIndex].value;
    
    var orignLen=provinceList.length;
    provinceList.length=0;
    var opt = document.createElement("option");
    document.getElementById(provinceList_id).options.add(opt);
    opt.text = "<--Specify Other Province-->";
    opt.value = "editible";
    if((event!="change") && (origSelectedVal !="BC"))
    { //alert(origSelectedVal)
      var origOpt=document.createElement("option");
      document.getElementById(provinceList_id).options.add(origOpt);
      origOpt.text = origSelectedText;
      origOpt.value = origSelectedVal;
    }
    //alert(origSelectedVal)
    if (origSelectedVal=='editible')
    {
      for (var i=0;i<provinceList.options.length;i++)
      {
        if (provinceList.options[i].value=='editible')
        { 
          provinceList.selectedIndex=i;
          
          break;
        }
      }
    }
    else
    { 
      if(event=="change")
        provinceList.selectedIndex=0;
      else
      {if(provinceList.options.length > 1)
        provinceList.selectedIndex=1;
      }
    }
  }
  else
  {   
      document.getElementById(requiredProvince_id).innerHTML="<font color='#FF0000'>*</font>";
      var provinceCodeList=new Array("BC","AB","MB","NB","NL","NT","NS","NU","ON","PE","QC","SK","YT")
      var provinceNameList=new Array("British Columbia","Alberta","Manitoba","New Brunswick","Newfoundland","Northwest Territories",
      "Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon")
      provinceList.length=0
      for(var i=0;i<provinceCodeList.length;i++)
      {
          var opt = document.createElement("option");
          // Add an Option object to Drop Down/List Box
          document.getElementById(provinceList_id).options.add(opt);
          // Assign text and value to Option object
          opt.text = provinceNameList[i];
          opt.value = provinceCodeList[i];
      }
  }
}*/





function handle_uncompleted_province(provinceList_id, countryList_id)
{
  var countryList=document.getElementById(countryList_id);
  var provinceList=document.getElementById(provinceList_id);
  if(countryList.options[countryList.selectedIndex].text =="Canada")
  {
      if (provinceList.options[provinceList.selectedIndex].value=='editible')
          {provinceList.options[provinceList.selectedIndex].value="";}
  }
  else
  {
    if (provinceList.options[provinceList.selectedIndex].value=='editible')
      provinceList.options[provinceList.selectedIndex].value="N/A";
  }
}




function preSelectProvince(province_id, province_code)
{
	var provinceList = document.getElementById(province_id)
	for (var i=0;i<provinceList.options.length;i++)
	{
		if(province_code==provinceList.options[i].value)
			{provinceList.selectedIndex=i;}
	}
}


function toggleProvinceList(txtProvinceID, cmboProvinceID, cmboCountryID, labelID)
{
	
	var country = document.getElementById(cmboCountryID);
	var txtProvince = document.getElementById(txtProvinceID);
	var cmboProcince=document.getElementById(cmboProvinceID);
	var provLabel=document.getElementById(labelID);
	if (country.options[country.selectedIndex].text != "Canada")
	{	
		txtProvince.style.display='inline';
		cmboProcince.style.display='none';
		provLabel.innerHTML="/ State (If Applicable)";
	}
	else
	{	
		txtProvince.style.display='none';
		cmboProcince.style.display='inline';
		provLabel.innerHTML="<font color='#FF0000'>*</font>";
	}
} 

function syncaddresses() {

	document.theform['shippingAddress.address1'].value = document.theform['billingAddress.address1'].value;
	document.theform['shippingAddress.address2'].value = document.theform['billingAddress.address2'].value;
	document.theform['shippingAddress.city'].value = document.theform['billingAddress.city'].value;
	document.theform['shippingAddress.postalCode'].value = document.theform['billingAddress.postalCode'].value;
	document.theform['shippingAddress.phone'].value = document.theform['billingAddress.phone'].value;
        var shippingCountry= document.theform['shippingAddress.country_rid'];
        var billingCountry= document.theform['billingAddress.country_rid'];
        shippingCountry.selectedIndex=billingCountry.selectedIndex;
        
        var txtBillingProvince=document.theform['txtBillingAddress.province'];
        var txtShippingProvince=document.theform['txtShippingAddress.province'];
        var cmboBillingProvince=document.theform['cmboBillingAddress.province'];
        var cmboShippingProvince=document.theform['cmboShippingAddress.province'];
        
               
        //this is for Canada
        if(billingCountry.options[billingCountry.selectedIndex].text=="Canada")
        {
        	document.theform['cmboShippingAddress.province'].selectedIndex = document.theform['cmboBillingAddress.province'].selectedIndex;
        	toggleProvinceList('txtShippingAddress.province', 'cmboShippingAddress.province', 'shippingAddress.country_rid', 'shippingRequiredProvince')
        	for(var i=0;i<cmboShippingProvince.options.length;i++)
        	{
        	  if(cmboShippingProvince.options[i].text==cmboBillingProvince.options[cmboBillingProvince.selectedIndex].text)
        	  {   
        	      cmboShippingProvince.selectedIndex=i;
        	      break;
        	  }
        	}
       	}
       	else
       	{
       		toggleProvinceList('txtShippingAddress.province', 'cmboShippingAddress.province', 'shippingAddress.country_rid', 'shippingRequiredProvince')
       		txtShippingProvince.value=txtBillingProvince.value;
       	}
}

function updateHiddenProvince(txtProvinceID, cmboProvinceID, hiddenInputID)
{
	var hiddenInput = document.getElementById(hiddenInputID);
	var txtProvince=document.getElementById(txtProvinceID);
	
	if(txtProvince.style.display=='none')
	{
		var cmboProvince=document.getElementById(cmboProvinceID);
		hiddenInput.value=cmboProvince.options[cmboProvince.selectedIndex].value;
	}
	else
	{
		if(txtProvince.value != '')
			hiddenInput.value = txtProvince.value;
		else
			hiddenInput.value='N/A';
	}
}