//-------------------------------------------------------------//// Copies data from billing section to shipping section//-------------------------------------------------------------////- Mar 17 2005 removed $ concatenation from subtotals - new Verisign requirement -//// - Oct 28 2005 changed some shipping values// - RSH RHD Robert Hastings function formCopy(form){	form.FNAMETOSHIP.value = form.FNAME.value;	form.LNAMETOSHIP.value = form.LNAME.value;	form.ADDRESSTOSHIP.value = form.ADDRESS.value;	form.CITYTOSHIP.value = form.CITY.value;	form.STATETOSHIP.value = form.STATE.value;	form.ZIPTOSHIP.value = form.ZIP.value;	form.COUNTRYTOSHIP.value = form.COUNTRY.value;	form.EMAILTOSHIP.value = form.EMAIL.value;	form.PHONETOSHIP.value = form.PHONE.value;	form.FAXTOSHIP.value = form.FAX.value;}//-------------------------------------------------------------//// Checks the form entries for correctness//-------------------------------------------------------------//function formCheck(form){	// Billing Information	if(form.FNAME.value == ""){		alert("Please enter a Billing First Name.");		form.FNAME.focus();		return false;	}	if(form.LNAME.value == ""){		alert("Please enter a Billing Last Name.");		form.LNAME.focus();		return false;	}		if(form.ADDRESS.value == ""){		alert("Please enter an Billing Address.");		form.ADDRESS.focus();		return false;	}		if(form.CITY.value == ""){		alert("Please enter a Billing City.");		form.CITY.focus();		return false;	}		if(form.STATE.value == ""){		alert("Please enter a Billing State.");		form.STATE.focus();		return false;	}		if(form.ZIP.value == ""){		alert("Please enter a Billing Zip Code.");		form.ZIP.focus();		return false;	}			if(form.EMAIL.value.indexOf("@") == -1 || form.EMAIL.value == ""){	  alert("Please enter a proper billing email address (ie. you@yourisp.com).");	  form.EMAIL.focus();    return false;  }	// Shipping Information	if(form.FNAMETOSHIP.value == ""){		alert("Please enter a Shipping First Name.");		form.FNAMETOSHIP.focus();		return false;	}	if(form.LNAMETOSHIP.value == ""){		alert("Please enter a Shipping Last Name.");		form.LNAMETOSHIP.focus();		return false;	}		if(form.ADDRESSTOSHIP.value == ""){		alert("Please enter a Shipping Address.");		form.ADDRESSTOSHIP.focus();		return false;	}		if(form.CITYTOSHIP.value == ""){		alert("Please enter a Shipping City.");		form.CITYTOSHIP.focus();		return false;	}		if(form.STATETOSHIP.value == ""){		alert("Please enter a Shipping State.");		form.STATETOSHIP.focus();		return false;	}		if(form.ZIPTOSHIP.value == ""){		alert("Please enter a Billing Zip Code.");		form.ZIPTOSHIP.focus();		return false;	}		if(form.EMAILTOSHIP.value.indexOf("@") == -1 || form.EMAIL.value == ""){	  alert("Please enter a proper shipping email address (ie. you@yourisp.com).");	  form.EMAILTOSHIP.focus();    return false;  }    form.NAME.value = form.FNAME.value+" "+form.LNAME.value;  form.NAMETOSHIP.value = form.FNAMETOSHIP.value+" "+form.LNAMETOSHIP.value;  form.ACCT.value = form.CARDNUM.value;  setData(form);    //if((form.ADDRESS.value != form.ADDRESSTOSHIP.value)&&(!form.GIFTCARD.checked)){  //	if(confirm("Would you like to include a gift card with your purchase?")){;  //		form.GIFTCARD.click();  //	}  //}  var tmp;  if(form.GIFTCARD.checked){  	setComments(form);	tmp = "Gift Card: "+form.GIFTCOMMENT.value;  }  else{  	tmp = "Gift Card: None";  }  if(form.MAILINGLIST.checked){  	tmp = tmp+", Mailing List: Yes";  }  else{  	tmp = tmp+", Mailing List: No";  }  if(form.ABOUT.value == ""){  	tmp = tmp+", Found HH: No Value";  }  else{  	tmp = tmp+", Found HH: "+form.ABOUT.value;  }  form.DESCRIPTION.value = tmp;}//-------------------------------------------------------------//// Rounds to two decimal places//-------------------------------------------------------------//function RoundTo2dp(X){ 	whole = Math.round(X*100)/100;	whole = whole+"";	end = whole.split(".");	if(end[1].length == 0){		end[1] = "00";	}	if(end[1].length == 1){		end[1] = end[1]+"0";	}	return end[0]+"."+end[1];	 }//-------------------------------------------------------------//// Handles quantity changes on the orderform//-------------------------------------------------------------//function updateTotals(form){	if(form.MONTHS[0].checked){		var amt = form.MONTHS[0].value;		var num = 1;	}	else if(form.MONTHS[1].checked){		var amt = form.MONTHS[1].value;		var num = 3;	}	else if(form.MONTHS[2].checked){		var amt = form.MONTHS[2].value;		var num = 6;	}	else if(form.MONTHS[3].checked){		var amt = form.MONTHS[3].value;		var num = 12;	}    else if(form.MONTHS[4].checked){		var amt = form.MONTHS[4].value;		var num = 4;	}   else if(form.MONTHS[5].checked){		var amt = form.MONTHS[5].value;		var num = 3;	}	// subtotal	form.SUBTOTALDISPLAY.value = amt;		// shipping	var ship	if(form.COUNTRYTOSHIP.value == "USA"){		if(num == 1) ship = 5.95;				if(num == 3) ship = 8.95;		if(num == 6) ship = 12.95;		if(num == 12) ship = 15.95;		if(num == 4) ship = 1.95;				form.SHIPAMOUNTDISPLAY.value = RoundTo2dp(ship);		form.SHIPAMOUNT.value = RoundTo2dp(ship);	}	else{		ship = (3.95*num);		form.SHIPAMOUNTDISPLAY.value = RoundTo2dp(ship);		form.SHIPAMOUNT.value = RoundTo2dp(ship);	}		// total	var total = (amt*1.00)+(ship*1.00);	form.TOTALDISPLAY.value = RoundTo2dp(total);	form.AMOUNT.value = RoundTo2dp(total); 	form.AMT.value = form.AMOUNT.value;}//-------------------------------------------------------------//// Handles cookie to remember user info//-------------------------------------------------------------//function setData(form){	var Ret = confirm("Do you want HepHelper to remember your Order Information?");	if(Ret){		var data = "";		var today = new Date();   		var expires = new Date();		expires.setTime(today.getTime() + 1000*60*60*24*365)		for(i=0;i<24;i++){			data = data+""+form.elements[i].name+"`"+form.elements[i].value+"~";			//alert(data);		}		setCookie("hephelper",data,expires);	}	else{		deleteCookie("hephelper");	}}function getData(form){	var data = getCookie("hephelper");	if(data != null){		var elem = data.split("~");		for(i=0;i<24;i++){			//if(elem[i] != "undefined"){				temp = elem[i].split("`");				form.elements[i].value = temp[1];			//}		}	}						//	if((i!=18)&&(i!=19)&&(i!=7)&&(i!=8)){	//		var e = getCookie(form.elements[i].name);	//		if(e == null){	//			form.elements[i].value = "";	//		}else{	//			form.elements[i].value = e;	//		}	//	}	//}}// name - name of the cookie// value - value of the cookie// [expires] - expiration date of the cookie (defaults to end of current session)// [path] - path for which the cookie is valid (defaults to path of calling document)// [domain] - domain for which the cookie is valid (defaults to domain of calling document)// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission// * an argument defaults when it is assigned null as a placeholder// * a null placeholder is not required for trailing omitted argumentsfunction setCookie(name, value, expires, path, domain, secure) {  var curCookie = name + "=" + escape(value) +      ((expires) ? "; expires=" + expires.toGMTString() : "") +      ((path) ? "; path=" + path : "") +      ((domain) ? "; domain=" + domain : "") +      ((secure) ? "; secure" : "");  document.cookie = curCookie;}// name - name of the desired cookie// * return string containing value of specified cookie or null if cookie does not existfunction getCookie(name) {  var dc = document.cookie;  var prefix = name + "=";  var begin = dc.indexOf("; " + prefix);  if (begin == -1) {    begin = dc.indexOf(prefix);    if (begin != 0) return null;  } else    begin += 2;  var end = document.cookie.indexOf(";", begin);  if (end == -1)    end = dc.length;  return unescape(dc.substring(begin + prefix.length, end));}// name - name of the cookie// [path] - path of the cookie (must be same as path used to create cookie)// [domain] - domain of the cookie (must be same as domain used to create cookie)// * path and domain default if assigned null or omitted if no explicit argument proceedsfunction deleteCookie(name, path, domain) {  if (getCookie(name)) {    document.cookie = name + "=" +     ((path) ? "; path=" + path : "") +    ((domain) ? "; domain=" + domain : "") +    "; expires=Thu, 01-Jan-70 00:00:01 GMT";  }}//############################################################################function setComments(form){	var txt = prompt("Please enter a few sentences to be included on the Gift Card.","");	if((txt != null) && (txt != "")){		form.GIFTCOMMENT.value = txt;		}}//////////////////////////////////////////////////////////////////////////////////---------- Pop Up Window ----------//////////////////////////////////////////////////////////////////////////////////function popup(name,file,w,h){	var popup = null;	popup = window.open('', name, 'width='+w+',height='+h+',resizable=1,scrollbars=yes');  	if (popup != null) {    	if (popup.opener == null) {      		popup.opener = self;    		}		popup.location.href = file;	}}