function getexpirydate( nodays) {
  var UTCstring;
  Today = new Date();
  nomilli=Date.parse(Today);
  Today.setTime(nomilli+nodays*24*60*60*1000);
  UTCstring = Today.toUTCString();
  return UTCstring;
}

function getcookie(cookiename) {
  var cookiestring=""+document.cookie;
  var index1=cookiestring.indexOf(cookiename);
  if (index1==-1 || cookiename=="") return ""; 
  var index2=cookiestring.indexOf(';',index1);
  if (index2==-1) index2=cookiestring.length; 
  return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration) {
  cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
  document.cookie=cookiestring;
  if(!getcookie(name))
    return false;
  else
    return true;
}

function UpdateOption(id, index) {
	document.getElementById("newOptionID" + index).value = id;
}

function CopyBilling() {
	document.getElementById("shippingFirstName").value = document.getElementById("billingFirstName").value;
	document.getElementById("shippingLastName").value = document.getElementById("billingLastName").value;
	document.getElementById("shippingAddress1").value = document.getElementById("billingAddress1").value;
	document.getElementById("shippingAddress2").value = document.getElementById("billingAddress2").value;
	document.getElementById("shippingCity").value = document.getElementById("billingCity").value;
	document.forms[0].shippingState.selectedIndex = document.forms[0].billingState.selectedIndex;
	document.getElementById("shippingZip").value = document.getElementById("billingZip").value;
	document.forms[0].shippingCountry.selectedIndex = document.forms[0].billingCountry.selectedIndex;
	document.getElementById("shippingEmail").value = document.getElementById("billingEmail").value;
	document.getElementById("shippingPhone").value = document.getElementById("billingPhone").value;
}