// 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"; */

//////////////////////////////////////////////////////////////////////////////////////
// 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;
	}
//////////////////////////////////////////////////////////////////////////////////////
