////////////////////////////////sIGN uP ////////////////////////////////////



function validateLogin(frmLogin)
{
  
//  alert("validateLogin");
  var Email = frmLogin.txtEmail.value;
  var Password = frmLogin.txtPassword.value;
 if(Email=="Ewebb09" || Email=="")
   {
	  		inlineMsg('txtEmail','<strong>You must enter User Name.</strong>',2);
			return false;
   }
 else if(Password=="Password" || Password=="")
   {
	   	    inlineMsg('txtPassword','<strong>You must enter password.</strong>',2);
			return false;
   }
   
   return true ;
}


function ValidateAdmin(AdminLoginform)
{
	
 var AdminName=AdminLoginform.txtUserName.value;
 var AdminPass=AdminLoginform.txtPassword.value;
 
 if(AdminName=="")
   {
	  		inlineMsg('txtUserName','<strong>Please enter your name.</strong>',2);
			return false;
   }
 else if(AdminPass=="")
   {
	   	    inlineMsg('txtPassword','<strong>Please enter your passworde.</strong>',2);
			return false;
   }
   return true ;
 
 
}


function validateDoDirect(DoDirectPaymentForm)
{
  
// alert("validateLogin");
 var firstName = DoDirectPaymentForm.firstName.value;
 var lastName = DoDirectPaymentForm.lastName.value;
 var creditCardType = DoDirectPaymentForm.creditCardType.value;
 var creditCardNumber = DoDirectPaymentForm.creditCardNumber.value;
 var cvv2Number = DoDirectPaymentForm.cvv2Number.value;
 var address1 = DoDirectPaymentForm.address1.value;
 var city = DoDirectPaymentForm.city.value;
 var state = DoDirectPaymentForm.state.value;
 var zip = DoDirectPaymentForm.zip.value;
 var country = DoDirectPaymentForm.country.value;
 var amount = DoDirectPaymentForm.amount.value;
 
 var cvv2NumberRegex = /^\d\d\d\d$/;

  
   if(firstName=="")
   {
	  		inlineMsg('firstName','<strong>You must enter First Name.</strong>',2);
			return false;
   }
  else if(lastName=="")
   {
	  		inlineMsg('lastName','<strong>You must enter Last Name.</strong>',2);
			return false;
   }
   else if(creditCardType=="")
   {
	  		inlineMsg('creditCardType','<strong>You must enter Credit Card Type.</strong>',2);
			return false;
   }
 
 else if(creditCardNumber=="")
   {
	  		inlineMsg('creditCardNumber','<strong>You must enter Credit Card number.</strong>',2);
			return false;
   }
 else if(cvv2Number=="")
   {
	   	    inlineMsg('cvv2Number','<strong>You must enter card verification number.</strong>',2);
			return false;
   }
   


   
    else if(address1=="")
   {
	   	    inlineMsg('address1','<strong>You must enter Address1.</strong>',2);
			return false;
   }
   
    else if(city=="")
   {
	   	    inlineMsg('city','<strong>You must enter City.</strong>',2);
			return false;
   }
    else if(state=="")
   {
	   	    inlineMsg('state','<strong>You must enter State.</strong>',2);
			return false;
   }
   
       else if(zip=="")
   {
	   	    inlineMsg('zip','<strong>You must enter Zip.</strong>',2);
			return false;
   }
   
       else if(country=="")
   {
	   	    inlineMsg('country','<strong>You must enter Country.</strong>',2);
			return false;
   }
         else if(amount=="")
   {
	   	    inlineMsg('amount','<strong>You must enter Amount.</strong>',2);
			return false;
   } 
   return true ;
}





function createRequestObject()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
	return xmlHttp;
	
  }
  var http = createRequestObject(); 
  
  
function ChkUser(user)
  {
  url="process_check_user.php?user="+user ;
  http.open('get', url);
  http.onreadystatechange = change_user_check; 
  http.send(null);
  return false;
}
function change_user_check()
{
//alert(http.responseText);
	if (http.readyState == 4)
		{
			document.getElementById('chkUser').innerHTML=http.responseText;
			
			if(http.responseText!="")
			{
				//alert(http.responseText);
				document.frmRegister.txtEmail.value="";
				document.frmRegister.txtEmail.focus();
			}
		} 
	
}



function Ischar(sText)
{
	var Validchars="aAbBcCdDeEfFgGhHiIJjKkLlMmNnoPpQqRrSsTtuUvVwWxXyYzZ";
	var Ischar=true;
	var char;
		for(i=0;i<sText.length && Ischar==true;i++)
		{
			char=sText.charAt(i);
			if(Validchars.indexOf(char)==-1)
			{
				Ischar=false;	
			}	
		}
		return Ischar;
}

 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)
		{
			 inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
			 return false ;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
		   return false ;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		   inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
			return false ;
	   	}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		   inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
			return false  ;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
	   	 inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
		  return false ;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    inlineMsg('txtEmail','<strong>You must enter Email .</strong>',2);
			return false ;
		 }
		
	/*	 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    inlineMsg('_txtEmail','<strong>You must enter Email .</strong>',2);
			return false ;
		 }
*/
 		 return true	;				
	}
			







function validate(frmRegister)
{

  var Email = frmRegister.txtEmail1.value;
  var SEmail = frmRegister.txtConEmail.value;
  var Password = frmRegister.txtPassword.value;
  var ConPassword = frmRegister.txtConPassword.value;
  var Fname = frmRegister.txtFName.value;
  var Lname = frmRegister.txtLName.value;
  var Address = frmRegister.txtAddress.value;
  var City = frmRegister.txtCity.value;
  var State = frmRegister.txtState.value;
  var ZIP = frmRegister.txtZip.value;
  var Country = frmRegister.selCountry.value;
  var Officename = frmRegister.txtOfficename.value;
  var Officeno = frmRegister.txtOfficeno.value;
  var Membership = frmRegister.rdoMembership.value;
 if(Email=="")
   {
	  inlineMsg('txtEmail1','<strong>You must enter Email .</strong>',2);
			return false;
   }
else if(!echeck(Email))
   {
	   	  inlineMsg('txtEmail1','<strong>You must enter Valid Email .</strong>',2);
			return false;
   }
 else if(SEmail=="")
   {
	  inlineMsg('txtConEmail','<strong>You must enter Confirm Email .</strong>',2);
	return false;
   }  
 else if(!echeck(SEmail))
   {
	       inlineMsg('txtConEmail','<strong>You must enter Valid Confirm Email .</strong>',2);
			return false;
   }  
   else if(Email1!=SEmail)
   {
	 	 inlineMsg('txtConEmail','<strong>Email and Confirm Email is not same </strong>',2);
			return false;
   } 
   else if(Password=="")
   {
	  inlineMsg('txtPassword','<strong>You must enter Password .</strong>',2);
			return false;
   }  
    else if(ConPassword=="")
   {
	  inlineMsg('txtConPassword','<strong>You must enter Confirm Password .</strong>',2);
			return false;
   }  
   else if(Password!=ConPassword)
   {
	  inlineMsg('txtConPassword','<strong>Your Password and Confirm Password are not same</strong>',2);
			return false;
   }  
    else if(Fname=="")
   {
	  inlineMsg('txtFName','<strong>Please Enter First Name</strong>',2);
			return false;
   }  
    else if(Lname=="")
   {
	  inlineMsg('txtLName','<strong>Please Enter Last Name</strong>',2);
			return false;
   }  
   else if(Address=="")
   {
	  inlineMsg('txtAddress','<strong>Please Enter Address</strong>',2);
			return false;
   }  
   else if(City=="")
   {
	  inlineMsg('txtCity','<strong>Please Enter the City</strong>',2);
			return false;
   }  
   else if(State=="")
   {
	  inlineMsg('txtState','<strong>Please Enter the State </strong>',2);
			return false;
   }  
  
   else if(Ischar(ZIP))
   {
	  inlineMsg('txtZip','<strong>Please enter the zip</strong>',2);
			return false;
   }  
   
   else if(Country=="")
   {
	  inlineMsg('selCountry','<strong>Please enter the country</strong>',2);
			return false;
   }  
     else if(Officename=="")
   {
	  inlineMsg('txtOfficename','<strong>Please enter the office name</strong>',2);
			return false;
   }  
      else if(Officeno=="")
   {
	  inlineMsg('txtOfficeno','<strong>Please enter the office no.</strong>',2);
			return false;
   }  
      else if(Membership=="")
   {
	  inlineMsg('rdoMembership','<strong>Please select membership</strong>',2);
			return false;
   }  

    return true;

}





function validate4(signupform)
{
	
	
	var Email = signupform.txtEmail.value; 
	
		var at="@" ;
		var dot="." ;
		var lat=Email.indexOf(at) ;
	    var lstr=Email.length ;
	    var ldot=Email.indexOf(dot) ;
	
	    
	 
	 if(Email=="")
{
 			inlineMsg('txtEmail','<strong>You must enter Email Id.</strong>',2);
			return false;
}


	else if (Email.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
		inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);  
		  return false ;
		}
     else if (Email.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
		   return false ;
		}
	else if (Email.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
			return false ;
	   }

		else if (Email.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
			return false ;
		 }

		else if (Email.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    //alert("Invalid E-mail ID")
		  inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
		  return false ;
		 }

		else if (Email.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
			return false ;
		 } 
		
		else if (Email.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    inlineMsg('txtEmail','<strong>Invalid E-mail ID.</strong>',2);
			return false ;
		 }

 		 return true ;
}
		 







var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 600));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "../images/msg_arrow.gif"; 
}

