// This script is the sole property of 4D Internet Solutions. Copyright 2007, 4D Internet Solutions, Inc. All rights reserved.
//read cookie
var cartCookie = unescape(readCookie('mssFloatingCart'));

function writeCart(){
	var links = new Array();
	var titles = new Array();
	var pids = new Array();
	var prices = new Array();
	var units = new Array();
	var total = "";
	if (cartCookie && cartCookie != ""){
		var eachArray = cartCookie.split("^");
		if (eachArray[0] && eachArray[0].length > 0){
			var eachElement = eachArray[0].split("|:|");
			total = eachElement[0];
			}
		
		if (eachArray[1] && eachArray[1].length > 0) {
			var numItems = eachArray[1].split("|:|").length - 1;
			} else {
				return null; 
				}
		// write floating cart header and number of items in cart	
		if (numItems > 0 ){
			document.write("<div class=\"fcartBG\"><div class=\"floatingCartHeader\"><a href=\"http://order.store.yahoo.net/cgi-bin/wg-order?yhst-16389103795725\"><img src=\"http://p7.hostingprod.com/@detailsformen.com/img/scart1.gif\" width=\"25\" height=\"17\" border=\"0\" /></a>&nbsp;&nbsp;Items in your Cart: " + numItems + "</div>");
			}
		// loop through each array from cookie
		for (i = 0; i < eachArray.length -1; i++){
			if (eachArray[i] && eachArray[i] != ""){
				var eachElement = eachArray[i].split("|:|");	
				var x = 0;
				// build javascript arrays from cookie data
				for (j = 0; j < eachElement.length; j++){
					if (eachElement[j] && eachElement[j] != ""){
						if (i == 1){
							links[x] = eachElement[j]
							}
						if (i == 2){
							titles[x] = eachElement[j]; 
							}
						if (i == 3){
							pids[x] = eachElement[j]; 
							}
						if (i == 4){
							prices[x] = eachElement[j]; 
							}
						if (i == 5){
							units[x] = eachElement[j]; 
							}
						x = x + 1;
						}
					}
				}
			}
		//loop through each cookie array and write the cart  using the javascript arrays
		for (i = 0; i < numItems; i++){
			if (eachArray[i] && eachArray[i] != "" && links[i] && links[i] != ""){
				document.write("<div class=\"fcart\">");
				//document.write("<div class=\"fcart-name\"><a href=\"" + links[i].toLowerCase() + "\">" + titles[i] + "</a></div>");
				//document.write("<div class=\"fcart-price\">Price: " + prices[i] + "</div>");
				//document.write("<div class=\"fcart-qty\"> Qty: " + units[i] + "</div>");
				document.write("</div>");
				}
			}
		// write subtotal	
		if (numItems > 0 ){
			document.write("<div class=\"fcart-total\">Sub Total: " + total + "&nbsp;&nbsp;&nbsp;<a href=http://order.store.yahoo.net/cgi-bin/wg-order?yhst-16389103795725>Checkout</a></div></div>");
			}
		}
	}
