//JavaScript Document

<!--- shopping cart administration functions --->
	//general administration variable declarations
	var loaded = false;
	//function obtains HTML to show the contents of the current shopping cart
	function displayCart(urlVars) {
		if(arguments.length==0){
			urlVars = '';
		}
		/*tempWin = window.open(jsRootPath+"e-Store/Cart/cartAdmin.cfm"+urlVars,"tempWindow","width=10,height=10");
		tempWin.blur();*/
		loaded = false;
		obj = window.frames["adminBox"].window
		if(typeof(obj.displayContent)!='undefined') {
			window.status = "undefined";
			obj.displayContent = "";
		} else {
			window.status = jsRootPath;
		}
		obj.location.href = jsRootPath+"e-Store/Cart/cartAdmin.cfm"+urlVars;
		//
		getCartContents(obj);
	}
	
	//function to delay and check each second whether the display content has loaded
	function getCartContents(newWindow) {
		if(typeof(newWindow.displayContent)=='undefined') {
			t = setTimeout(function getTheContents() {getCartContents(newWindow)},1000);
		} else if(newWindow.displayContent=="") {
			t = setTimeout(function getTheContents2() {getCartContents(newWindow)},1000);
		} else {
			clearTimeout(t);
			if(!loaded) {
				document.getElementById("cartDisplay").innerHTML = newWindow.displayContent;
				controlToolbarDetails('cart');
				loaded = true;
				//newWindow.close();
				//if(getBrowserType()=="IE"){
				if(getBrowserType()!="IE"){
					controlToolbarDetails('cart');
				}
				if(newWindow.location.search.indexOf('CartAction=add')!=-1) {
					confirmItemInCart('show');
				}
				//alert('done');
			}
			//}
			return;
		}						
	}
	
	//function to initiate update of quantity of an item in cart
	function updateCart(formField) {
		itemID = formField.name.replace('Quantity','');
		quantity = formField.value;
		displayCart('?CartAction=Update&ItemIDs='+itemID+'&Quantity='+quantity);
	}
	
	//function to control the display of a confirmation "tooltip" when an item is added to cart
	function confirmItemInCart(action) {
		theBox = window.frames['resultsFrame'].document.getElementById('cartAdditionConfirm');
		theWin = window.frames['resultsFrame'].window;
		switch(action) {
			case "show":
				theBox.style.left = theWin.mouseH + 20;
				theBox.style.top = theWin.mouseV + 20;
				theBox.style.visibility = 'visible';
				boxTO = setTimeout("confirmItemInCart('move')",20);
				boxCL = setTimeout("confirmItemInCart('hide')",5000);
			break;
			case "move":
				clearTimeout(boxTO);
				theBox.style.left = theWin.mouseH + 20;
				theBox.style.top = theWin.mouseV + 20;
				boxTO = setTimeout("confirmItemInCart('move')",20);
			break;
			case "hide":
				clearTimeout(boxCL);
				clearTimeout(boxTO);
				theBox.style.visibility = 'hidden';
			break;
		}
	}