
function SetCookie (name,value,expires,path,domain,secure) {
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000));
		expires=expdate;
		document.cookie = name + "=" + escape (value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	}
	// no domain was specified when creating the cookie.
	//
function 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 FixCookieDate (date) {
	var base = new Date(0);
	var skew = base.getTime(); // dawn of (Unix) time - should be 0
	if (skew > 0) date.setTime (date.getTime() - skew);// Except on the Mac - ahead of its time	
	}
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}
//
// Function to correct for 2.x Mac date bug. Call this function to
// fix a date object prior to passing it to SetCookie.
// IMPORTANT: This function should only be called *once* for
// any given date object! See example at the end of this document.
//
// Function to return the value of the cookie specified by "name".
// name - String object containing the cookie name.
// returns - String object containing the cookie value, or null if
// the cookie does not exist.
//
function GetCookie (name) {
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen) {
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg)
				return getCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;
				if (i == 0) break;
			}
		return null;
		}
	function add_to_cart(sss, aaa){//document.cookie="dealzone=";
		tmp=GetCookie ('dealzone');
		var findText="#"+sss+"#";
		var pos=0;
		var len=findText.length;					
			var expdate = new Date (); // Correct for Mac date bug - call only once for given	Date object!
			expdate.setTime (expdate.getTime() + (60 * 60 * 1000));
			//alert(expdate)
			//alert("1--> " );	
		var mess="Selected discount DEAL was ADDED to your \"Coupon Wallet\"";
		if (tmp==null) {tmp="";
					document.cookie="dealzone=" +sss+"#; expires=" + expdate;
					//alert(document.f1["discount"+sss])
					//document.manage_coupon["discount"+sss].checked=true;
					document.manage_coupon.coupons.value=1 + 1*document.manage_coupon.coupons.value;
					if (aaa!='1');//alert(mess)
					if (aaa=='2')self.location.href='view_coupons.php';}// && aaa!='2'
				else {pos=("#"+tmp).indexOf(findText);//alert(findText)
				//alert("-> " + pos);
						//else{
							if(pos == -1){
								nCookCoup=tmp.split("#");
								//alert(nCookCoup.length)
								if(nCookCoup.length>5){alert("You can only add up to 5 coupons to your \"Coupon wallet\"!");
								document.f1["discount"+sss].checked=false;
								return false;}
										document.cookie="dealzone=" + tmp + sss + "#; expires=" + expdate;				
										document.manage_coupon.coupons.value=1 + 1*document.manage_coupon.coupons.value;
										if (aaa!='1');// && aaa!='2'alert(mess)
										if (aaa=='2')self.location.href='view_coupons.php';}
								else if (aaa!='2'){preString=tmp.substring(0,pos);
										poststring=tmp.substring(pos-1+len,tmp.length);
										//alert("1--> " + preString+"---"+poststring + "=");	
										//alert(tmp);	
										document.cookie="dealzone="+preString+poststring+"; expires=" + expdate;
										document.manage_coupon.coupons.value= 1*document.manage_coupon.coupons.value - 1;
										if (aaa!='1');
									}//alert("\nThis discount DEAL was REMOVED from your \"Coupon Wallet\".\n")
								else if (aaa=='2'){alert("\nThis discount DEAL is already in your \"Coupon Wallet\".\n");}
							//}
					/**/}					//alert(GetCookie ('dealzone'));
					//return true;
		}
		
	function showDescr(ss, pp){
		nnWin=window.open('mlupld.php?pic='+ ss + '&deals=' + pp, 'window11', 'top=20,left=100,width=400,height=200,scrollbars=no');
		nnWin.focus();
		}
	function ord(ccc, aaa){ccc.value=parseFloat(ccc.value);nrd=true;
			if(ccc.value=="NaN"){var mes="\"value of Discount\"";
				if(aaa=='1')mes="\"Coupons per Email\"";
				alert("Wrong data in field " + mes);
			ccc.value=''; nrd=false;//ccc.value=aaa;
				}}
				
	function ord1(ccc, aaa){ccc.value=parseFloat(ccc.value);nrd=true;
			if(ccc.value=="NaN"){var mes="\"value of Discount\"";
				if(aaa=='1')mes="\"Coupons per Email\"";
				alert("For SKU/Barcode enter digits only");
			ccc.value=''; nrd=false;//ccc.value=aaa;
				}}
				
	function showMap(sss){
			new_window = window.open(sss, "Image",
				"top=30,left=90,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
			new_window.focus();
			}