function SameAsAbove(FormName)
{
	eval("document."+FormName+".ShippAddress1.value	=	document."+FormName+".Address1.value");
	eval("document."+FormName+".ShippAddress2.value	=	document."+FormName+".Address2.value");
	eval("document."+FormName+".ShippAddress3.value	=	document."+FormName+".Address3.value");
	eval("document."+FormName+".ShippPostCode.value	=	document."+FormName+".PostCode.value");
	eval("document."+FormName+".ShippCountry.value	=	document."+FormName+".Country.value");
	eval("document."+FormName+".ShipBillState.value	=	document."+FormName+".BillingState.value");
	eval("document."+FormName+".ShippCity.value		=	document."+FormName+".City.value");
}

function OpenBigMap()
{
	var OpenWindow=window.open("big_map.php","logwindow",'left=250,top=100,height=400,width=480,toolbar=0,resizable=1,scrollbars=1,addressbar=0');
	OpenWindow.focus();
	return false;
}

function OpenTermsBusiness()
{
	var OpenWindow=window.open("terms_of_business.php","logwindow",'left=250,top=100,width=500,height=700,toolbar=0,resizable=1,scrollbars=1,addressbar=0');
	OpenWindow.focus();
	return false;
}

function GetPage()
{
	var Path = window.location.pathname;
	var Page = Path.substring(Path.lastIndexOf('/') + 1);
	return Page;
}

function Validation()
{
	var Obj    = document.form1;
	if ( (Obj.FirstName.value.charAt(0) == " ") || (Obj.FirstName.value.charAt(1) == " ") || ((Obj.FirstName.value.charAt(0) == " ") && (Obj.FirstName.value.charAt(1) == " ") && (Obj.FirstName.value.charAt(2) == " ")) || (Obj.FirstName.value == "") || (Obj.FirstName.value.length <= 3) )
	{
		alert("Please insert the First Name correctly.");
		Obj.FirstName.focus();
		return false;
	}
	if ( (Obj.LastName.value.charAt(0) == " ") || (Obj.LastName.value.charAt(1) == " ") || ((Obj.LastName.value.charAt(0) == " ") && (Obj.LastName.value.charAt(1) == " ") && (Obj.LastName.value.charAt(2) == " ")) || (Obj.LastName.value == "") || (Obj.LastName.value.length <= 3) )
	{
		alert("Please insert the Last Name correctly.");
		Obj.LastName.focus();
		return false;
	}
	if ( Obj.Telephone.value == "" )
	{
		alert("Please insert the Telephone.");
		Obj.Telephone.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidationAppForm()
{
	var Obj    = document.form1;
	var Filter =/^.+@.+..{2,3}$/
	if ( (Obj.FullName.value.charAt(0) == " ") || (Obj.FullName.value.charAt(1) == " ") || ((Obj.FullName.value.charAt(0) == " ") && (Obj.FullName.value.charAt(1) == " ") && (Obj.FullName.value.charAt(2) == " ")) || (Obj.FullName.value == "") || (Obj.FullName.value.length <= 3) )
	{
		alert("Please insert the Full Name correctly.");
		Obj.FullName.focus();
		return false;
	}
	if ( Obj.Email.value == "" || !Filter.test(Obj.Email.value) )
	{
		alert("Please insert the Email correctly.");
		Obj.Email.focus();
		return false;
	}
	if ( (Obj.JobsID.value.charAt(0) == " ") || (Obj.JobsID.value.charAt(1) == " ") || ((Obj.JobsID.value.charAt(0) == " ") && (Obj.JobsID.value.charAt(1) == " ") && (Obj.JobsID.value.charAt(2) == " ")) || (Obj.JobsID.value == "") )
	{
		alert("Please insert the Target Job correctly.");
		Obj.JobsID.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function checkUncheckAll(theElement)
{
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
		{
			theForm[z].checked = theElement.checked;
		}
	}
}

function validate_delete()
{
	return confirm("Continue delete!");
}

function validate_qty_form(nform)
{
	if(!nform.qtyname.value)
	{
		alert("Quantity name required");
		nform.qtyname.focus();
		return false;
	}
	return true;
}

function validate_qty_form2(nform)
{
	if(!nform.ProductCategoryID.value)
	{
		alert("Product Category required");
		nform.ProductCategoryID.focus();
		return false;
	}
	if(!nform.qtyname.value)
	{
		alert("Quantity name required");
		nform.qtyname.focus();
		return false;
	}
	return true;
}

function showhide2ids(id1,id2)
{
	var target1 = document.getElementById(id1);
	var target2 = document.getElementById(id2);
	target1.style.display = 'none'; 
	target2.style.display = ''; 
	return false;
}

function validate_register(nform)
{
	if(!nform.IsType.value)
	{
		alert("Type required!");
		nform.IsType.focus();
		return false;
	}
	if(!nform.NameUser.value)
	{
		alert("User Name required!");
		nform.NameUser.focus();
		return false;
	}
	if(!nform.Password1.value)
	{
		alert("Password required!");
		nform.Password1.focus();
		return false;
	}
	if(!nform.Password2.value)
	{
		alert("Confirm password required");
		nform.Password2.focus();
		return false;
	}
	if(nform.Password1.value!=nform.Password2.value)
	{
		alert("Password's confirmation didn't match!");
		nform.Password2.focus();
		return false;
	}
	if(!nform.FirstName.value)
	{
		alert("First name required!");
		nform.FirstName.focus();
		return false;
	}
	if(!nform.LastName.value)
	{
		alert("Last name required!");
		nform.LastName.focus();
		return false;
	}
	if(!IsValidEmail1(nform))
	{
		nform.UserEmail.focus();
		return false;
	}
	/*
	if(!nform.BirthYear.value)
	{
		alert("Birth Year required!");
		nform.BirthYear.focus();
		return false;
	}
	if(!nform.BirthMonth.value)
	{
		alert("Birth Month required!");
		nform.BirthMonth.focus();
		return false;
	}
	if(!nform.BirthDay.value)
	{
		alert("Birth Day required!");
		nform.BirthDay.focus();
		return false;
	}
	*/
	if(!nform.HomePhone.value)
	{
		alert("Phone required!");
		nform.HomePhone.focus();
		return false;
	}
	if(!nform.Address1.value)
	{
		alert("Address required!");
		nform.Address1.focus();
		return false;
	}
	if(!nform.PostCode.value)
	{
		alert("Post Code required!");
		nform.PostCode.focus();
		return false;
	}
	if(!nform.Country.value)
	{
		alert("Country required!");
		nform.Country.focus();
		return false;
	}
	if (nform.Country.value == 234)
	{
		if(!nform.BillingState.value)
		{
			alert("State required!");
			nform.BillingState.focus();
			return false;
		}
	}
	if(!nform.City.value)
	{
		alert("City required!");
		nform.City.focus();
		return false;
	}
	if(!nform.ShippAddress1.value)
	{
		alert("Shipping Address1 required!");
		nform.ShippAddress1.focus();
		return false;
	}
	if(!nform.ShippPostCode.value)
	{
		alert("Shipping Post Code required!");
		nform.ShippPostCode.focus();
		return false;
	}
	if(!nform.ShippCountry.value)
	{
		alert("Shipping Country required!");
		nform.ShippCountry.focus();
		return false;
	}
	if (nform.ShippCountry.value == 234)
	{
		if(!nform.ShipBillState.value)
		{
			alert("Shipping State required!");
			nform.ShipBillState.focus();
			return false;
		}
	}
	if(!nform.ShippCity.value)
	{
		alert("Shipping City required!");
		nform.ShippCity.focus();
		return false;
	}
	return true;
}

function validate_login_form(nform)
{
	if(!nform.NameUser.value)
	{
		alert("User Name required");
		nform.NameUser.focus();
		return false;
	}
	if(!nform.UserPass.value)
	{
		alert("Password required");
		nform.UserPass.focus();
		return false;
	}
	return true;
}

function validate_login_form1(nform)
{
	if(!nform.Type.value)
	{
		alert("Type required");
		nform.Type.focus();
		return false;
	}
	if(!nform.NameUser.value)
	{
		alert("User Name required");
		nform.NameUser.focus();
		return false;
	}
	if(!nform.UserPass.value)
	{
		alert("Password required");
		nform.UserPass.focus();
		return false;
	}
	return true;
}

function handler(e)
{
	var key = (navigator.appName == "Netscape") ? e.which : e.keyCode;
	if (key == 110)
		return false;
	if ((key > 36 && key < 41) || key == 9 || key == 8 || key == 13 || key == 46 || (key > 47 && key < 58) || (key > 95 && key < 106) || (key==109) || (key==189))
		return true; 
	else
		return false;
}

function openforgotpass()
{
	var OpenWindow=window.open("forgotpassword.php","logwindow",'left=350,top=250,height=190,width=450,toolbar=0,resizable=0,addressbar=0');
	return false;
}

function IsValidEmail(NForm)
{
	/*
	NForm.email.focus();
	var str = NForm.email.value; 
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid 
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid 
	if (!reg1.test(str) && reg2.test(str)) // if syntax is valid 
	{
		return true; 
	}
	else
	{ 
		alert("Enter a valid Email Address");
		return false; 
	}
	//*/
	var str = NForm.email.value; 
	var Filter	=	/^.+@.+..{2,3}$/
	if ( str == "" || !Filter.test(str) )
	{
		alert("Enter a valid Email Address");
		NForm.email.focus();
		return false;
	}
	return true;
}

function IsValidEmail1(NForm)
{
	/*
	NForm.UserEmail.focus();
	var str = NForm.UserEmail.value; 
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid 
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid 
	if (!reg1.test(str) && reg2.test(str)) // if syntax is valid 
	{
		return true; 
	}
	else
	{ 
		alert("Enter a valid Email Address");
		return false; 
	}
	//*/
	var str = NForm.UserEmail.value; 
	var Filter	=	/^.+@.+..{2,3}$/
	if ( str == "" || !Filter.test(str) )
	{
		alert("Enter a valid Email Address");
		NForm.UserEmail.focus();
		return false;
	}
	return true;
}

function validate_cartform(nform,MinimumOrder)
{
	if ( (!nform.qty.value) || (nform.qty.value == 0) )
	{
		alert("Please enter the quantity requested!");
		nform.qty.focus();
		return false;
	}	
	if ( eval(nform.qty.value) < MinimumOrder )
	{
		alert("Please enter a higher quantity.\nThe mimimum order quantity for this item is "+MinimumOrder);
		nform.qty.focus();
		return false;
	}	
	return true;
}

function validate_update_user(nform)
{
	if(!nform.IsType.value)
	{
		alert("Type required!");
		nform.IsType.focus();
		return false;
	}
	if(!nform.FirstName.value)
	{
		alert("First name required!");
		nform.FirstName.focus();
		return false;
	}
	if(!nform.LastName.value)
	{
		alert("Last name required!");
		nform.LastName.focus();
		return false;
	}
	if(!IsValidEmail1(nform))
	{
		nform.UserEmail.focus();
		return false;
	}
	/*
	if(!nform.BirthYear.value)
	{
		alert("Birth Year required!");
		nform.BirthYear.focus();
		return false;
	}
	if(!nform.BirthMonth.value)
	{
		alert("Birth Month required!");
		nform.BirthMonth.focus();
		return false;
	}
	if(!nform.BirthDay.value)
	{
		alert("Birth Day required!");
		nform.BirthDay.focus();
		return false;
	}
	*/
	if(!nform.HomePhone.value)
	{
		alert("Phone required!");
		nform.HomePhone.focus();
		return false;
	}
	if(!nform.Address1.value)
	{
		alert("Address required!");
		nform.Address1.focus();
		return false;
	}
	if(!nform.PostCode.value)
	{
		alert("Post Code required!");
		nform.PostCode.focus();
		return false;
	}
	if(!nform.Country.value)
	{
		alert("Country required!");
		nform.Country.focus();
		return false;
	}
	if (nform.Country.value == 234)
	{
		if(!nform.BillingState.value)
		{
			alert("State required!");
			nform.BillingState.focus();
			return false;
		}
	}
	if(!nform.City.value)
	{
		alert("City required!");
		nform.City.focus();
		return false;
	}
	if(!nform.ShippAddress1.value)
	{
		alert("Shipping Address1 required!");
		nform.ShippAddress1.focus();
		return false;
	}
	if(!nform.ShippPostCode.value)
	{
		alert("Shipping Post Code required!");
		nform.ShippPostCode.focus();
		return false;
	}
	if(!nform.ShippCountry.value)
	{
		alert("Shipping Country required!");
		nform.ShippCountry.focus();
		return false;
	}
	if (nform.ShippCountry.value == 234)
	{
		if(!nform.ShipBillState.value)
		{
			alert("Shipping State required!");
			nform.ShipBillState.focus();
			return false;
		}
	}
	if(!nform.ShippCity.value)
	{
		alert("Shipping City required!");
		nform.ShippCity.focus();
		return false;
	}
	return true;
}

function openchangepass()
{
	var OpenWindow=window.open("changepass.php","logwindow",'left=350,top=250,height=190,width=450,toolbar=0,resizable=0,addressbar=0');
	return false;
}

function validatechangepass(nform)
{
	if(!nform.pass.value)
	{
		alert("Old password required!");
		nform.pass.focus();
		return false;
	}
	if(!nform.pass1.value)
	{
		alert("Password required!");
		nform.pass1.focus();
		return false;
	}
	if(!nform.pass2.value)
	{
		alert("Confirm password required1");
		nform.pass2.focus();
		return false;
	}
	if(nform.pass1.value!=nform.pass2.value)
	{
		alert("Password's confirmation didn't match!");
		nform.pass2.focus();
		return false;
	}
	return true;

}

function OpenOrder(OrdersID)
{
	var OpenWindow=window.open("openorders.php?OrdersID="+OrdersID,"logwindow",'left=150,top=100,height=600,width=700,toolbar=0,resizable=0,scrollbars=1,addressbar=0');
	OpenWindow.focus();
	return false;
}

function OpenOrderHome(OrdersID)
{
	var OpenWindow=window.open("openorders.php?OrdersID="+OrdersID,"logwindow",'left=150,top=100,height=600,width=700,toolbar=0,resizable=0,scrollbars=1,scrollbars=1,addressbar=0');
	OpenWindow.focus();
	return false;
}

function Openproductdetails(ProductsID)
{
	var OpenWindow=window.open("productdetails.php?ProductsID="+ProductsID,"logwindow",'left=250,top=100,height=550,width=600,toolbar=0,resizable=1,scrollbars=1,addressbar=0');
	OpenWindow.focus();
	return false;
}

function validatecontct(nform)
{
	if(!nform.fullname.value)
	{
		alert("Full name is a required field!");
		nform.fullname.focus();
		return false;

	}
	if(!IsValidEmail(nform))
	{
		nform.email.focus();
		return false;
	}
	if(!nform.country.value)
	{
		alert("Country is a required field!");
		nform.country.focus();
		return false;
	}
	if(!nform.subject.value)
	{
		alert("Subject is a required field!");
		nform.subject.focus();
		return false;
	}
	if(!nform.message.value)
	{
		alert("Comment is a required field!");
		nform.message.focus();
		return false;
	}
	return true;
}

function validate_newsletterreg(nform)
{
	if(!nform.fullname.value)
	{
		alert("Full Name required!");
		nform.fullname.focus();
		return false;
	}
	if(!IsValidEmail(nform))
	{
		nform.email.focus();
		return false;
	}
	if(!nform.tel.value)
	{
		alert("Telephone required!");
		nform.tel.focus();
		return false;
	}
	return true;
}

function validate_shiipingform(nform)
{
	if(!nform.FirstName.value)
	{
		alert("First name required!");
		nform.FirstName.focus();
		return false;
	}
	if(!nform.LastName.value)
	{
		alert("Last name required!");
		nform.LastName.focus();
		return false;
	}
	if(!nform.ContactPhone.value)
	{
		alert("Contact phone required!");
		nform.ContactPhone.focus();
		return false;
	}
	if(!IsValidEmail1(nform))
	{
		nform.UserEmail.focus();
		return false;
	}
	if(!nform.Address1.value)
	{
		alert("Address required!");
		nform.Address1.focus();
		return false;
	}
	if(!nform.PostCode.value)
	{
		alert("Post Code required!");
		nform.PostCode.focus();
		return false;
	}
	if(!nform.Country.value)
	{
		alert("Country required!");
		nform.Country.focus();
		return false;
	}
	if (nform.Country.value == 234)
	{
		if(!nform.BillingState.value)
		{
			alert("State required!");
			nform.BillingState.focus();
			return false;
		}
	}
	if(!nform.City.value)
	{
		alert("City required!");
		nform.City.focus();
		return false;
	}
	if(!nform.ShippAddress1.value)
	{
		alert("Shipping Address1 required!");
		nform.ShippAddress1.focus();
		return false;
	}
	if(!nform.ShippPostCode.value)
	{
		alert("Shipping Post Code required!");
		nform.ShippPostCode.focus();
		return false;
	}
	if(!nform.ShippCountry.value)
	{
		alert("Shipping Country required!");
		nform.ShippCountry.focus();
		return false;
	}
	if (nform.ShippCountry.value == 234)
	{
		if(!nform.ShipBillState.value)
		{
			alert("Shipping State required!");
			nform.ShipBillState.focus();
			return false;
		}
	}
	if(!nform.ShippCity.value)
	{
		alert("Shipping City required!");
		nform.ShippCity.focus();
		return false;
	}
	return true;
}

function ShowHide(id)
{
	if ( document.getElementById(id).style.display == "" )
		document.getElementById(id).style.display="none";
	else
		document.getElementById(id).style.display="";
}

function checklogin(loged)
{
	if(!loged)
	{
		alert("You must login in order to continue");
	}
}

//document.oncontextmenu=new Function("return false");