	
	var RETAIL_PARTNER = false;
	var MIN_ORDER = 100;
	var CART_SUBTOTAL = 0;
	
	function processShoppingCart( id, act )
	{
		if( RETAIL_PARTNER == true && parseFloat( CART_SUBTOTAL ) < MIN_ORDER ){
			alert('Please note: minimum Retail Partner order is $100.00, please add more items to your cart. Thank you!');
			return false;
		}
		
		if( act != '' ){
			$('#'+id).attr('action',act);
		}
		
		$('#'+id).submit();

		return false;

	}
	
	function updateShipping(taxSch)
	{
		var subtotal = document.getElementById('subtotal').innerHTML;
		subtotal = Math.round(subtotal.substring(1)*100)/100;
		var type = document.getElementById('Order[ShippingOption]').value;
		var tax = document.getElementById('tax').innerHTML;
		//alert("tax schedule is: "+taxSch);
		tax = Math.round(tax.substring(1)*100)/100;
		var total = document.getElementById('total').innerHTML;
		total = Math.round(total.substring(1)*100)/100;
		var taxSchedule = document.getElementById('taxSchedule').value;
		

		//$price = floatval( $price );
		var returnPrice = 0;
		if( subtotal < 15 ){
			if(type == 'GROUND'){
				returnPrice = 6.95;
			} else if(type == '2NDDAYAIR') {
				returnPrice = 11.00;
			} else if(type == 'NEXTDAY') {
				returnPrice = 21.75;
			}
		} else if( subtotal < 39.00 ){
			if( type == 'GROUND' ){
				returnPrice = 7.95;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 13.60;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 27.00;
			}
		} else if( subtotal < 63.00 ){
			if( type == 'GROUND' ){
				returnPrice = 9.95;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 19.00;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 30.00;
			}
		} else if( subtotal < 95 ){
			if( type == 'GROUND' ){
				returnPrice = 12.70;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 26.00;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 42.75;
			}
		} else if( subtotal < 159.00 ){
			if( type == 'GROUND' ){
				returnPrice = 18.90;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 41.25;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 54.25;
			}
		} else if( subtotal < 255.00 ){
			if( type == 'GROUND' ){
				returnPrice = 29.70;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 62.00;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 74.00;
			}
		} else if( subtotal < 359.00 ){
			if( type == 'GROUND' ){
				returnPrice = 35.00;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 79.95;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 102.45;
			}
		} else if( subtotal < 479.00 ){
			if( type == 'GROUND' ){
				returnPrice = 49.95;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 86.80;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 137.75;
			}
		} else if( subtotal < 599.00 ){
			if( type == 'GROUND' ){
				returnPrice = 57.75;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 109.35;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 165.25;
			}
		} else if( subtotal < 800.00 ){
			if( type == 'GROUND' ){
				returnPrice = 78.30;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 137.50;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 211.25;
			}
		} else if( subtotal < 1500.00 ){
			if( type == 'GROUND' ){
				returnPrice = 106.90;
			} else if( type == '2NDDAYAIR' ) {
				returnPrice = 266.10;
			} else if( type == 'NEXTDAY' ) {
				returnPrice = 447.70;
			}
		}
		//calculate saturday shipping
		var selDate = document.getElementById('OrderShipBy').value;
		shipDate = new Date(selDate);
		if( shipDate.getDay() == '5' && type == 'NEXTDAY' ){
			returnPrice += 13.00;
		}

		
		
		
		//format the shipping so we can see it nice and formated
		returnPrice = format(returnPrice);
		document.getElementById('shipping').innerHTML = "$" + returnPrice.toFixed(2);
		
		//get the numeric representation so we can do our calculations
		returnPrice = Math.round(returnPrice*100)/100;
		
		//calculate tax
		if (taxSchedule == 'NC2PRC'){
			tax = Math.round((((returnPrice+subtotal)*.02)*100))/100;
			document.getElementById('tax').innerHTML = "$" + tax.toFixed(2);
		}else{
			tax = 0;
			document.getElementById('tax').innerHTML = "$" + tax.toFixed(2);
		}
		grandTotal = Math.round((returnPrice + subtotal + tax)*100)/100
		document.getElementById('total').innerHTML = "$" + grandTotal.toFixed(2);
	}
	
	function format(str) {
		try{
			index = str.indexOf('.');
			if (index < 0){
				str = str + '.00';
			}
			else {
				str = str.substring(0, index + 3);
			}
			if (str.length < (index + 3)) {
				str += '0';
			}
		}catch(exception){
			
		}

	return str;
	} 

	function postToTheSession( id )
	{
		var url = '/checkout/post-session-info/'
		$('#'+id).attr( 'action', url );
	}


	function processAddressSelection( obj, id, ret )
	{

		var val = parseInt( obj.value );

		// redirect the user to the add address page
		if( val == -10 ){

			document.location.href = '/account/address/add/?return='+ret;
			return false;

		} else if( val > 0 ) {

			var url = "/account/address/xml/"+val+"/";
		
			/* * /
			$.get(
				url,
				function(xml) {
					var CustomerName = $('CustomerName', xml).text();
					var AddressLine1 = $('AddressLine1', xml).text();
					var AddressLine2 = $('AddressLine2', xml).text();
					var City = $('City', xml).text();
					var State = $('State', xml).text();
					var ZipCode = $('ZipCode', xml).text();
					var TelephoneNo = $('TelephoneNo', xml).text();

					// 
					var addressString = '';
					addressString += '<ul>';
					addressString += '	<li>'+CustomerName+'</li>';
					addressString += '	<li>'+AddressLine1+'</li>';
					addressString += '	<li>'+AddressLine2+'</li>';
					addressString += '	<li>'+City+', '+State+' '+ZipCode+'</li>';
					addressString += '	<li>'+TelephoneNo+'</li>';
					addressString += '</ul>';
					addressString += '';

					// add the address to the correct location
					$('#'+id).html( addressString );
				},
				"xml"
			); //close $.get(
			/* */
			$.get(
				url,
				function(addressString) {
					// add the address to the correct location
					$('#'+id).html( addressString );
				}
			); //close $.get(
	
		}

	}
	
	GLOBAL_SHIPPING_OPTION_SELECTION = 'GROUND';
	
	function processMethodSelection( obj, id )
	{
		var cal = GLOBAL_JQUERY_SELECTCALENDAR[id];
		if( typeof cal == 'object' ){
			GLOBAL_SHIPPING_OPTION_SELECTION = obj.value;
			cal.refresh();
		}
		return true;
	}
	
	function cartIsDisabled( date, fullYear, month, day, cal )
	{
	
		var MINUTE = 60 * 1000;
		var HOUR = 60 * MINUTE;
		var DAY = 24 * HOUR;
		var WEEK = 7 * DAY;
		var today = new Date();
		
		var offset = Math.ceil( ( date.getTime() - today.getTime() ) / DAY );
		var dis = false;
		
		// disable anything less than 2 days out...
		if( offset < 2 ){
			dis = true;
		}
		
		var disabledDays = cal.disabledDaysOfWeek.toString();
		
		// ground restrictions..
		if( GLOBAL_JQUERY_SELECTCALENDAR_RESTRICTION == 'food' && GLOBAL_SHIPPING_OPTION_SELECTION == 'GROUND' ){
			disabledDays = '0,4,5,6';
		}
		// 2nd day air restrictions..
		if( GLOBAL_SHIPPING_OPTION_SELECTION == '2NDDAYAIR' ){
			disabledDays = '0,5,6';
		}
		// overnight restrictions..
		if( GLOBAL_SHIPPING_OPTION_SELECTION == 'NEXTDAY' ){
			disabledDays = '0,6';
		}
		
		// disable disabled days of the week
		if( disabledDays.indexOf( date.getDay() ) >= 0 ){
			dis = true;
		}

		return dis;
	}
	
	function toggleGiftMessage( tableID, hiddenID )
	{
		var giftMessageValue = parseInt( $.trim( $( '#'+hiddenID ).attr('value') ) );
		// If currently its displayed...
		if( giftMessageValue == 1 ){
			$( '#'+tableID ).slideUp();
			$( '#'+hiddenID ).attr( 'value', 0 );
		} else {
			$( '#'+tableID ).slideDown();
			$( '#'+hiddenID ).attr( 'value', 1 );
		}
	}