var xmlHttp
/*---------------------------------------------*/
function isblank(s)  
	 {
	   var len=s.length;
	   for(var i=0;i<len;i++)
	   {
	     if(s.charAt(i)!=" ")
		 {
		   return false;
		  }
		}
		return true;
	}

function onlyNumbers(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode;
	 if (charCode > 31 && (charCode < 43 || charCode > 57)){
	 alert("Please enter numaric value");
	return false;
	}								
	 return true;
}

function evntonlyNumbers(evt)
{

	var charCode = (evt.which) ? evt.which : event.keyCode;
	 if (charCode > 31 && (charCode < 48 || charCode > 57) ){
	 alert("Please enter numaric value");
	return false;
	}								
	 return true;
}

var remail=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;

/*-------------for check box select------------*/
function check_all(str,elem)
  {
  	//alert('check all...'+str);
  var ml = str;
  var len = ml.elements.length;
  	//alert('total length...'+len);
  for (var i = 0; i < len; i++) {
   var e = ml.elements[i];
   if (ml.elements[i].name == elem)
   e.checked=true;
  }
  return false;
  }
  
 function uncheck_all(str,elem)
  {
  var ml = str;
  var len = ml.elements.length;
  for (var i = 0; i < len; i++) {
   var e = ml.elements[i];
   if (ml.elements[i].name == elem)
   e.checked=false;
  }
  return false;
 }
 
 function is_checked(str,elem)       
    { 
    
   var obj=str.elements;
   var len=str.elements.length;
   var flag=false;
   //for (var i = 0; i < len-1; i++)
   for (var i = 0; i < len; i++)
   {
   
   if (obj[i].name==elem)
      if (obj[i].checked==true)
     {
     flag=true;
     break;
     }   
   }
   return flag;
   }
  

/*-------------------------------online book form validate----------------------------*/
function registersubmit(str){	
	/*if(isblank(str.membercompanyname.value)){
	alert("You forgot to enter - Company Name");
	str.membercompanyname.focus();
	str.membercompanyname.style.borderColor="red";
	return false;
	}*/
	if(is_checked(str,"membersirname")==false){
	alert("Please choose a salutation.");
	str.membersirname[0].focus();
	str.membersirname[0].style.borderColor="red";
	return false;
	}
	if(isblank(str.memberfirstname.value)){
	alert("You forgot to enter - First Name");
	str.memberfirstname.focus();
	str.memberfirstname.style.borderColor="red";
	return false;
	}
	if(isblank(str.memberlastname.value)){
	alert("You forgot to enter - Last Name");
	str.memberlastname.focus();
	str.memberlastname.style.borderColor="red";
	return false;
	}
	if(isblank(str.memberaddress.value)){
	alert("You forgot to enter - Address");
	str.memberaddress.focus();
	str.memberaddress.style.borderColor="red";
	return false;
	}
	if(isblank(str.membercity.value)){
	alert("You forgot to enter - City");
	str.membercity.focus();
	str.membercity.style.borderColor="red";
	return false;
	}
	if(isblank(str.memberstate.value)){
	alert("You forgot to enter - State");
	str.memberstate.focus();
	str.memberstate.style.borderColor="red";
	return false;
	}
	if(str.memberstate.value=="Others"){
		if(isblank(str.othersstate.value)){
		alert("You forgot to enter - State");
		str.othersstate.focus();
		str.othersstate.style.borderColor="red";
		return false;
		}
	}
	if(isblank(str.memberzipcode.value)){
	alert("You forgot to enter - Zipcode");
	str.memberzipcode.focus();
	str.memberzipcode.style.borderColor="red";
	return false;
	}
	if(isblank(str.membercountry.value)){
	alert("You forgot to enter - Country");
	str.membercountry.focus();
	str.membercountry.style.borderColor="red";
	return false;
	}
	
	if(isblank(str.memberphone.value)){
	alert("You forgot to enter - Phone no");
	str.memberphone.focus();
	str.memberphone.style.borderColor="red";
	return false;
	}
	/*if(!isblank(str.membermobile.value)){
	if(str.membermobile.value.length<10){
	alert("You forgot to enter 10 digit Mobile no");
	str.membermobile.focus();
	str.membermobile.style.borderColor="red";
	return false;
	}
	}*/
	if(isblank(str.memberemail.value) || (str.memberemail.value=='Email Id')){
	alert("You forgot to enter - Email Id");
	str.memberemail.focus();
	str.memberemail.style.borderColor="red";
	return false;
	}
	if(!remail.test(str.memberemail.value)){
	alert("You forgot to enter - Correct Email ID");
	str.memberemail.focus();
	str.memberemail.style.borderColor="red";
	return false;	
	}
	if(isblank(str.memberpassword.value)){
	alert("You forgot to enter - Password");
	str.memberpassword.focus();
	str.memberpassword.style.borderColor="red";
	return false;
	}
	if(str.memberpassword.value!=str.memberconfirmpassword.value){
	alert("You forgot to enter - confirm Password");
	str.memberconfirmpassword.focus();
	str.memberconfirmpassword.style.borderColor="red";
	return false;
	}	
	if(isblank(str.securitycode.value)){
	alert("You forgot to enter - Security Code");
	str.securitycode.focus();
	str.securitycode.style.borderColor="red";
	return false;
	}
	if(str.terms.checked==false){
	alert("You forgot to checked - I agree with ...Box.");
	str.terms.focus();
	str.terms.style.borderColor="red";
	return false;
	}
	return true;
}
function othersstatechangg(str,did){  
	if(str=="Others"){
	document.getElementById(did).style.display="block";
	}else{
	 document.getElementById(did).style.display="none";   
	}
}
function loginsubmit(str){
	if(isblank(str.loginusername.value) || (str.loginusername.value=='Username')){
	alert("You forgot to enter - Username");
	str.loginusername.focus();
	return false;
	}
	if(isblank(str.loginpassword.value) || (str.loginpassword.value=='Password')){
	alert("You forgot to enter - Password");
	str.loginpassword.focus();
	return false;
	}
return true;
}

function allajaxreturn(did,requrl)
{	
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 document.getElementById(did).innerHTML='<img src="images/zoomloader.gif" alt="" border="0"  />';
var url=requrl;
if(xmlHttp){
xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(did).innerHTML=xmlHttp.responseText  
 } 
}
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function billingfrmsubmit(str){
	if(isblank(str.billing_name.value)){
	alert("You forgot to enter - Name");
	str.billing_name.focus();
	return false;
	}
	if(isblank(str.billing_address.value)){
	alert("You forgot to enter - Address");
	str.billing_address.focus();
	return false;
	}
	if(isblank(str.billing_phone.value)){
	alert("You forgot to enter - Phone");
	str.billing_phone.focus();
	return false;
	}
	if(isblank(str.billing_country.value)){
	alert("You forgot to enter - Country");
	str.billing_country.focus();
	return false;
	}
	if(isblank(str.billing_state.value)){
	alert("You forgot to enter - State");
	str.billing_state.focus();
	return false;
	}
	if(isblank(str.billing_city.value)){
	alert("You forgot to enter - City");
	str.billing_city.focus();
	return false;
	}
	if(isblank(str.billing_pincode.value)){
	alert("You forgot to enter - Pincode");
	str.billing_pincode.focus();
	return false;
	}
	
	if(isblank(str.shipping_name.value)){
	alert("You forgot to enter - Name");
	str.shipping_name.focus();
	return false;
	}
	if(isblank(str.shipping_address.value)){
	alert("You forgot to enter - Address");
	str.shipping_address.focus();
	return false;
	}
	if(isblank(str.shipping_phone.value)){
	alert("You forgot to enter - Phone");
	str.shipping_phone.focus();
	return false;
	}
	if(isblank(str.shipping_country.value)){
	alert("You forgot to enter - Country");
	str.shipping_country.focus();
	return false;
	}
	if(isblank(str.shipping_state.value)){
	alert("You forgot to enter - State");
	str.shipping_state.focus();
	return false;
	}
	if(isblank(str.shipping_city.value)){
	alert("You forgot to enter - City");
	str.shipping_city.focus();
	return false;
	}
	if(isblank(str.shipping_pincode.value)){
	alert("You forgot to enter - Pincode");
	str.shipping_pincode.focus();
	return false;
	}
	return true;
}

function contactsubmit(str){
	if(isblank(str.contactname.value)){
	alert("You forgot to enter - Name");
	str.contactname.focus();
	return false;
	}
	if(isblank(str.contactaddress.value)){
	alert("You forgot to enter - Address");
	str.contactaddress.focus();
	return false;
	}
	if(isblank(str.contactphno.value)){
	alert("You forgot to enter - Phone No.");
	str.contactphno.focus();
	return false;
	}
	if(isblank(str.contactemailid.value)){
	alert("You forgot to enter - Email Id.");
	str.contactemailid.focus();
	return false;
	}
	if(!remail.test(str.contactemailid.value)){
	alert("You forgot to enter - Correct Email ID");
	str.contactemailid.focus();
	return false;	
	}
	if(isblank(str.contactquery.value)){
	alert("You forgot to enter - Your Query.");
	str.contactquery.focus();
	return false;
	}
	if(isblank(str.contactsecurity.value)){
	alert("You forgot to enter - Security code.");
	str.contactsecurity.focus();
	return false;
	}
	return true;
}
