if (document.images) {
  preload_image_object = new Image();
  // set image url
  image_url = new Array();
  image_url[0] = "App_Themes/Alpha/images/light.png";
  image_url[1] = "App_Themes/Alpha/images/dark.png";

  var i = 0;
  for(i=0; i<=1; i++) 
		preload_image_object.src = image_url[i];
}

startList = function() {
	if (document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					// firefox trims class names so we can't replace on " over"
					var cn = this.className
					if(cn == "over") {
						cn = "";
					}
					else {
						cn = this.className.replace(" over", "");
					}
					this.className = cn;
				}
			}
		}
	}
}
window.onload=startList;

function spawn(url) {
	window.open(url, 'madeleineritchie', 'height=630,width=480,scrollbars=1,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=50,top=50');
}
function AddToBasket (productID, quantity, IsReload){
	// add quantity to the basket icon			
	var totalItems = document.getElementById("totalItems").innerHTML;
	totalItems = parseInt(totalItems);
	totalItems = totalItems+quantity;
	document.getElementById("totalItems").innerHTML = totalItems;

	// update the session
	// this uses request.js
	Http.get({
		url: "update_basket.aspx?task=add&id=" + productID + "&qty=" + quantity + '&rnd=' + Math.random(),
		callback: checkResult
	}, [IsReload]);
}

function DeleteFromBasket (productID, quantity, IsReload){
	// delete quantity to the basket icon			
	var totalItems = document.getElementById("totalItems").innerHTML;
	totalItems = parseInt(totalItems);
	totalItems = totalItems-quantity;
	document.getElementById("totalItems").innerHTML = totalItems;
		
	// update the session
	// this uses request.js
	Http.get({
		url: "update_basket.aspx?task=delete&id=" + productID + "&qty=" + quantity + '&rnd=' + Math.random(),		
		callback: checkResult
	}, [IsReload]);	
	
}

function checkResult(result, IsReload){
	if(result.status==Http.Status.OK ) {
			if(IsReload) { // filter out undefined's from Flash
				location.reload();
			}
	}
	else {
		//alert("ERROR: Could not add item to basket!!");
	}	
}

var startProductID = 0; // this is assigned a value if there is a product to load when we start
// this is called from the Product Detail swf when it finishes loading

function ProductDetailFlashDone() {
	//alert('ProductDetailFlashDone')
	if (startProductID > 0) {	
		 setTimeout('callFlDisplay(' + startProductID + ')', 100)
	}
}

function callFlDisplay(ProductID){
	var flashMovie=getFlashMovieObject("lf_display");
	flashMovie.SetVariable("setProductID", ProductID);	 	 
}
function getFlashMovieObject(movieName){
  if (window.document[movieName]){
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1){
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else{ // if (navigator.appName.indexOf("Microsoft Internet")!=-1)  
    return document.getElementById(movieName);
  }
}

//function billingDelivery(obj)
//{	
//	if(!obj.checked){
//		document.getElementById('tbl_delivery').style.display="none";
//		document.getElementById('txt_billing').innerHTML = "BILLING AND DELIVERY ADDRESS";
//	}
//	else{
//		document.getElementById('tbl_delivery').style.display ="block";
//		document.getElementById('txt_billing').innerHTML = "BILLING ADDRESS";
//	}
//}

