// General Scripts used on the site
//////////////////////////////////////////////////////////////////////////////////////
//  http://support.microsoft.com/kb/887741  just incase
function submitForm(appAction) {
	submitFormDo(appAction)
}
////////////////////////////////////////////////////////////////////////////////////////////
	// sumbitForm
	function submitFormDo(appAction) {
		
		if (appAction == "Save" || appAction == "Add adddress"){
			window.document.lgoCartForm.action = window.document.lgoCartForm.formLocationUpdate.value;
		}else{
			window.document.lgoCartForm.action = window.document.lgoCartForm.formLocationFinal.value;
		}

		window.document.lgoCartForm.appAction.value = appAction;
		window.document.lgoCartForm.submit();
		
	}
//////////////////////////////////////////////////////////////////////////////////////
// Preload the loader images

/*var checkoutLoaderImage = new Image();
checkoutLoaderImage.src = "images/checkoutLoader.gif";

var longLoaderImage = new Image();
longLoaderImage.src = "images/longLoaderImage.gif";

var loadingImage = new Image();
loadingImage.src = "images/loading.gif"; */

//////////////////////////////////////////////////////////////////////////////////////
	function changeLargeImage(imageID){
					
		var imageFile = 'largeImagelink' + imageID;
		var imageWidth = 'largeImagelink' + imageID + 'width';
		document.getElementById('largeImage').src= window[imageFile];
		document.getElementById('largeImage').style.width = window[imageWidth];
		
	}

//////////////////////////////////////////////////////////////////////////////////////
// Open and Close Navigation menu

	//////////////////////////////////////////////////////////////////////////////////////
	// Create an Object to save open menu
	function recordOpenMenu() {
			this.menuID = 'blankMenuItem';
	}
	
	var savedOpenMenu = new recordOpenMenu();
	
	//////////////////////////////////////////////////////////////////////////////////////
	// The actual menu that opens/closes
	function openMenu(id)
	{
		// Get Open Menu
		var toBeClosed = window.savedOpenMenu.menuID;

		//Close current open menu
		identity = document.getElementById(toBeClosed);
		identity.className='headerClosed';
				
		// Save open Menu
		window.savedOpenMenu.menuID =  id;
		
		// Open the menu
		identity=document.getElementById(id);
		identity.className='headerOpen';
	}
	//////////////////////////////////////////////////////////////////////////////////////
	function validateRegistration() {
		
		// set flag to true as default
		var flag = true
		
		// Reset all old errror
			var element = document.getElementById('firstname');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('lastname');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('email');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('email2');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('password');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('password2');
			element.style.backgroundColor = '#FFFFFF';

			var element = document.getElementById('businessName');
			element.style.backgroundColor = '#FFFFFF';
		
		// Check if feild are filled in
		
		if (!window.document.signUpForm.firstname.value) {
			var element = document.getElementById('firstname');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check Firstname");

		}
		if (!window.document.signUpForm.lastname.value) {
			var element = document.getElementById('lastname');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check LastName");
		}
		if (!window.document.signUpForm.email.value) {
			var element = document.getElementById('email');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check email");

		}
		if (!window.document.signUpForm.email2.value) {
			var element = document.getElementById('email2');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check email2");

		}
		if (!window.document.signUpForm.pword.value) {
			var element = document.getElementById('password');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check pass1");
		}
		if (!window.document.signUpForm.pword2.value) {
			var element = document.getElementById('password2');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check pass2");
		}
		if (!window.document.signUpForm.businessName.value) {
			var element = document.getElementById('businessName');
			element.style.backgroundColor = '#FF3333';
			flag = false;
			//alert("Check biz name");
		}
		
		// Check if email and pass match
		
		if (window.document.signUpForm.email.value != window.document.signUpForm.email2.value) {
			var element = document.getElementById('email');
			element.style.backgroundColor = '#FF3333';
			var element = document.getElementById('email2');
			element.style.backgroundColor = '#FF3333';
			flag = false;
		}
		
		if (window.document.signUpForm.password.value != window.document.signUpForm.password2.value) {
			var element = document.getElementById('password');
			element.style.backgroundColor = '#FF3333';
			var element = document.getElementById('password2');
			element.style.backgroundColor = '#FF3333';
			flag = false;
		}

		if (flag == false) alert("Please check all the feilds");
		
		// return flag
		return flag;
	}
//////////////////////////////////////////////////////////////////////////////////////

window.onload=function(){TJK_keyBoardDropDown();}

// removed the comment around the "return false" statement
// I can't remember why I commented it in the first place :-( 
function swap(){this.className="msieFix";}
function swapBack(){this.className="trigger";}
function toggle(){(this.parentNode.className=="trigger")?this.parentNode.className="msieFix":this.parentNode.className="trigger";return false;}
function reveal(){
this.parentNode.parentNode.parentNode.className="msieFix";
}
function cleanUp(){
	var zA;
	var LI = document.getElementsByTagName("li");
	var zLI= LI.length;
		for(var k=0;k<zLI;k++){
		if(LI[k]!=this.parentNode){
		LI[k].className="trigger";
		}
	}	
}
function TJK_keyBoardDropDown(){// v1.2 Copyright (c) 2006 TJKDesign - Thierry Koblentz
	var LI = document.getElementsByTagName("li");
	var zLI= LI.length;
	if (document.getElementById){	
		for(var k=0;k<zLI;k++){
			if(LI[k].id){
				LI[k].className="trigger";
				//LI[k].firstChild.onclick=toggle;
				//LI[k].firstChild.title="show/hide the sub-menu";				
				LI[k].firstChild.onfocus=cleanUp;
			}
			if(LI[k].className=="trigger"){
				LI[k].onmouseover=swap;
				LI[k].onmouseout=swapBack;
			}
			if(!LI[k].id){
				//LI[k].firstChild.onfocus=reveal;
			}
		}
	}
}