// ----------------------------------------------------------------------
// LOCATION CONTROL VARIABLES
// ----------------------------------------------------------------------
LOCATION_NAME = 0;
LOCATION_LISTNUMBER = 1;
LOCATION_HASTIPS = 2;
LOCATION_HASRECIPES = 3;
LOCATION_HASNEWS = 4;

gnLocMax = 0;
var gsLocMatrix = new Array(100);
//                              have their own:        tip? recipes? news?
gsLocMatrix[gnLocMax++] = new Array("middletown", "2", true, true, true);


// ----------------------------------------------------------------------
// NAVIGATION CONTROL VARIABLES
// ----------------------------------------------------------------------
gstTarget = "";
NAV_CATEGORY = 0;
NAV_PAGEHEAD = 1;
NAV_ALIAS = 2;
NAV_URL = 3;
NAV_WIDTH = 4;
NAV_IMGWIDTH = 5;
gnNavMax=0;
var gstNavMatrix = new Array(100);

gstNavMatrix[gnNavMax++] = new Array("Equestrian - Equestrian Camp", "Equestrian", "equestrian", "../publish/equestrian.shtml", "49%", "170");
gstNavMatrix[gnNavMax++] = new Array("Equestrian - Riding Lessons", "Equestrian", "riding", "../publish/riding.shtml", "49%", "170");

gstNavMatrix[gnNavMax++] = new Array("Overnight Camp - The Mohawk Spirit", "Overnight Camp For Girls", "spirit", "../publish/spirit.shtml", "24%", "122");
gstNavMatrix[gnNavMax++] = new Array("Overnight Camp - Camp Information", "Overnight Camp For Girls", "campinfo", "../publish/campinfo.shtml", "24%", "122");
gstNavMatrix[gnNavMax++] = new Array("Overnight Camp - Seniors", "Overnight Camp For Girls", "seniors", "../publish/seniors.shtml", "24%", "122");
gstNavMatrix[gnNavMax++] = new Array("Overnight Camp - Counselor in Training", "Overnight Camp For Girls", "cit", "../publish/cit.shtml", "28%", "124");

gstNavMatrix[gnNavMax++] = new Array("Day Camp - Day Camp", "Day Camp Mohawk For Girls", "daycamp", "../publish/daycamp.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Day Camp - Transportation", "Day Camp For Girls", "transportation", "../publish/transportation.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Day Camp - Dates and Fees", "Day Camp For Girls", "datesfees", "../publish/datesfees.shtml", "33%", "122");

gstNavMatrix[gnNavMax++] = new Array("Employment - General Information", "Employment Opportunities", "employment", "../publish/employment.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Employment - Job Descriptions", "Employment Opportunities", "jobs", "../publish/jobs.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Employment - Application", "Employment Opportunities", "jobapp", "../publish/jobapp.shtml", "33%", "122");

//gstNavMatrix[gnNavMax++] = new Array("Camp Facilities - Camp Facilities", "Discover Camp Mohawk", "facilities", "../publish/facilities.shtml", "25%", "120");
gstNavMatrix[gnNavMax++] = new Array("Directions - Directions", "Discover Camp Mohawk", "directions", "../publish/directions.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Directions - Map (Wide Angle)", "Discover Camp Mohawk", "mapwide", "../publish/mapwide.shtml", "33%", "122");
gstNavMatrix[gnNavMax++] = new Array("Directions - Map (Zoom)", "Discover Camp Mohawk", "mapzoom", "../publish/mapzoom.shtml", "33%", "122");



//gstNavMatrix[gnNavMax++] = new Array("Online Store - Departments", "Online Store", "order_departments", "../publish/order_departments.shtml", "33%", "170");
//gstNavMatrix[gnNavMax++] = new Array("Online Store - ORDER ITEMS", "Online Store", "order_items", "javascript:GetItemPage('../publish/order_botsjewel.shtml')", "33%", "170");
//gstNavMatrix[gnNavMax++] = new Array("Online Store - Checkout", "Online Store", "order_checkout", "../publish/order_checkout.shtml", "33%", "170");

gstNavMatrix[gnNavMax++] = new Array("Daily Update - Session 1", "Daily Update", "session1", "../publish/session1.shtml", "20%", "90");
gstNavMatrix[gnNavMax++] = new Array("Daily Update - Session 2", "Daily Update", "session2", "../publish/session2.shtml", "20%", "90");
gstNavMatrix[gnNavMax++] = new Array("Daily Update - Session 3", "Daily Update", "session3", "../publish/session3.shtml", "20%", "90");
gstNavMatrix[gnNavMax++] = new Array("Daily Update - Session 4", "Daily Update", "session4", "../publish/session4.shtml", "20%", "90");
gstNavMatrix[gnNavMax++] = new Array("Daily Update - Special Events", "Daily Update", "special", "../publish/special.shtml", "20%", "90");



// ----------------------------------------------------------------------
// LOCATION CONTROL VARIABLES
// ----------------------------------------------------------------------
SHIPPING_NAME = 0;
SHIPPING_FEE = 1;

gnShipMax = 0;
var gstShipMatrix = new Array(10);
//                              
gstShipMatrix[gnShipMax++] = new Array("Standard Ground", "7.00");
gstShipMatrix[gnShipMax++] = new Array("Two Day Express", "12.00");
gstShipMatrix[gnShipMax++] = new Array("Overnight", "24.00");
gstShopCat="Online Store - ORDER ITEMS";
gstOrderForm="https://www42.fatcow.com/boitum/content/publish/order_checkout.shtml";


gstCheckoutRecipient = "orders@boitumelo.com";
gstCheckoutEmailCopies = "";
gstCheckoutSubject = "Boitumelo Online Order";
gstCheckoutConfirmScript ="https://www42.fatcow.com/boitum/ordersys/order_confirm.php";


// DO NOT AUTO-AUTHORIZE YET
gbAllowShipAddress = true;
gbAllowDiscount = true;
gbCalcShip = true;
gstAuthNet = "FALSE"


// ----------------------------------------------------------------------
// Recalc
// ----------------------------------------------------------------------
function Recalc(myFormCtrl) {
	stQty = new String();
	stTot = new String();
	stShip = new String();
	stSalesTax = new String();
	
	nQty = new Number();
	nTot = new Number();

	gQty = new Number();
	nShip = new Number();	
	gTot = new Number();
	nSalesTax = new Number();	
	nTemp = new Number();	
	
	
	jewerlyTot = new Number();	
	otherTot = new Number();	
	jewerlyTot = 0;	
	otherTot = 0;	

	nDiscount = new Number();	
	nDiscount = 0;	

	/* m_discount_code
	   m_discount_amount */
	nDiscMult = 1;
	if (gbAllowDiscount) {
		stDiscountCode = myFormCtrl.document.getElementById("m_discount_code").value;
		if (stDiscountCode=="DISC1204"){
			nDiscMult = .9;
		}
		else {
			if (stDiscountCode!="") { 
				myFormCtrl.document.getElementById("m_discount_code").value = "";
				alert('Sorry, Invalid Discount Code');
			}
		}
	}
	
	gQty=0;
	gTot=0;
	stShip = "0.00";
	stSalesTax = "0.00"; 
	for (n = 0; n<nCnt; n++) {
		nQty = 1 * myFormCtrl.document.getElementById("item_quantity_"+n).value;
		stItemName = myFormCtrl.document.getElementById("item_name_"+n).value;
		
		if (nQty.toString()=="NaN"){ 
			nQty=0; 
		}
		stQty = nQty.toFixed(0);

		nQty = 1 * stQty;
		nTot = nQty * myFormCtrl.document.getElementById("item_price_"+n).value * nDiscMult;
		stTot = nTot.toFixed(2);

		myFormCtrl.document.getElementById("item_quantity_"+n).value = stQty;
		myFormCtrl.document.getElementById("item_total_"+n).value = stTot;
		gQty=gQty+nQty;
		gTot=gTot+nTot;
		
		// test if this item is Jewelery
		if (stItemName.indexOf("(JY")>=0) {
			jewerlyTot = jewerlyTot + nTot;
		}
		else {
			otherTot = otherTot + nTot;		
		}
	}	

	//Calc SALES based on STATE
	var list = myFormCtrl.document.getElementById("x_ship_to_state")
	stState = list.options[list.selectedIndex].value;
	//alert("["+stState+"]");
	if (stState=="CT"){
		nSalesTax = gTot*.06;
	}	
	stSalesTax = nSalesTax.toFixed(2);
	myFormCtrl.document.getElementById("salestax").value = stSalesTax;
	nTot = gTot + nSalesTax;
	gTot = nTot;

	//Calc Shipping based on dropdown
	nMethod = myFormCtrl.document.getElementById("m_ship_method").selectedIndex;
	// nShip  = parseFloat(gstShipMatrix[nMethod][SHIPPING_FEE]);
	
	if (gTot<=0){
		nShip = 0;
	}
	else {
		if (otherTot==0){
			nShip = 6;
		}
		else {
			if (otherTot<=30){
				nShip = 8;
			}
			else {
				if (otherTot<=50){
					nShip = 11;
				}
				else {
					if (otherTot<=90){
						nShip = 15;
					}
					else {
						if (otherTot<=125){
							nShip = 18;
						}
						else {
							if (otherTot<=200){
								nShip = 21;
							}
							else {
								if (otherTot<=300){
									nShip = 32;
								}
								else {
									nShip = 45;
								}	
							}	
						}	
					}	
				}	
			}			
		}	
	}
	
	if (gTot>0 && nMethod==1) {
		// express
		nShip = nShip + 15;
	}
	if (gTot>0 && nMethod==2) {
		// overnight
		nShip = nShip + 20;
	}	
	
	
	stShip = nShip.toFixed(2);
	myFormCtrl.document.getElementById("shipping").value= stShip;
	
	nTot = gTot + parseFloat(myFormCtrl.document.getElementById("shipping").value);
	stTot = nTot.toFixed(2);

	myFormCtrl.document.getElementById("x_amount").value = stTot;
	myFormCtrl.document.getElementById("total_amount").value = stTot;
}