<!--
//Iesus@PtS.sp.st
var Cart         = new Array();
var tmpArray     = new Array();
var shopperArray = new Array();
var shipeeArray  = new Array();
var shipDesc     = '';
var shipTemplate = '';
var cardDesc     = '';
var cardName     = '';
var cardNo       = '';
var cardMonth    = '';
var cardYear     = '';
var postAction   = '';
var orderID      = '';
var delim        = '|';
var taxRate      = 0;
var cartVersion  = 2.5;

function CartItem(RECREATE, prodID, qty, desc, price, opt, limit){
	if(RECREATE){
		this.prodID = prodID;
		this.qty    = qty;
		this.price  = price;
		this.desc   = desc;
		this.limit  = limit;
		this.opt    = opt;
	} else {
		this.prodID = prodID;
		this.qty    = qty;
		this.price  = getValue(prodID,'price');
		this.desc   = getValue(prodID,'desc');
		this.limit  = getValue(prodID,'limit');
		this.opt    = getOptions(prodID,'opt');
		tmpXtra     = getOptionCosts(prodID,'opt');
		if(tmpXtra != 0){
			this.price = Number(this.price) + Number(tmpXtra);
		}
	}
}

function AddItem(ItemNo){
	var madeChange    = false;
	var alreadyExists = false;
	var newItem       = false;
	var verb          = 'has';
	var Qty           = getValue(ItemNo,'');
	if(Cart.length >=20){
		msg  = 'Tyvärr går det för tillfället bara att hantera 20\n';
		msg += 'artiklar åt gången, men skicka gärna två!\n';
		alert(msg);
	} else {
		if(!Number(Qty) || Qty.indexOf('.') != -1){
			alert('Det går inte att köpa 0st av den här varan \n vi säljer inte halva varor heller.');
			clear(ItemNo);
			focus(ItemNo);
		} else {
			Qty = parseInt(Qty);
			if(Cart.length > 0){
				for(i=0; i < Cart.length; i++){
					if(Cart[i].prodID == ItemNo){

						var newOption = getOptions(ItemNo,'opt');
						if(newOption != Cart[i].opt){
							madeChange = false;
							alreadyExists = false;
						} else if(Cart[i].qty != Qty){
							ChangeQty(i,Qty);
							madeChange = true;
							alreadyExists = true;
							break;
						} else {
							alreadyExists = true;
							alert(' ' + Cart[i].prodID + ', (' + Cart[i].desc + ')\nFinns redan i din kundvagn.');
							break;
						}
					}
				}
				if(!madeChange && !alreadyExists){
					newItem = true;
				}
			} else {
				newItem = true;
			}
			if(newItem){
				Cart[Cart.length] = new CartItem(false,ItemNo,Qty);
				if(supressCart){
					alert(' ' + Cart[Cart.length - 1].prodID + ', (' + Cart[Cart.length - 1].desc + ')\nHar lagts till i kundvagnen.');
					cartToCookie();
				} else {
					displayCart();
				}
			}
		}
	}
}

function UpdateItems(numItems){
	for(itmC = 0; itmC < numItems; itmC++){
		oldQty = Cart[itmC].qty;
		newQty = getValue(Cart[itmC].prodID,String(itmC));
		if(newQty <= 0 || String(newQty).trim() == '' || !Number(newQty)){
			Cart[itmC].qty = 0;
		} else if(newQty != oldQty){
			if(Cart[itmC]== '' || newQty <= Cart[itmC]){
				Cart[itmC].qty = parseInt(newQty);
			} else {
				Cart[itmC].qty = Cart[itmC];
			}
		}
	}
	DeleteItems();
}

function DeleteItems(){
	var deletedItem;
	for(i=0; i < Cart.length; i++){
		if(Cart[i].qty > 0){
			tmpArray[tmpArray.length] = Cart[i];
		}
	}
		Cart = new Array();
	for(i=0; i < tmpArray.length; i++){
		Cart[i] = tmpArray[i];
	}
	tmpArray = new Array();
	if(supressCart && String(location).indexOf(cartPage) == -1){
		cartToCookie();
	} else {
		displayCart();
	}
}

function ChangeQty(arrayNum, newQty){
	var OK = false;
	var underLimit = true;
	if(newQty > Number(Cart[arrayNum].limit) && Cart[arrayNum]!= ''){
		alert('Oj något gick fel, men försök med att tömma kundvagnen och sedan försöka igen');
		Cart[arrayNum].qty = Cart[arrayNum].limit;
	} else {
		Cart[arrayNum].qty = newQty;
	}

	if(supressCart && String(location).indexOf(cartPage) == -1)
{
		cartToCookie();
		alert('Item ' + Cart[arrayNum].prodID + ', (' + Cart[arrayNum].desc + ')\nhar lagts till i din kundvagn.');
} 

else {
		displayCart();
	}
}

function getOptions(itemID, valType){
	var retStr = '';
	retStr     = getValue(itemID, valType);
	for(optCount = 0; optCount < 20; optCount ++){
		optName = valType + String(optCount + 1);
		tmpStr  = getValue(itemID, optName);
		if(tmpStr != ''){
			if(retStr == ''){
				retStr = tmpStr;
			} else {
				retStr += ', ' + tmpStr;
			}
		}
	}
	allOpt = retStr.split(',');
	retStr = '';
	for(optCount = 0; optCount < allOpt.length; optCount ++){
		tmpStr = allOpt[optCount].split(delim);
		if(retStr == ''){
			retStr = tmpStr[0];
		} else {
			retStr += ', ' + tmpStr[0];
		}
	}
	return retStr;
}

function getOptionCosts(itemID,valType){
	var retStr = '';
	retStr     = getValue(itemID, valType);
	for(optCount = 0; optCount < 20; optCount ++){
		optName = valType + String(optCount + 1);
		tmpStr  = getValue(itemID, optName);
		if(tmpStr != ''){
			if(retStr == ''){
				retStr = tmpStr;
			} else {
				retStr += ', ' + tmpStr;
			}
		}
	}
	allOpt = retStr.split(',');
	retStr = '';
	for(optCount = 0; optCount < allOpt.length; optCount ++){
		tmpStr = allOpt[optCount].split(delim);
		if(retStr == ''){
			retStr  = (tmpStr[1]) ? Number(tmpStr[1]) : 0;
		} else {
			retStr += (tmpStr[1]) ? Number(tmpStr[1]) : 0;
		}
	}
	return retStr;
}

function DeleteCart(){
//	if(confirm('Är du säker på att du vill\ntömma kundvagnen?')){
		Cart = new Array();
		displayCart();
//	}
}

function displayCart(){
	cartToCookie();
	document.location = cartPage;
}

function getShipDetails(){
//	var shipDetails = CheckedValue(document.NC_form['NC_form'].elements['ship_option']
//	var shipSel     = document.NC_form.ship_option;
	var shipDetails = getCheckedValue(document.forms['NC_form'].elements['ship_option']);
	shipDetails     = shipDetails.split(delim);
	shipDesc        = shipDetails[0];
	shipAmt         = shipDetails[1];
	shipPerItem     = shipDetails[2];
	shipTemplate    = shipDetails[3];	
}

function getSelectedRadio(radioGroup){
	for(i = 0; i < radioGroup.length; i ++){
		if(radioGroup[i].checked){
			return i;
		}
	}
	return 0;
}

function fillShopperForm(){
	shopperArray = getCookieVal(myStoreName + '_b');
	if(shopperArray == null || shopperArray == ''){
			shopperArray = new Array();
	}
	shipeeArray = getCookieVal(myStoreName + '_r');
	if(shipeeArray == null || shipeeArray == ''){
			shipeeArray = new Array();
	}
	if(shopperArray.length > 0){

		if(shopperArray[1] != ''){
			document.NC_form.fname.value = shopperArray[1];
		}
		
		if(shopperArray[0] != '')		
		{
			document.NC_form.email.value = shopperArray[0];
		}
		
		if(shopperArray[9] != ''){
			document.NC_form.phone.value = shopperArray[9];
		}
		
		
		if(shopperArray[3] != ''){
			document.NC_form.add1.value = shopperArray[3];
		}
		
//		if(shopperArray[4] != ''){
	//		document.NC_form.add2.value = shopperArray[4];
		//}
		
		if(shopperArray[5] != ''){
			document.NC_form.city.value = shopperArray[5];
		}

		if(shopperArray[6] != ''){
			document.NC_form.zip.value = shopperArray[6];
		}
		
		if(shopperArray[7] != ''){ setupStateSel('state',shopperArray[7]); }

		
/*		if(shipeeArray[10] != ''){
			document.NC_form.checkbox.value = shipeeArray[10];
		}
*/
/*		if(shipeeArray[11] != ''){
			document.NC_form.PF.value = shipeeArray[11];
		}
*/
	/*	if(shopperArray[12] != ''){
		document.NC_form.ship_option.value = shopperArray[12];
		}*/
					
		if(shopperArray[8] != ''){ setupCountrySel('country',shopperArray[8]); }
		if(shopperArray[2] != ''){
			document.NC_form.lname.value = shopperArray[2];
		}
	}
	if(shipeeArray.length > 0 && shipeeArray[0] != ''){
		document.NC_form.diffShip.checked = true;
		if(shipeeArray[0] != ''){
			document.NC_form.Sfname.value = shipeeArray[0];
		}
		if(shipeeArray[1] != ''){
			document.NC_form.Slname.value = shipeeArray[1];
		}
		if(shipeeArray[2] != ''){
			document.NC_form.Semail.value = shipeeArray[2];
		}
		if(shipeeArray[3] != ''){
			document.NC_form.Sadd1.value = shipeeArray[3];
		}
		if(shipeeArray[4] != ''){
			document.NC_form.Sadd2.value = shipeeArray[4];
		}
		if(shipeeArray[5] != ''){
			document.NC_form.Scity.value = shipeeArray[5];
		}
/*		if(shipeeArray[10] != ''){
			document.NC_form.checkbox.value = shipeeArray[10];
		}*/
		if(shipeeArray[11] != ''){
			document.NC_form.PF.value = shipeeArray[11];
		}
		if(shopperArray[12] != ''){
		document.NC_form.ship_option.value = shopperArray[12];
		}
		if(shipeeArray[6] != ''){ setupStateSel('Sstate',shipeeArray[6]); }
		if(shipeeArray[7] != ''){
			document.NC_form.Szip.value = shipeeArray[7];
		}
		if(shopperArray[8] != ''){ setupCountrySel('Scountry',shipeeArray[8]); }
	}
	if(useDiscount && !discountByQty && discountArray.length > 0){
		document.NC_form.Discount.value = getCookieVal(myStoreName + '_d');
	}
}

function Validate(orderOption, secureWin){
	var AllOk       = true;
	var tmpPhone    = '';
	var phoneChar   = new Array('-','(',')',' ','.');
	var goodChar    = true;
	
	shopperArray[9] = getValue('phone','');
	shopperArray[1] = getValue('fname','');
	shopperArray[2] = getValue('lname','');
	shopperArray[0] = getValue('email','');
	shopperArray[3] = getValue('add1','');
	shopperArray[4] = getValue('add2','');
	shopperArray[5] = getValue('city','');
	shopperArray[7] = getValue('state','');
	shopperArray[6] = getValue('zip','');
	shopperArray[8] = getValue('country','');
	shopperArray[10] = getValue('checkbox',''); 
	shopperArray[11] = getValue('PF','');
	shopperArray[12] = getValue('ship_option','');
	if(shopperArray[8].indexOf('-- Välj') != -1){
		shopperArray[8] = '';
	}
	for(w = 0; w < shopperArray.length; w++){
		shopperArray[w] = shopperArray[w].trim();
	}
	if(getAltShipping){
		if(getValue('Sfname','') != '' &&
		   getValue('Slname','') != '' &&
		   getValue('Semail','') != '' &&
		   getValue('Sadd1','')  != '' &&
		   getValue('Scity','')  != '' &&
		   getValue('Sstate','') != '' &&
		   getValue('Szip','')   != ''){
		   document.NC_form.diffShip.checked = true;
		}
		if(document.NC_form.diffShip.checked){
			shipeeArray[0] = getValue('Sfname','');
			shipeeArray[1] = getValue('Slname','');
			shipeeArray[2] = getValue('Semail','');
			shipeeArray[3] = getValue('Sadd1','');
			shipeeArray[4] = getValue('Sadd2','');
			shipeeArray[5] = getValue('Scity','');
			shipeeArray[6] = getValue('Sstate','');
			shipeeArray[7] = getValue('Szip','');
			shipeeArray[8] = getValue('Scountry','');
			if(shipeeArray[6].indexOf('-- Välj') != -1){
				shipeeArray[6] = '';
			}
			for(w = 0; w < shipeeArray.length; w++){
				shipeeArray[w] = shipeeArray[w].trim();
			}
		} else {
			shippeeArray = new Array();
			killCookie(myStoreName + '_r');
		}
	} else {
			shippeeArray = new Array();
			killCookie(myStoreName + '_r');
	}
	if(shopperArray[1] == '' && AllOk){
		alert('Ditt förnamn kan vara bra att ha!');
		focus('fname');
		AllOk = false;
	}
	if(shopperArray[2] == '' && AllOk){
		alert('Efternamn, posten vill tydligen ha det.');
		focus('lname');
		AllOk = false;
	}

	if(AllOk){
		if(shopperArray[0] == ''){
			alert('Vi behöver en Emailadress');
			focus('email');
			AllOk = false;
		} else {
			if(shopperArray[0].indexOf('@') == -1 || shopperArray[0].length < 7 || shopperArray[0].indexOf('.') < 1 || shopperArray[0].indexOf('.') < 1 || shopperArray[0].search(/hotmial/) > 0 || shopperArray[0].search(/hotmail.con/) > 0){
				alert('Det var ingen riktig email, du luras.');
				focus('email');
				AllOk = false;
				

		}/*else {
			if(shopperArray[0].lenght < 5){
				alert('Din email verkar inte verklig, den är under 5 tecken.');
				focus('email');
				AllOk = false;
		}else {
			if(shopperArray[0].indexOf('.') < 1){
				alert('Du har inte ens en punkt i din email.');
				focus('email');
				AllOk = false;
			}*/
		}
	}
	if(shopperArray[3] == '' && AllOk){
		alert('Din adress tack.');
		focus('add1');
		AllOk = false;
	}
	if(shopperArray[5] == '' && AllOk){
		alert('vilken postort då?');
		focus('city');
		AllOk = false;
	}
	
var Zipval = shopperArray[6];
function IsNumeric(Zipval){
		var ValidChars = " 0123456789";
		var IsNumber=true;
		var Char="";
		for (i = 0; i < Zipval.length && IsNumber == true; i++) 
		{ 
		Char = Zipval.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
	return IsNumber;
   }
		if(Zipval.length > 6 && AllOk){
   		alert('postnummret är för långt eller för kort.');
		focus('zip');
		AllOk = false;
		}
		
		if(!IsNumeric(Zipval) && AllOk){
		alert('postnummret innehåller inte bara siffror.');
		focus('zip');
		AllOk = false;
		}
		if(shopperArray[6] == '' && AllOk){
		alert('postnummret måste fyllas i.');
		focus('zip');
		AllOk = false;
		}	
	
	if(shopperArray[8].toLowerCase() == 'us'){ 
		if(shopperArray[7] == '' && AllOk){
			alert('Write yor state in the Comment box.');
			focus('comment');
			AllOk = true;
		}
		
	}
	if(shopperArray[8] == '' && AllOk){
		alert('Men välj ett då!');
		focus('country');
		AllOk = false;
	}

	/*	if(shopperArray[10] == '' && AllOk){
		alert('Du måste läsa och acceptera villkoren för att handla från oss');
		focus('checkbox');
		AllOk = false;
	}*/
	if(shopperArray[11] == '' && AllOk){
	var PF = 0;
	}else{
	var PF = 50;
	}
	if(shopperArray[8] == 'SE' && shopperArray[12] == '' && AllOk){
		alert('Det är inte tillåtet att inte välja någon frakt alls.');
		focus('ship_option');
		AllOk = false;
	}
	 
	if(shopperArray[9] == '' && AllOk){
		if(shopperArray[9] == ''){
			alert('Du glömde telefonnumret!');
			focus('phone');
			AllOk = false;
		} else {
			for(i = 0; i < shoppArray[9].length; i ++){
				for(j = 0; j < phoneChar.length; j ++){
					if(shopperArray[9].charAt(i) != phoneChar[j]){
						goodChar = true;
					} else {
						goodChar = false;
					}
				}
				if(goodChar){
					tmpPhone = tmpPhone + shopperArray[9].charAt(i);
				}
			}
			if(!Number(tmpPhone)){
				alert('Du glömde telefonnummret!');
				focus('phone');
				allOk = false;
			}
		}
	}
	if(getAltShipping){
		if(document.NC_form.diffShip.checked){
			if(shipeeArray[0] == '' && AllOk){
				alert('Please fill out the "Shipping First Name" field');
				focus('Sfname');
				AllOk = false;
			}
			if(shipeeArray[1] == '' && AllOk){
				alert('Please fill out the "Shipping Last Name" field');
				focus('Slname');
				AllOk = false;
			}
			if(shipeeArray[2] == '' && AllOk){
				alert('Please fill out the "Shipping Email" field');
				focus('Semail');
				AllOk = false;
			}
			if(shipeeArray[3] == '' && AllOk){
				alert('Please fill out the "Shipping Address" field');
				focus('Sadd1');
				AllOk = false;
			}
			if(shipeeArray[5] == '' && AllOk){
				alert('Please fill out the "Shipping City" field');
				focus('Scity');
				AllOk = false;
			}
			if(shipeeArray[8].toLowerCase() == 'us' ||
			   shipeeArray[8].toLowerCase() == 'ca'){
				if((shipeeArray[6] == '' || shipeeArray[6].indexOf('-- v') != -1) && AllOk){
					alert('Please fill out the "Shipping State/Province" field');
					focus('Sstate');
					AllOk = false;
				}
				
				if(shipeeArray[7] == '' && AllOk){
					alert('Please fill out the "Shipping Postal Code" field');
					focus('Szip');
					AllOk = false;
				}
			}
			if((shipeeArray[8] == '' || shipeeArray[8].indexOf('-- Select') != -1) && AllOk){
				alert('Please select your shipping country.');
				focus('Scountry');
				AllOk = false;
			}
		}
	}
	if(AllOk){
		setCookie(myStoreName + '_b',shopperArray.join(delim),eval(customerTime),cookiePath,unsecureDomain);
		if(shipeeArray.length > 0){
			setCookie(myStoreName + '_r',shipeeArray.join(delim),null,cookiePath,unsecureDomain);
		}
		if(useDiscount && !discountByQty && discountArray.length > 0){
			setCookie(myStoreName + '_d',document.NC_form.Discount.value,null,cookiePath,unsecureDomain);
		}
		routeToPayment(orderOption, secureWin);
	}
}


function calcDiscount(){
	var Discount = 0;
	if(useDiscount && discountArray.length > 0){
		if(discountByQty){
			for(dCount = 0; dCount < discountArray.length; dCount++){
				tmpA = discountArray[dCount].split(delim);
				if(totalQty >= tmpA[0] && totalQty <= tmpA[1]){
					return (Math.round(totalCost * tmpA[2]));
				}
			}
		} else {
			discountCode = getCookieVal(myStoreName + '_d');
			for(dCount = 0; dCount < discountArray.length; dCount++){
				tmpA = discountArray[dCount].split(delim);
				if(discountCode.toLowerCase() == tmpA[0].toLowerCase()){
					return (totalCost * tmpA[1]);
				}if(discountCode.toLowerCase() == tmpA[1].toLowerCase()){
					return (Math.round(tmpA[2]));}
			}
		}
	}
	return Math.round(Discount);
}

function calcTax(){
	var t          = 0;
	var tmpCost    = (taxShipping && Number(SnH)) ? (totalCost + Number(SnH)) : totalCost;
	var taxAddress = new Array();
	if(taxOnShipAddress && shipeeArray.length > 0){
		taxAddress = shipeeArray;
	} else {
		taxAddress = shopperArray;
	}

	if(alwaysTax){
		t = taxRateArray[0] * tmpCost;
		taxRate = taxRateArray[0];
	} else if(taxOnState && taxAddress.length > 0){
		for(tCount = 0; tCount < taxStateArray.length; tCount ++){
			if (taxAddress[6].toLowerCase() == taxStateArray[tCount].toLowerCase()){
				if(taxRateArray[tCount]){
					t = taxRateArray[tCount] * tmpCost;
					taxRate = taxRateArray[tCount];
				} else if(taxRateArray[0]){
					t = taxRateArray[0] * tmpCost;
					taxRate = taxRateArray[0];
				}
				break;
			}
		}
	} else if(taxOnZipCode && taxAddress.length > 0){
		for(tCount = 0; tCount < taxZipCodeArray.length; tCount ++){
			if (taxAddress[7].toLowerCase() == taxZipCodeArray[tCount].toLowerCase()){
				if(taxRateArray[tCount]){
					t = taxRateArray[tCount] * tmpCost;
					taxRate = taxRateArray[tCount];
				} else if(taxRateArray[0]){
					t = taxRateArray[0] * tmpCost;
					taxRate = taxRateArray[0];
				}
				break;
			}
		}
	} else if(taxOnCountry && taxAddress.length > 0){
		for(tCount = 0; tCount < taxStateArray.length; tCount ++){
			if (taxAddress[8].toLowerCase() == taxCountryArray[tCount].toLowerCase()){
				if(taxRateArray[tCount]){
					t = taxRateArray[tCount] * tmpCost;
					taxRate = taxRateArray[tCount];
				} else if(taxRateArray[0]){
					t = taxRateArray[0] * tmpCost;
					taxRate = taxRateArray[0];
				}
				break;
			}
		}
	}
	return t;
}



function calcShipping(){
	if(!shipPercent && !shipPerItem && !useShipRules && !useShipOptions){
		return shipAmt;
	}
	if(!shipPercent && shipPerItem && !useShipRules && !useShipOptions){
		return (shipAmt * totalQty);
	}
	if(shipPercent && !shipPerItem && !useShipRules && !useShipOptions){
		return (shipAmt * totalCost);
	}
	if(!useShipRules && useShipOptions){
			if(shipPerItem){
					return (shipAmt * totalQty);
			} else {
					return shipAmt;
			}
	}
	if(useShipRules && !useShipOptions){
		return getShipRule(totalCost,totalQty);
}
	if(useShipRules && useShipOptions && !gratisfrakt){
		var rule = getShipRule(totalCost)
		if(rule > 1){
		shipping = (1 * rule);
		}else{
		shipping = (1 * shipAmt);
		}
		return (shipping);
	}
		if(useShipRules && useShipOptions && gratisfrakt){
		var rule = getShipRule(totalCost,totalQty)
		return rule;
	}

	return 0;
}

	
function buildOrderID(){
	tmpDate  = new Date();
//	orderID  = String(tmpDate.getFullYear());
//	orderID += ((tmpDate.getMonth() + 1) < 10)? '0' + (tmpDate.getMonth() + 1) : (tmpDate.getMonth() + 1);
	orderID += (tmpDate.getDate()        < 10)? '0' + tmpDate.getDate()        : tmpDate.getDate();
	orderID += (tmpDate.getHours()       < 10)? '0' + tmpDate.getHours()       : tmpDate.getHours();
//	orderID += (tmpDate.getMinutes()     < 10)? '0' + tmpDate.getMinutes()     : tmpDate.getMinutes();
	orderID += (tmpDate.getSeconds()     < 10)? '0' + tmpDate.getSeconds()     : tmpDate.getSeconds();
//	orderID += shopperArray[1].charAt(0).toUpperCase();
//	orderID += shopperArray[2].charAt(0).toUpperCase();
	return orderID;
}

function routeToPayment(orderOption, secureWin){
	var s = '';
	if(useShipOptions){
		getShipDetails();
	}
	killCookie(myStoreName + '_sd');
	killCookie(myStoreName + '_sa');
	killCookie(myStoreName + '_sp');
	setCookie(myStoreName  + '_sd',shipDesc   ,eval(cartTime),cookiePath,unsecureDomain);
	setCookie(myStoreName  + '_st',shipTemplate  ,eval(cartTime),cookiePath,unsecureDomain);
	setCookie(myStoreName  + '_sa',shipAmt    ,eval(cartTime),cookiePath,unsecureDomain);
	setCookie(myStoreName  + '_sp',shipPerItem,eval(cartTime),cookiePath,unsecureDomain);
	if(orderOption == '' || orderOption == null){
		document.location = COprintVerify;
	} else {
		if(secureWin && securePath != ''){
			msg  = 'Message';
			alert(msg);
		} else {
			document.location = orderOption;
		}
	}
}

function cartToCookie(){
	for (cc = 0; cc < 10000; cc++){
		cookieVal = getCookieVal(myStoreName + '_i' + cc);
		if(cookieVal != '' && cookieVal != null){
			killCookie(myStoreName + '_i' + cc);
		} else {
			break;
		}
	}
	if(Cart.length > 0){
		for(cc = 0; cc < Cart.length; cc++){
			itemContents  = '';
			itemContents += Cart[cc].prodID + delim;
			itemContents += Cart[cc].qty    + delim;
			itemContents += Cart[cc].desc   + delim;
			itemContents += Cart[cc].price  + delim;
			itemContents += Cart[cc].opt    + delim;
			setCookie(myStoreName + '_i' + cc,itemContents,eval(cartTime),cookiePath,unsecureDomain);
		}
	}
}

function cookieToCart(){
	shopperArray = getCookieVal(myStoreName + '_b');
	if(shopperArray == null || shopperArray == ''){
			shopperArray = new Array();
	}
	shipeeArray = getCookieVal(myStoreName + '_r');
	if(shipeeArray == null || shipeeArray == ''){
			shipeeArray = new Array();
	}
	shipDesc = getCookieVal(myStoreName + '_sd');
	shipTemplate = getCookieVal(myStoreName + '_st');
	tmpShipAmt = getCookieVal(myStoreName + '_sa');
	if(tmpShipAmt != null && tmpShipAmt != ''){
		shipAmt = tmpShipAmt;
	}
	tmpShipPerItem = getCookieVal(myStoreName + '_sp');
	if(tmpShipPerItem != null && tmpShipPerItem != ''){
		tmpShipPerItem = (tmpShipPerItem == 'true') ? true : false;
		shipPerItem    = tmpShipPerItem;
	}
	if(shipPercent || useShipRules){
		shipPerItem = false;
	}
	for (cc = 0; cc < 10000; cc++){
		cookieVal = getCookieVal(myStoreName + '_i' + cc);
		if(cookieVal != '' && cookieVal != null){
			itemVal  = getCookieVal(myStoreName + '_i' + cc);
			Cart[cc] = new CartItem(true,itemVal[0],itemVal[1],itemVal[2],itemVal[3],itemVal[4],itemVal[5],itemVal[6],itemVal[7],itemVal[8],itemVal[9],itemVal[10],itemVal[11],itemVal[12],itemVal[13],itemVal[14],itemVal[15],itemVal[16],itemVal[17],itemVal[18],itemVal[19],itemVal[20]);
		} else {
			break;
		}
	}
}

function PreAddItem(ItemNo,SubFld,DefV,Msg){
	ID = String(ItemNo + SubFld);
	fldVal = getValue(ID,'');
	if(fldVal != DefV){
		AddItem(ItemNo);
	} else {
		alert(Msg);
	}
}
//-->
