// pop-up window functionfunction popWin(page) {	window.open(page, "helpWin", "width=400,height=350,scrollbars=yes,status=yes,resizable=yes");}// create expiration date for 30 daysvar thirtydays = new Date();var expDate = thirtydays.getTime() + (60 * 60 * 24 * 30 * 1000);thirtydays.setTime(expDate);// set date for immediate expiration var expireNow = new Date();// get the value of the specified cookie (name)function readCookie(name) {    var start = document.cookie.indexOf(name+"=");    var len = start+name.length+1;    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;    if (start == -1) return null;    var end = document.cookie.indexOf(";",len);    if (end == -1) end = document.cookie.length;  //begin modification    var string_value = unescape(document.cookie.substring(len,end));	var numeric_value = parseInt(string_value);	return numeric_value; }// read the value of the quantity of each video (from cookies)var vid1_qty = readCookie("vid1");var vid2_qty = readCookie("vid2");var vid3_qty = readCookie("vid3");var vid4_qty = readCookie("vid4");// calculates subtotal for each video based on value retireved from cookiefunction subTotal(qty) {	var item_price = 24.95;	return item_price * qty;}// calculates grand total by adding subtotalsfunction endTotal(a,b,c,d) {	return a + b + c + d;}// assigns values to subtotal variablesvar vid1_subtotal = subTotal(vid1_qty);var vid2_subtotal = subTotal(vid2_qty);var vid3_subtotal = subTotal(vid3_qty);var vid4_subtotal = subTotal(vid4_qty);var grandTotal = endTotal(vid1_subtotal,vid2_subtotal,vid3_subtotal,vid4_subtotal);// fixes problem with improper decimal points on subtotalsfunction fixNumString(number) {  // input the number (subtotal, total) in string form, returnd string with decimal 0's	var oldString = number.toString();	var result = oldString.match(/\.+\d+\d/);	if(result == null) {		var fixedNumber = oldString + "0";	}	else {		var fixedNumber = oldString;	}	// begin IE long decimal bug fix	var number_end = oldString.indexOf(".") + 3;	var fixed = fixedNumber.substring(0,number_end);	return fixed;}// function that builds the cart HTMLfunction makeCart() {  	// if cart is empty, display text only	if(((vid1_qty == null) || (vid1_qty == 0)) && ((vid2_qty == null) || (vid2_qty == 0)) && ((vid3_qty == null) || (vid3_qty == 0)) && ((vid4_qty == null) || (vid4_qty == 0))) {		var help_page = "'help_cookies.html'";		document.write('<font face="Verdana,Arial,Helvetica">Your shopping cart currently contains no items.</font>');		document.write('<p><font face="Verdana,Arial,Helvetica" size="2">If you have added an item to the cart, and receive this message, you may not have &quot;cookies&quot; enabled on your web browser. </font>');		document.write('<a href="javascript:popWin(' + help_page + ')"><font face="Verdana,Arial,Helvetica" color="#ffcc66" size="2">Click here for help with &quot;cookies.&quot;</font></a>');	}	else {  // write HTML for the FORM		document.write('<font face="Verdana,Arial,Helvetica">');		document.write('<form name="CartForm" method="post">');		document.write('<table border="1" cellpadding="2" cellspacing="0" width="390">');		document.write('<tr>');		document.write('<td width="18%" bgcolor="#ffcc66" align="center">');		document.write('<font face="Verdana,Arial,Helvetica" color="black" size="2"><b>Quantity</b></font></td>');		document.write('<td bgcolor="#ffcc66" align="center">');		document.write('<font face="Verdana,Arial,Helvetica" color="black" size="2"><b>Item</b></font></td>');		document.write('<td width="18%" bgcolor="#ffcc66" align="center">');		document.write('<font face="Verdana,Arial,Helvetica" color="black" size="2"><b>Subtotal</b></font></td>');		document.write('</tr>');		// item specific data			// video1		if((vid1_qty != null) && (vid1_qty != 0)) {			document.write('<tr>');			document.write('<td width="18%" align="center">');			document.write('<input type="text" name="vid1_qty_txt" size="3" maxlength="3" value=' + vid1_qty + '></td>');			document.write('<td align="left">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">Video # 1 - Intro to Qi Gong</font></td>');			document.write('<td width="18%" align="right">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">$' + fixNumString(vid1_subtotal) + '</font></td>')  /			document.write('</tr>');		}			// video2		if((vid2_qty != null) && (vid2_qty != 0)) {			document.write('<tr>');			document.write('<td width="18%" align="center">');			document.write('<input type="text" name="vid2_qty_txt" size="3" maxlength="3" value=' + vid2_qty + '></td>');			document.write('<td align="left">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">Video # 2 - Intro to Nei Gong</font></td>');			document.write('<td width="18%" align="right">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">$' + fixNumString(vid2_subtotal) + '</font></td>')  /			document.write('</tr>');		}			// video3		if((vid3_qty != null) && (vid3_qty != 0)) {			document.write('<tr>');			document.write('<td width="18%" align="center">');			document.write('<input type="text" name="vid3_qty_txt" size="3" maxlength="3" value=' + vid3_qty + '></td>');			document.write('<td align="left">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">Video # 3 - 10 Minute Sessions</font></td>');			document.write('<td width="18%" align="right">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">$' + fixNumString(vid3_subtotal) + '</font></td>')  /			document.write('</tr>');		}			// video4		if((vid4_qty != null) && (vid4_qty != 0)) {			document.write('<tr>');			document.write('<td width="18%" align="center">');			document.write('<input type="text" name="vid4_qty_txt" size="3" maxlength="3" value=' + vid4_qty + '></td>');			document.write('<td align="left">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">Video # 4 - 5 Minute Sessions</font></td>');			document.write('<td width="18%" align="right">');			document.write('<font face="Verdana,Arial,Helvetica" size="2">$' + fixNumString(vid4_subtotal) + '</font></td>')  /			document.write('</tr>');		}		// closing data (end table and write submit button)		document.write('<tr>');		document.write('<td align="center" width="18%" bgcolor="#FFCC66"><font face="Verdana,Arial,Helvetica"><input type="button" value="Update" name="UpdateQty" onClick="updateCart()"></font></td>');		document.write('<td bgcolor="#FFCC66" colspan="2"><font face="Verdana,Arial,Helvetica" size="2" color="black">Click &quot;Update&quot; when making changes in Quantity.</font></td>');		document.write('</tr>');		document.write('<tr><td width="18%" height="16"></td><td></td><td width="18%"></td></tr>'); // empty row		document.write('<tr>');		document.write('<td bgcolor="#ffffff" colspan="2" align="left">');		document.write('<font face="Verdana,Arial,Helvetica" color="black" size="2"><b>Subtotal:</b></font></td>');		document.write('<td bgcolor="#ffffff" width="18%" align="right">');		document.write('<font face="Verdana,Arial,Helvetica" color="black" size="2"><b>$' + fixNumString(grandTotal) + '</b></font></td>'); 		document.write('</tr>');		document.write('</table>');		document.write('<br><br>');		document.write('<div align="right"><input type="button" value="Continue to Checkout &gt;&gt;" name="submitVerisign" onClick="goCheckout()"></div>');  // goCheckout() function resides in cart.html		document.write('</form>');		document.write('</font>');	}}function updateCart() {	// video # 1	if((vid1_qty != null) && (vid1_qty != 0))  {		if(document.CartForm.vid1_qty_txt.value == 0) {			document.cookie = "vid1=0; expires=" + expireNow.toGMTString();		}		else 			document.cookie = "vid1=" + document.CartForm.vid1_qty_txt.value + "; expires=" + thirtydays.toGMTString();	}	// video # 2	if((vid2_qty != null) && (vid2_qty != 0))  {		if(document.CartForm.vid2_qty_txt.value == 0) {			document.cookie = "vid2=0; expires=" + expireNow.toGMTString();		}		else 			document.cookie = "vid2=" + document.CartForm.vid2_qty_txt.value + "; expires=" + thirtydays.toGMTString();	}	// video # 3	if((vid3_qty != null) && (vid3_qty != 0))  {		if(document.CartForm.vid3_qty_txt.value == 0) {			document.cookie = "vid3=0; expires=" + expireNow.toGMTString();		}		else 			document.cookie = "vid3=" + document.CartForm.vid3_qty_txt.value + "; expires=" + thirtydays.toGMTString();	}	// video # 4	if((vid4_qty != null) && (vid4_qty != 0))  {		if(document.CartForm.vid4_qty_txt.value == 0) {			document.cookie = "vid4=0; expires=" + expireNow.toGMTString();		}		else 			document.cookie = "vid4=" + document.CartForm.vid4_qty_txt.value + "; expires=" + thirtydays.toGMTString();	}	location.reload();  // refresh the page}		