var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
 

function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1) { endstr = document.cookie.length; }
 return unescape(document.cookie.substring(offset, endstr));
 }
 
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 DeleteCookie (name,path,domain) {
var today = new Date();
var expiry2 = new Date(today.getTime() - 24*60* 60 * 1000);
 if (GetCookie(name)) {
  document.cookie = name + "=" + "; expires=" + expiry2.toGMTString()
  }
 }
 
function SetCookie (name,value,expires,path,domain,secure) {
var today = new Date();
var expiry1 = new Date(today.getTime() +  24*60*60 * 1000);
 
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + expiry1.toGMTString()) +";path=/"


 }




function add(name,n_form,add_text){


cook=GetCookie("shop")
sku1=name+"|0*"

if(!isNaN(n_form)){
	if(document.forms[0][n_form].value==""){return}
	sk=sku1.split("|")
	vle=(document.forms[0][n_form].value+"||").split("|")
	sk[1]=sk[1]+"<br>"+(add_text?add_text+" ":"Size: ")+vle[0]
	if (vle[2]){sk[3]=(vle[2]/vle[1])}
	if (vle[1]){sk[4]=vle[1]}	

	sku1=sk.join("|")
}

if(cook!="" && cook !=null){
	sku=cook.replace(sku1,"")+sku1
}
else{sku=sku1}



SetCookie("shop",sku)
name=sku1
mess='<html><head><title>Shopping cart</title></head><body><b><font face="Arial" color="#0000FF" size="2">You have added to your shopping cart:</font><p><font face="Arial" color="#ff0000" size="2">'+name.split("|")[0]+'</font></b><br><font face="Arial" color="#000000" size="2">'+name.split("|")[1]+'</font></body></html>'
try{cart.close()}
catch(e){}

wid_scr=(document.all)?window.document.body.clientWidth:window.innerWidth

cart=window.open("","cart","top=200, left="+(wid_scr-220)+", width=220, height=160, resizable=1")
cart.focus()
cart.document.write(mess)

}
function view(){
window.location.href="../cart.asp"
}


function chan(n){
cook2=new Array()

a=""
j=0
for (i=1; i<n; i++){

	cook=document.f1["s"+i].value
	if (document.f1["d"+i].checked==1){
	}else{
		qty=document.f1["q"+i].value
		if (isNaN(qty)){
		alert(qty+" - NaN")
		return false
		}else{
		qty=Math.floor(qty)

		cook2[j]=cook+"|"+qty
		j++
		}
	}
}
cook=cook2.join("*")+"*"

SetCookie("shop",cook)
return true
}

function re(n){

if(chan(n))window.location.reload()
}
function check(n){
if(chan(n))window.location.href="check.asp"
}

