
function GetSizes(Frm_Num){
	//make sure the cookies are there
	var itemspcf
for (var i=1; i < 6; i++) {
itemspcf = "item" + i
if (GetCookie(itemspcf)== null){
	SetCookie (itemspcf, 0,null,"/");
	//alert("set cookie" + itemspcf + " to zero!!!")	
}	
itemspcf = "size" + i
if (GetCookie(itemspcf)== null){
SetCookie (itemspcf, 0,null,"/");
//alert("set cookie" + itemspcf + " to zero!!!")		
}
itemspcf = "quantity" + i
if (GetCookie(itemspcf)== null){
SetCookie (itemspcf, 0,null,"/");
//alert("set cookie" + itemspcf + " to zero!!!")		
}		
}
var size_ch2 = " "		
var size_ch1 = document.forms[Frm_Num].size1.options[document.forms[Frm_Num].size1.selectedIndex].text
if (document.forms[Frm_Num].size2.value == "no"){
//alert("one size")
var size_ch2 = " "
}else{
//alert("two sizes")
var size_ch2 = "-" + document.forms[Frm_Num].size2.options[document.forms[Frm_Num].size2.selectedIndex].text
}

var size_num = ""
	//get the size(s) and set the cookie
	var curr_cart = GetCookie("cart_num")
	if (curr_cart== null){
curr_cart = 1
var size_num = "size" + 1
}
	
for (var i=1; i < 6; i++) {
if (curr_cart==i){
var size_num = ("size" + i)
//add 1 to the cart_num value
} 
}

var my_size =  size_ch1 + size_ch2
SetCookie(size_num, my_size, null,"/");
	
	}


function SetButtons(){
	
	//THIS IS NOT BE NEEDED NOW THAT NETSCAPE IS FIXED
if(navigator.appName == "Netscape"){
	for (var i=0; i < document.images.length; i++) {
		var j = document.images[i].src
		var k = document.images[i].src.length
		
	if(document.images[i].src.lastIndexOf("buybutton.gif", k)> 1){
	document.images[i].src ="netscape.gif"
}
}
}
}

function ChkBrowser(){

if(navigator.appName == "Netscape"){
	document.location = "ordaff2.shtml"
}else{
document.location = "ordaff2.shtml"
}
} 

function GtRef(){
	//get the referring document
	var csdocref
	csdocref = "myrefdoc"
if (GetCookie(csdocref)== null){
	SetCookie (csdocref,document.referrer,0,"/");
	var mycookie3 = GetCookie(csdocref)
	//alert("cookie set to " + mycookie3)	
}	
	
	}

function GtCkies(){
	
	//clear cc if user clicks back
	//took out 2-2-03
	//document.form1.cc_num.value=""
//check for null cookies

var itemspcf
for (var i=1; i < 6; i++) {
itemspcf = "item" + i
if (GetCookie(itemspcf)== null){
	SetCookie (itemspcf, 0,null,"/");	
}	
itemspcf = "size" + i
if (GetCookie(itemspcf)== null){
SetCookie (itemspcf, 0,null,"/");	
}
itemspcf = "quantity" + i
if (GetCookie(itemspcf)== null){
SetCookie (itemspcf, 0,null,"/");	
}		
	
}
//check the browser
//ChkBrowser()	
//now.....get the items
get_items()
for (var i=1; i < 6; i++) {
update(i)
}
}

function setdata(option_num, size_num){// option_num is the product number, size_num is the form number
	//get and set the size value
		GetSizes(size_num)
if(option_num > 0){
	//get rid of the temporary value on the color cookie
	SetCookie ("col_cookie", 0,null,"/");			
var expdate = new Date ();
FixCookieDate (expdate); // Correct for Mac date bug 
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); // 24 hrs from now 

//find and add to the cart_num
var curr_cart_num = GetCookie("cart_num")
//alert("first item is " + curr_cart_num)
if (curr_cart_num == null){
curr_cart_num = 1
	//alert("now the value is " + curr_cart_num)
}
if (curr_cart_num >0) {
	var ncart_num = eval(curr_cart_num) + eval(1)
	//alert("added 1 to num it is now " + ncart_num)
	}

SetCookie ("cart_num", ncart_num,null,"/");
//alert("from setdata current cart Number is " + ncart_num)

for (var i=1; i < 6; i++) {
if (curr_cart_num==i){
var item_num = ("item" + i)
var quant_num = ("quantity" + i)
} 
// NOW add 1 to the cart number
SetCookie ("cart_num", ncart_num,null,"/");
}
SetCookie(item_num, option_num,null,"/");

//Check quantity if == 0 make it 1
var quant_chk = GetCookie(quant_num)
if (quant_chk == "0"){
	SetCookie(quant_num, 1,null,"/");
}
//send to order page
ChkBrowser()
}
else{
	alert("Please select valid styles/sizes from drop down menus, then click buy")
	}
}

//***************SET AND GET THE VALUES*********************************************
function setsize(ans_num){
tf = document.form1	
//set set all the initial cookie values here
//set quantity
SetCookie("quantity1", tf.quantity1.selectedIndex,null,"/");
SetCookie("quantity2", tf.quantity2.selectedIndex,null,"/");
SetCookie("quantity3", tf.quantity3.selectedIndex,null,"/");
SetCookie("quantity4", tf.quantity4.selectedIndex,null,"/");
SetCookie("quantity5", tf.quantity5.selectedIndex,null,"/");
//set item
SetCookie("item1", tf.menu1.options.selectedIndex,null,"/");
SetCookie("item2", tf.menu2.options.selectedIndex,null,"/");
SetCookie("item3", tf.menu3.options.selectedIndex,null,"/");
SetCookie("item4", tf.menu4.options.selectedIndex,null,"/");
SetCookie("item5", tf.menu5.options.selectedIndex,null,"/");
//set size
SetCookie("size1", tf.size1.value,null,"/");
SetCookie("size2", tf.size2.value,null,"/");
SetCookie("size3", tf.size3.value,null,"/");
SetCookie("size4", tf.size4.value,null,"/");
SetCookie("size5", tf.size5.value,null,"/");


//also update cart_num
tf = document.form1
//check out the cart num
var cart_tag = 0
if (tf.menu1.options.selectedIndex > 0){
cart_tag = eval(cart_tag + 1)
}
if (tf.menu2.options.selectedIndex > 0){
cart_tag = eval(cart_tag + 1)
}
if (tf.menu3.options.selectedIndex > 0){
cart_tag = eval(cart_tag + 1)
}
if (tf.menu4.options.selectedIndex > 0){
cart_tag = eval(cart_tag + 1)
}
if (tf.menu5.options.selectedIndex > 0){
cart_tag = eval(cart_tag + 1)
}

var ncart_num = eval(cart_tag) + eval(1)
SetCookie ("cart_num", ncart_num,null,"/");

if (ans_num == 1){
//alert("go back " )
history.back()
}
}

//***************************************************************


function get_items(){
tf = document.form1

//SET PRODUCT
tf.menu1.options[GetCookie("item1")].selected = true
tf.menu2.options[GetCookie("item2")].selected = true
tf.menu3.options[GetCookie("item3")].selected = true
tf.menu4.options[GetCookie("item4")].selected = true
tf.menu5.options[GetCookie("item5")].selected = true

//SET QUANTITY
//wm = window.parent.hiddenfra.frmhide

tf.quantity1.options[GetCookie("quantity1")].selected = true
tf.quantity2.options[GetCookie("quantity2")].selected = true
tf.quantity3.options[GetCookie("quantity3")].selected = true
tf.quantity4.options[GetCookie("quantity4")].selected = true
tf.quantity5.options[GetCookie("quantity5")].selected = true
//SET SIZE

tf.size1.value = GetCookie("size1")
tf.size2.value = GetCookie("size2")
tf.size3.value = GetCookie("size3")
tf.size4.value = GetCookie("size4")
tf.size5.value = GetCookie("size5")
    
                }
                                
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function del_item1(item_num){

//first set all the values that are there
setsize(0)
//change the cart number
var currcart= GetCookie("cart_num")
var nccart = eval(currcart -1)	
SetCookie ("cart_num", nccart,null,"/");

//del item 1 move others up
for (var j=1; j < 6; i++) {
if(item_num==j){
for (var i=j; i < 6; i++) {
var gval = "item" + i, sval = "item" + eval(i+1), nval = GetCookie(sval)
SetCookie (gval,nval ,null,"/");
var gval = "size" + i, sval = "size" + eval(i+1), nval = GetCookie(sval)
SetCookie (gval,nval ,null,"/");
var gval = "quantity" + i, sval = "quantity" + eval(i+1), nval = GetCookie(sval)
SetCookie (gval,nval ,null,"/");
if (i==5){
SetCookie (gval,0 ,null,"/");
}
}
}
if(j==1){
document.form1.menu1.options[0].selected = true
}
if(j==2){
document.form1.menu2.options[0].selected = true
}
if(j==3){
document.form1.menu3.options[0].selected = true
}
if(j==4){
document.form1.menu4.options[0].selected = true
}
if(j==5){
document.form1.menu5.options[0].selected = true
}

}
				
//*********************************
setsize(0)
get_items()
update(item_num)		
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//DELETE ITEMS
function del_item(item_num){
//I know it ain't pretty but it works :)
//first set all the values that are there
setsize(0)


//change the cart number
var currcart= GetCookie("cart_num")
var nccart = eval(currcart -1)	
SetCookie ("cart_num", nccart,null,"/");


//del item 1 move others up
if(item_num==1){
document.form1.menu1.options[0].selected = true
SetCookie("item1", GetCookie("item2"),null,"/");
SetCookie("quantity1", GetCookie("quantity2"),null,"/");
SetCookie("size1", GetCookie("size2"),null,"/");
SetCookie("item2", GetCookie("item3"),null,"/");
SetCookie("quantity2", GetCookie("quantity3"),null,"/");
SetCookie("size2", GetCookie("size3"),null,"/");
SetCookie("item3", GetCookie("item4"),null,"/");
SetCookie("quantity3", GetCookie("quantity4"),null,"/");
SetCookie("size3", GetCookie("size4"),null,"/");
SetCookie("item4", GetCookie("item5"),null,"/");
SetCookie("quantity4", GetCookie("quantity5"),null,"/");
SetCookie("size4", GetCookie("size5"),null,"/");
SetCookie("item5", "0",null,"/");
SetCookie("quantity5", "0",null,"/");
SetCookie("size5", "0",null,"/");

}
//del item 2 move others up
document.form1.menu2.options[0].selected = true
if(item_num==2){
SetCookie("item2", GetCookie("item3"),null,"/");
SetCookie("quantity2", GetCookie("quantity3"),null,"/");
SetCookie("size2", GetCookie("size3"),null,"/");
SetCookie("item3", GetCookie("item4"),null,"/");
SetCookie("quantity3", GetCookie("quantity4"),null,"/");
SetCookie("size3", GetCookie("size4"),null,"/");
SetCookie("item4", GetCookie("item5"),null,"/");
SetCookie("quantity4", GetCookie("quantity5"),null,"/");
SetCookie("size4", GetCookie("size5"),null,"/");
SetCookie("item5", "0",null,"/");
SetCookie("quantity5", "0",null,"/");
SetCookie("size5", "0",null,"/");
}
//del item 3 move others up
document.form1.menu3.options[0].selected = true
if(item_num==3){
SetCookie("item3", GetCookie("item4"),null,"/");
SetCookie("quantity3", GetCookie("quantity4"),null,"/");
SetCookie("size3", GetCookie("size4"),null,"/");
SetCookie("item4", GetCookie("item5"),null,"/");
SetCookie("quantity4", GetCookie("quantity5"),null,"/");
SetCookie("size4", GetCookie("size5"),null,"/");
SetCookie("item5", "0",null,"/");
SetCookie("quantity5", "0",null,"/");
SetCookie("size5", "0",null,"/");
}
//del item 4 move others up
document.form1.menu4.options[0].selected = true
if(item_num==4){
SetCookie("item4", GetCookie("item5"),null,"/");
SetCookie("quantity4", GetCookie("quantity5"),null,"/");
SetCookie("size4", GetCookie("size5"),null,"/");
SetCookie("item5", "0",null,"/");
SetCookie("quantity5", "0",null,"/");
SetCookie("size5", "0",null,"/");
}
//del item 5 move others up
document.form1.menu5.options[0].selected = true
if(item_num==5){
	//FIXED THIS ERROR ON 5-28-01
SetCookie("item5", "0",null,"/");
SetCookie("quantity5", "0",null,"/");
SetCookie("size5", "0",null,"/");
				}
				//update what we did
		tf = document.form1
tf.menu1.options[GetCookie("item1")].selected = true
tf.menu2.options[GetCookie("item2")].selected = true
tf.menu3.options[GetCookie("item3")].selected = true
tf.menu4.options[GetCookie("item4")].selected = true
tf.menu5.options[GetCookie("item5")].selected = true
//QTY
tf.quantity1.options[GetCookie("quantity1")].selected = true
tf.quantity2.options[GetCookie("quantity2")].selected = true
tf.quantity3.options[GetCookie("quantity3")].selected = true
tf.quantity4.options[GetCookie("quantity4")].selected = true
tf.quantity5.options[GetCookie("quantity5")].selected = true
//SIZE
tf.size1.value =GetCookie("size1")
tf.size2.value =GetCookie("size2")
tf.size3.value =GetCookie("size3")
tf.size4.value =GetCookie("size4")
tf.size5.value =GetCookie("size5")

//*********************************
setsize(0)
get_items()
for (var i=1; i < 6; i++) {
update(i)
}		
}


//***************COKIE STUFF HERE
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime (date.getTime() - skew);
}
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 SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

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";
  }
}
//*************END COOKIE STUFF

