function disp_div(opendiv,closediv)

{
	if(closediv=='')
	{
			
			document.getElementById(opendiv).style.display='block';
	}
	else if(opendiv=='')
	{
		document.getElementById(closediv).style.display='none';	
	}
	else
	{
		
		document.getElementById(opendiv).style.display='block';
		document.getElementById(closediv).style.display='none';
	}

}

function modifypassword()
{
var form = document.frm_userdata;

	if(form.currentpwd.value =='')
		{
			alert("Please give your current password!");
			form.currentpwd.focus();
			return false;
		}
		if(form.newpwd.value =='')
		{
			alert("Please give your new password!");
			form.newpwd.focus();
			return false;
		}
	if(form.newpwd.value !=form.verifypwd.value)
		{
			alert("Your password and retype password should be same!");
			form.verifypwd.focus();
			return false;
		}
	
}



function shippingvalidate()
{
var form = document.addshipping;

	if(form.name.value =='')
		{
			alert("Please Enter your name!");
			form.name.focus();
			return false;
		}
		
	
	if(form.email.value =='')
		{
			alert("Please Give your E-mail!");
			form.email.focus();
			return false;
		}
		
		
		if(!form.email.value =='' && !eMailCheck(form.email.value))
		{
			alert("Please give a valid E-Mail id.");
			form.email.focus();
			return false;
		}
if(form.address1.value =='')
		{
			alert("Please give your Address!");
			form.address1.focus();
			return false;
		}
if(form.city.value =='')
		{
			alert("Please give your city!");
			form.city.focus();
			return false;
		}
if(form.zip.value =='')
		{
			alert("Please give your Zip!");
			form.zip.focus();
			return false;
		}
if(form.state.value =='')
		{
			alert("Please give your state!");
			form.state.focus();
			return false;
		}

/*	if(form.email.value =='')
		{
			alert("Please give your E-Mail id!");
			form.email.focus();
			return false;
		}*/
		/*else 
		{
			form.submit();
			return true;
		}
		*/
	
}


function edituser()
{
var form = document.frm_userdata;

	if(form.name.value =='')
		{
			alert("Please Enter your name!");
			form.name.focus();
			return false;
		}
		
			
		if(form.address.value =='')
		{
			alert("Please give your Address!");
			form.address.focus();
			return false;
		}
		
		if(form.email.value =='')
		{
			alert("Please Give your E-mail!");
			form.email.focus();
			return false;
		}
		
		if(!form.email.value =='' && !eMailCheck(form.email.value))
		{
			alert("Please give a valid E-Mail id.");
			form.email.focus();
			return false;
		}

if(form.contactno.value =='')
		{
			alert("Please give your contact number!");
			form.contactno.focus();
			return false;
		}



if(!form.contactno.value=='' && !IsNumeric(form.contactno.value))
{
			alert("Contact number should be numeric!");
			form.contactno.focus();
			return false;
}
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }




function eMailCheck(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 email")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid email")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid email")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid email")
		    return false
		 }
 		 return true;
}