// JavaScript Document
<!-- Version 1.0.0.3 -->
document.observe('dom:loaded', function() { initialise_application(); });

function initialise_application() {
	pre_load_images();
}

function initialise_page(page) {
	try {
		eval('initialise_' + page + '_page();');	
	}
	catch(err) {
	//	alert(err);
	}	
	
	try {
		eval('local_initialise_' + page + '_page();');	
	}
	catch(err) {
	//	alert(err);
	}	
}

function initialise_product_page() {
}


function show_item_added_to_basket() {
	if(typeof hightlight_basket == 'function') {
		hightlight_basket();	
	}
}

function pre_load_images() {
	if (pre_load_image_list) {
		var myimages = new Array();
		for(var i=0; i < pre_load_image_list.length; i++ ){
			myimages[i] = new Image();
			myimages[i].scr = pre_load_image_list[i]
		};
	}
}

function trapKeypress(e, theKey) {
 var iKeyCode = 0;
 if (window.event) iKeyCode = window.event.keyCode
 else if (e) iKeyCode = e.which;
 return (iKeyCode != theKey);
}

function clickButton(e, buttonid){ 
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
} 

function openindex(prodRecId) { 
OpenWindow=window.open("imagepopup.aspx?p=" + prodRecId, "newwin", "height=50, width=50,toolbar=No,menubar=no,resizable=yes,status=no");
OpenWindow.focus();
OpenWindow.document.close()
self.name="main" }
	 
function ChangeColor(tableRow, highLight)  
{
      if (highLight)
	        {
			        tableRow.style.backgroundColor = '#EEEEEE';
			}      
	   else
	        {
			        tableRow.style.backgroundColor = 'white';
			}
}

function ChangeRowColor(tableRow, rowColour) {tableRow.style.backgroundColor = rowColour;}	

function checkbillingformforerrors() {
  if (Page_ClientValidate() == true){
	 if ($get('formerrors')) { $get('formerrors').style.display = "none";}
   }
	else {
		if ($get('formerrors')) { $get('formerrors').style.display = "inline";}
	}
}

function HidePasswordBoxes() {
	document.getElementById("password1").style.display = "none";	
	document.getElementById("password2").style.display = "none";
	ValidatorEnable(reqPassword1, false)
	ValidatorEnable(reqPassword2, false)
	ValidatorEnable(cmpPasswords1, false)
	ValidatorEnable(reqRegBillPassword, false)
}

function ShowPasswordBoxes() {
	document.getElementById("password1").style.display = "block";	
	document.getElementById("password2").style.display = "block";
	ValidatorEnable(reqPassword1, true)
	ValidatorEnable(reqPassword2, true)
	ValidatorEnable(cmpPasswords1, true)
	ValidatorEnable(reqRegBillPassword, true)
}

function ShowHideDeliveryAddressFields() {
	var ddlDifAddress = $get("ddlBillDellAddressDifferent")
	
	var delFields = $get("deliveryaddresswrapper");
	
	if (ddlDifAddress.selectedIndex == 1) {
	  delFields.style.display = "block";
	  
	  $get("txtBillDelFirstName").value = $get("txtBillFirstName").value
	  $get("txtBillDelLastName").value = $get("txtBillLastName").value
	  if ($get("txtBillCompanyName")) $get("txtBillDelCompanyName").value = $get("txtBillCompanyName").value
	  
	  ValidatorEnable(reqBillDelAddress1, true)
  	  ValidatorEnable(reqBillDelAddress3, true)
  	  ValidatorEnable(reqBillDelAddress4, true)
	  ValidatorEnable(reqBillDelPostCode, true)
	  ValidatorEnable(reqBillDelFirstName, true)
	  ValidatorEnable(reqBillDelLastName, true)
	  
	  $get("reqBillDelAddress1").style.display = "none";
  	  $get("reqBillDelAddress3").style.display = "none";
  	  $get("reqBillDelAddress4").style.display = "none";
	  $get("reqBillDelPostCode").style.display = "none";
	  $get("reqBillDelFirstName").style.display = "none";
	  $get("reqBillDelLastName").style.display = "none";
  
	} else {
	  delFields.style.display = "none";
  	  ValidatorEnable(reqBillDelAddress1, false)
  	  ValidatorEnable(reqBillDelAddress3, false)
  	  ValidatorEnable(reqBillDelAddress4, false)
	  ValidatorEnable(reqBillDelPostCode, false)
	  ValidatorEnable(reqBillDelFirstName, false)
	  ValidatorEnable(reqBillDelLastName, false)
	}
	
}

function $get(element) {
	if (typeof(element) == 'string') {
		element = document.getElementById(element);
		return element;
	}
	else {
		return element;
	}
}
