var shipOption1 = document.createElement("OPTION")
var shipOption2 = document.createElement("OPTION")
var shipOption3 = document.createElement("OPTION")
var shipOption4 = document.createElement("OPTION")
function copyAddress(element){
        if(element.checked){
          if (returnObjById('billingFirstName').value != '') {
            returnObjById('shippingFirstName').value = returnObjById('billingFirstName').value;
          } else {
            returnObjById('shippingFirstName').value = '';
          }
          if (returnObjById('billingLastName').value != '') {
            returnObjById('shippingLastName').value = returnObjById('billingLastName').value;
          } else {
            returnObjById('shippingLastName').value = '';
          }
          if (returnObjById('billingAddress1').value != '') {
            returnObjById('shippingAddress1').value = returnObjById('billingAddress1').value;
          } else {
            returnObjById('shippingAddress1').value = '';
          }
          if (returnObjById('billingAddress2').value != '') {
            returnObjById('shippingAddress2').value = returnObjById('billingAddress2').value;
          } else {
            returnObjById('shippingAddress2').value = '';
          }
          if (returnObjById('billingCity').value != '') {
            returnObjById('shippingCity').value = returnObjById('billingCity').value;
          } else {
            returnObjById('shippingCity').value = '';
          }
          if (returnObjById('billingState').value != '') {
            returnObjById('shippingState').value = returnObjById('billingState').value;
          } else {
            returnObjById('shippingState').value = '';
          }
          if (returnObjById('billingZip').value != '') {
            returnObjById('shippingZip').value = returnObjById('billingZip').value;
          } else {
            returnObjById('shippingZip').value = '';
          }
          if (returnObjById('billingDaytimePhone1').value != '') {
            returnObjById('shippingDaytimePhone1').value = returnObjById('billingDaytimePhone1').value;
          } else {
            returnObjById('shippingDaytimePhone1').value = '';
          }
      if (returnObjById('billingDaytimePhone2').value != '') {
        returnObjById('shippingDaytimePhone2').value = returnObjById('billingDaytimePhone2').value;
      } else {
        returnObjById('shippingDaytimePhone2').value = '';
          }
      if (returnObjById('billingDaytimePhone3').value != '') {
      returnObjById('shippingDaytimePhone3').value = returnObjById('billingDaytimePhone3').value;
      } else {
      returnObjById('shippingDaytimePhone3').value = '';
          }
          updateShipOptions();
        }
}

function popUp(url,w,h,target,windowOptions) {
  if ((!target)||(target=="")) target="_blank";
  if ((!windowOptions)||(windowOptions==""))  windowOptions= 'scrollbars,titlebar,resizable';
  popupWin = window.open(url,target,'width='+w+',height='+h+','+windowOptions);
  setTimeout("popupWin.focus();",250);
}

function backupShipOptions()
{
 var sOpt1 = document.getElementById('shippingMethod');
shipOption1 = sOpt1.options[0];
shipOption2 = sOpt1.options[1];
shipOption3 = sOpt1.options[2];
shipOption4 = sOpt1.options[3];
updateShipOptions();
}

function updateShipOptions() {

  var sState=document.getElementById('shippingState').value;
  if(sState==''){
    sState=document.getElementById('billingState').value;
  }
  if(sState!=''){
  var sOpt1 = document.getElementById('shippingMethod');
sOpt1.length=0;
  if(sState=='AK' || sState=='HI'){
  	sOpt1.options[sOpt1.length] = shipOption2;
	sOpt1.options[sOpt1.length] = shipOption4;
  } else {
	sOpt1.options[sOpt1.length] = shipOption1;
	sOpt1.options[sOpt1.length] = shipOption2;
	sOpt1.options[sOpt1.length] = shipOption3;
	sOpt1.options[0].selected=true;
	}

  }
}

