﻿function ValidateEmail(obj)
{
	var emailval=(obj.value);
	var emailat;
	emailat = emailval.indexOf('@');
	emaildot = emailval.indexOf('.');

	if (emailval.length<=0 ) 
	{
		alert("Please enter a valid email Address, for example abc@abc.com");
		return false;
	}
	else if ((emailat == "-1" )||(emaildot == "-1" ))
	{
		alert("The email you entered is not valid. Please reformat your email address to be: abc@abc.com");
		return false;
	}
	else
	{
	document.forms[0].elements["hpost"].value="posted";
	document.forms["add_cart1"].submit();	   
	}
}


function formSubmit()
{
	var emailval=(document.forms["add_cart1"].elements["txtEmail"].value);
	var emailat;
	emailat = emailval.indexOf('@');
	emaildot = emailval.indexOf('.');

	if (emailval.length<=0 ) 
	{
		alert("Please enter a valid email Address, for example abc@abc.com");
		return false;
	}
	else if ((emailat == "-1" )||(emaildot == "-1" ))
	{
		alert("The email you entered is not valid. Please reformat your email address to be: abc@abc.com");
		return false;
	}
	else
	{
	    document.forms[0].elements["hpost"].value="posted";
	    //document.forms["add_cart1"].submit();
	    var hval = document.forms[0].elements["hpost"].value;
	    if (hval != "" && emailval != "Enter email address")
        {        	   		
	        document.forms["add_cart1"].action ='/myaccount/index.asp?email=HomePage&emailval=' + emailval;	         
	    }
	}
}

function Empty()
{
if (document.add_cart1.txtEmail.value.toLowerCase()=='enter email address')
document.add_cart1.txtEmail.value='';
}


function CheckEnter(obj,e) 
	{
	
	var emailval=(obj.value);
	var emailat;
	 var keycode; 
	if (window.event) 
		keycode = window.event.keyCode; 
	else if (e) 
		keycode = e.which; 
	else return true; 
	if (keycode == 13) 
	{ 
	emailat = emailval.indexOf('@');
	emaildot = emailval.indexOf('.');

	if (emailval.length<=0 ) 
	{
		alert("Please enter a valid email Address, for example abc@abc.com");
		return false;
	}
	else if ((emailat == "-1" )||(emaildot == "-1" ))
	{
		alert("The email you entered is not valid. Please reformat your email address to be: abc@abc.com");
		return false;
	}
	else
	{
	document.forms[0].elements["hpost"].value="posted";
	//document.forms["add_cart1"].submit();	
	    var hval = document.forms[0].elements["hpost"].value;	   		
        if (hval != "" &&  emailval != "Enter email address")
        {     
	        window.location.href='/myaccount/index.asp?email=HomePage&emailval=' + emailval;
	    }
	}

	return false; 
	} 
	else 
	return true; 
	}


function submitform(URL,URLtarget,mode)
        {
        document.forms["add_cart1"].action = URL;
        document.forms["add_cart1"].method = "post";
        document.forms["add_cart1"].target = URLtarget;
        //      document.forms["add_cart1"].submit();
        if(mode=='add')
        {
        window.status='Adding to Shopping Cart'
        }
        else
        {
        window.status='Updating Shopping Cart'
        }
        return true;
        }