function preview(previewURL) {

	var f = document.forms['shipCalc2'];
	var select = f.elements['shipMethod'];
	if (select.selectedIndex >= 0) {
		selectedMethod = select.options[select.selectedIndex].text;
	}
	destZip = f.elements['destZip'].value;
	shipDate = f.elements['shipDate'].value;
	reloadShipping = 1;

	Set_Cookie("strings", pack(varr_string), cartexp, '/');
	Set_Cookie("numbers", pack(varr_number), cartexp, '/');
	Set_Cookie('CART', CART, cartexp, '/');
	
	//if a saturday date was clicked
	if (previewURL) {
		url = document.location.href;
		
		//saturday clicked and on arrival date page or the checkout page
		if( (url.match("ArrivalDate") != null) || (url.match("Checkout.bok?smode=checkout")) ){
			
			//check to see if there is a packfee, if so, se that to the num of saturday fees
			if(document.getElementById('packfeeQty2'))
				var numSat = document.getElementById('packfeeQty2').value
			else
				var numSat = 0;
			
			var satFeeCount = 0;	
			
			//saturday clicked and on page, there is a saturday fee (dont update or add anymore)
			if(document.getElementById('satfeeDel')){
				 document.location.href = previewURL;
			}
		    //saturday clicked and on page, there isn't a saturday fee.  We need to add one
		    else{
					document.location.href = '/Cart.bok?smode=add&product_no=23&qty='+numSat;
			}
		}
		//saturday clicked and on the Cart.bok page
		else if(url.match("Cart.bok")){
			document.location.href = previewURL;
		}
		//saturday clicked, on a different page (most likely detail.bok"
		else{
			if(document.getElementById('satfeeDel') == null){
				//var numSat = Get_Cookie('PackageCount');
				if(document.getElementById('packfeeQty2'))
					var numSat = document.getElementById('packfeeQty2').value
				else
					var numSat = 0;	
					
		   		Set_Cookie('hasSatFee', 'yes', cartexp, '/');
			    document.location.href = '/Cart.bok?smode=add&product_no=23&qty='+numSat;

			}
			else{
				document.location.href = '/Cart.bok?smode=update';
			}
		}
	} 
	//if a day other than saturday was clicked
	else {
		/*var url = document.location.href;
		if (document.location.search) {
			url += "&";
		} else {
			url += "?";
		}
		document.location.href = url + Math.random();*/
		
		var url = document.location.href;
		
		if (document.location.search) {
			url += "&";
		} else {
			url += "?";
		}
		
		//didn't click saturday, in the cart template
		if(url.match("Cart.bok") != null){
			document.getElementById('cart1').submit();			
		}
        //saturday not clicked, and not in the cart
		else{
			//saturday not clicked, not in the cart template, there is currently a saturday fee.  We need to take it out
			if(document.getElementById('satfeeDel')){
				document.getElementById('satfeeDel').value = 0;
				Set_Cookie('hasSatFee', 'no', cartexp, '/');
				document.getElementById('arrivalCart').submit();

			}
			//saturday not clicked, not in the cart template, we only need to change the date and do nothing else
			else{
				//prompt("im in the bottom else");
				document.location.href = url + Math.random();	
			}
		}
	
		
		/*
			if(document.getElementById('satfeeDel')){
				document.getElementById('satfeeDel').value = 0;
				document.getElementById('formDel').submit();
			}
			else{
				document.location.href = '/Cart.bok?smode=update';
			}
		*/
	}
}


function zippreview() {
	var f = document.cart;
	if (f.cartZip.value=="override") {
		alert('Override mode');
		f.cartZip.value = '';
		override = 1;
	}
	if (f.cartZip.value=="cancel") {
		alert('Cancel override mode');
		f.cartZip.value = '';
		override = 0;
	}
	
	Set_Cookie("strings", pack(varr_string), cartexp, '/');
	Set_Cookie("numbers", pack(varr_number), cartexp, '/');
	Set_Cookie('CART', CART, cartexp, '/');
//	preview();
}

function shipOption(text, rate) {
	day = new Date(shipDate);
	if(text == "" || rate=="" || rate=="$0.00")
	   return '';
	
    
		if (selectedMethod == '' || selectedMethod==null) {
		    
		    selectedMethod = text.substr(0,1);
		}
		
		var tempLetter = selectedMethod.substr(0,1);
		
		var selected = '';
		//alert("selectedMethod="+selectedMethod+"\ntext="+text.substr(0,1));
		if (tempLetter == text.substr(0,1) || (day.getDay()==6)) {
			selected = ' SELECTED';
			shipping = rate;
		}
		return '<option'+selected+'>'+text+'</option>';
	
}

function shipOptions() {
	var ret = '';
    if(selectedMethod.substr(0,1)==2 && (method2Day=="" || method2Day==null)){
		selectedMethod="";
	}
	if(selectedMethod.substr(0,1).toLowerCase()=="s" && (methodStandard=="" || methodStandard==null)){
		selectedMethod="";
	}
	ret += shipOption(method2Day, rate2Day);
	ret += shipOption(methodStandard, rateStandard);
	ret += shipOption(methodNextDay, rateNextDay);
	return ret;
}


