/*Function below is for category jump menu*/

function popup(url,width,height,left,top,name){
		//var props = "toolbar=no,location=no,modal=yes,status=no,scrollbars=yes,resizable=no,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height,;
		var props = "toolbar=no,modal=yes,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		//w = window.showModalDialog(url, name,props);

		if (w) {
		w.focus();
		}
}
function resize()
{

window.resizeBy( 0,-250);

}

function popup1(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}

function sortOrder(cat,scat,obj) {
	location.href = "category.aspx?cat="+cat+"&scat="+scat+"&sort="+obj.value
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}

function validateEmail()
{
	with(document.frmPassword)
	{
		if(email.value==""){
		alert("Please specify the email");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
	}
return true;
}
function validateBulkSize()
{
	var flag = 0;
	for(var i=0;i<document.frmBulkSize.length;i++) {
		if(document.frmBulkSize.elements[i].type == 'checkbox') {
			if(document.frmBulkSize.elements[i].checked) {
				flag = 1;
				break;
			}
		}
	}
	if(!flag) {
			alert("Please select atleast one product size!");
			return false;
	}
	return true;
}

function ValidateAlphaNumeric(myfield,e)
{
    //alert("ssssssssssss");
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<58) ) || ((keycode>=64) && (keycode<=90) ) || (keycode==8) || (keycode==95) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}


function ValidateNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateFullDecimal(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (((keycode>=46) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateFullNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (((keycode>46) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateAlpha(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<48)) || ((keycode>=65) && (keycode<=90) )  || (keycode==8) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}

function validateLoginForm(obj)
{
	with(document.loginFrm)
	{
		if(UserName.value==""){
		alert("Please specify the email address/username.");
		UserName.focus();
		return false;
		}
		if(!echeck(UserName.value))
		{
			UserName.focus();
			return false;
		}
		if(UserPassword.value == "" )
		{
			alert("Please enter the password!");
			UserPassword.focus();
			return false;
		}
	}
	return true;
}

function validateForgotPassword(obj)
{
	with(document.forgotPassword)
	{
		if(email.value==""){
		alert("Please specify the email address/username.");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
		/*if(Birthdate.value=="")
		{
		alert("Please specify the birthdate");
		Birthdate.focus();
		return false;
		}*/
	}
	return true;
}

function validateCustomerForm(obj)
{
	with(document.addCustomer)
	{
		if(email.value==""){
		alert("Please specify the email address");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
		if(password.value == "" )
		{
			alert("Please enter the password!");
			password.focus();
			return false;
		}
		if(password.value.length < 6 )
		{
			alert("Password should be of minimum 6 characters!");
			password.value= "";
			password.focus();
			return false;
		}
		if(confirmPassword.value == "" )
		{
			alert("Please confirm your password!");
			confirmPassword.focus();
			return false;
		}
		if(confirmPassword.value != password.value )
		{
			alert("Confirm password does not match your password!");
			confirmPassword.value = "";
			confirmPassword.focus();
			return false;
		}
		if(FName.value==""){
		alert("Please specify the first name");
		FName.focus();
		return false;
		}
		if(LName.value==""){
		alert("Please specify the last name");
		LName.focus();
		return false;
		}
		if(HouseNo.value==""){
		alert("Please specify the house no");
		HouseNo.focus();
		return false;
		}
		if(Street_1.value==""){
		alert("Please specify the street 1");
		Street_1.focus();
		return false;
		}
		if(City.value==""){
		alert("Please specify the city");
		City.focus();
		return false;
		}
		if(Postcode.value==""){
		alert("Please specify the Postcode");
		Postcode.focus();
		return false;
		}
		if(Postcode.value.length < 5){
		alert("Postcode length should be more than 5 digits");
		Postcode.focus();
		return false;
		}
		if(isNaN(Postcode.value)){
		alert("Postcode should be numeric.");
		Postcode.value = "";
		Postcode.focus();
		return false;
		}
		if(TelNo.value==""){
		alert("Please specify the telephone");
		TelNo.focus();
		return false;
		}
		if(isNaN(TelNo.value)){
		alert("Telephone should be numeric.");
		TelNo.value = "";
		TelNo.focus();
		return false;
		}
		if(Terms.checked==false){
		alert("Please accept the terms and conditions");
		Terms.focus();
		return false;
		}
	}
	return true;
}


//Added by  Mahi
//This function is used to submit the form when user hits enter key. This function
// should be called on the keydown event of textbox.
function KeyDownHandler(btnName)
{
var objectBtn;
objectBtn=document.getElementById(btnName); 
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
objectBtn.click();
}
} 



function checkSubmission(obj)
{
//
if (submitcount<=1)
{
	//alert("check");
	if (validateCustChkoutEditForm(obj))
		return true;
	else
		{
			submitcount=0;
			return false;
		}
	
}
else
return false;
}



