// JavaScript Documen 
function chkvalue(captcha)
{	
	var doc=document.registrationfrm;
    var date=document.registrationfrm.orderdate.value;
 
	/***************************************************************************************************/
	if(doc.usrname.value=="")
	{
		alert("Please enter username.");
		doc.usrname.focus();
		return false;
	}
	

/*if(doc.usrname.value!="")
{
	var str=doc.usrname.value;
if(str.length > 13 )
{
alert("Your username cannot be more than thirteen characters")
doc.usrname.focus()
			  return false;
}*/

	
  
  	if(doc.usrname.value!="")
	{
		if(isfirstspace(doc.usrname.value)==false)
		{
			alert("Please enter usrname correctly.");
			doc.usrname.focus();
			return false;
		}
	}
	/***************************************************************************************************/
	if(doc.pass.value=="")
	{
		alert("Please enter password.");
		doc.pass.focus();
		return false;
	}
	 if(doc.pass.value!="")
	{
		
		var str=doc.pass.value;
		  if(str.length < 5 )
		  {
			  alert("Please enter password greater than  five characters.")
			  doc.pass.focus()
			  return false;
		  }
		  if(isAlphaNumeric(doc.pass.value)==false)
			{
				alert("Please enter password correctly.");
				doc.pass.focus();
				return false;
			}
	}
	/***************************************************************************************************/
	if(doc.confpwd.value=="")
	{
		alert("Please enter confirm password.");
		doc.confpwd.focus();
		return false;
		
	}
	if(doc.confpwd.value!=doc.pass.value)
		{
			alert("Please enter confirm password correctly");
			doc.confpwd.focus();
			return false;
		}
	if(doc.confpwd.value!="")
	{
		
		var str=doc.confpwd.value;
		  if(str.length < 5 )
		  {
			  alert("Please enter confirm password greater than  five characters.")
			  doc.confpwd.focus()
			  return false;
		  }
		  if(isAlphaNumeric(doc.confpwd.value)==false)
			{
				alert("Please enter  confirm password correctly.");
				doc.confpwd.focus();
				return false;
			}
	}
		
	/*****************************************Enter User first Name****************************/
	if(doc.usrfname.value=="")
	{
		alert("Please enter first name.");
		doc.usrfname.focus();
		return false;
	}
	if(isAllCharacters(doc.usrfname.value)==false)
  	{
	  alert("Please enter first name only in characters.")
	 doc.usrfname.focus();
	  return false;
   }
  
   if(doc.usrfname.value!="")
	{
		if(isfirstspace(doc.usrfname.value)==false)
		{//alert("ok");
			alert("Please enter first name correctly.");
			doc.usrfname.focus();
			return false;
		}
	}
	/*****************************************Enter User last Name****************************/
	if(doc.usrlname.value=="")
	{
		alert("Please enter last name.");
		doc.usrlname.focus();
		return false;
	}
	if(isAllCharacters(doc.usrlname.value)==false)
  	{
	  alert("Please enter last name only in characters.")
	 doc.usrlname.focus();
	  return false;
   }
  
   if(doc.usrlname.value!="")
	{
		if(isfirstspace(doc.usrlname.value)==false)
		{
			alert("Please enter last name correctly.");
			doc.usrlname.focus();
			return false;
		}
	}
	/***************************************************************************************************/
	if(doc.emailid.value=="")
 	 {
	   alert("Please enter email ID.")
	   doc.emailid.focus();
	   return false;
  	 }
  	if(!isValidEmail(doc.emailid.value))
 	 {
	  alert("Please enter valid email address.")
	  doc.emailid.focus();
	  return false;
     }
	
	/***************************************************************************************************/
	/*if(doc.career.value=="")
	{
		alert("Please enter career.");
		doc.career.focus();
		return false;
	}
		
	
	if(!isAllCharacters(doc.career.value))
  	{
	  alert("Please enter career only in characters.")
	  doc.career.focus()
	  return false;
  	}
  
  	if(doc.career.value!="")
	{
		if(isfirstspace(doc.career.value)==false)
		{
			alert("Please enter career correctly.");
			doc.career.focus();
			return false;
		}
	}*/
	
	
	/*************************************************************************************************/
	if(doc.country.value=="")
	{
		alert("Please select country.");
		doc.country.focus();
		return false;
	}
	/***************************************************************************************************/
	if(doc.state.value=="")
	{
		alert("Please select state.");
		doc.state.focus();
		return false;
	}
	
	
	/***************************************************************************************************/
	if(doc.city.value=="")
	{
		alert("Please select city.");
		doc.city.focus();
		return false;
	}
     	
	
	
	/**************************************************************************************************/
	/*if(doc.orderdate.value=="")
	{
		alert("Please select the date .");
		doc.orderdate.focus();
		return false;
	}*/
	//alert(date);
	if(date!="")
  	{   	//alert("ok");  
      var d=date.split("-");
	  //alert(date);
	  var dtoday=new Date();
	  var year=dtoday.getFullYear();
	  var mon=dtoday.getMonth();
	  var today=dtoday.getDate();
	  var month=mon+1;

	  var da=year-16;
	 /**************Chk year entered less than or equal to the da******************/
	  //alert(d[0]);alert(da);
	  if(d[0] > da)
	  {//alert("dfd");
		alert("You must be 16 years or older to become a member on FavorAsk.");
		//document.getElementById("date").innerHTML="Please enter age greater than 18 years.";
		//doc.orderdate.focus();
		return false;  
	  }
	  else if(da <= d[0])
	  {  
	  /*********************Year entered is equal to the enteredd year**************************/
		if(da == d[0])
		{
 	 /*********************month entered is equal to or less than the enteredd month**************************/
			if(month <= d[1])
			{
	/*********************today entered is equal to or greater than the enteredd today**************************/
				if(d[2] >= today)
				{
					 alert("You must be 16 years or older to become a member on FavorAsk.");
					 //document.getElementById("date").innerHTML="Please enter age greater than 18 years.";
					 //doc.orderdate.focus();
					 return false;
				}
			}
		}		
	  }	 
  }


	/***************************************************************************************************/
	if(doc.gender.value=="")
	{
		alert("Please enter gender.");
		doc.gender.focus();
		return false;
	}
	//alert(valButton(doc.gender));
	  if(valButton(doc.gender) == null)
	  {   
			alert("Please select gender.");
			//document.sendmsg.sub.focus();
			return false;	
	  }
	/************************************************************************************************/
	/*if(doc.usrphoto.value=="")
	{
		alert("Please select the photo.");
		doc.usrphoto.focus();
		return false;
	}*/
	
	
	if (doc.usrphoto.value != "" )
    {
		 text =  doc.usrphoto.value;		 
		 aPosition = text.lastIndexOf(".")+1;
		 lPosition = text.length;		 
		 exten = text.substr(aPosition,lPosition);
		 switch (exten.toLowerCase())
		 {
			  case "jpg"  :	break;
			  case "jpeg" : break;
			  case "gif"  :	break;
			 // case "GIF"  : break;
			 
			  default :
		   {
			  alert("Input file is not an image."); 
			  doc.usrphoto.focus();
			  return false ;		
		   }
		  																										
		 }
		   
		 //alert(exten); // Will display an alert box with the number 1
	}
	//alert(captcha);
	if(doc.term.checked == false )
	{
		alert("Please accept Terms Of Uses & Privacy policy.");
		doc.term.focus();
		return false;
		}
	
	/***************************************************************************************************/
return true;
}

function isfirstspace(string)
{
    var str=string.split(" ");
	//alert(str[0]);
	if(str[0]== "")
	{
	return false;	
	}
}


function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}



/********************Numbers only********************/

function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode);
	
if (unicode==9 || unicode==13 || unicode==46){return true}
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}


/*******************Characters only*********************/
function charonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode);
if (unicode==9 || unicode==13 || unicode==46){return true}	
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<65||unicode>90 && unicode<97||unicode>122) //if not a number
return false //disable key press
}
}


/*******************Characters & spaces only*********************/
function charnumbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode);
	if (unicode==9 || unicode==13 || unicode==46){return true}
	
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if ((unicode<65||unicode>90 && unicode<97||unicode>122) && (unicode<48||unicode>57)) //if not a number
return false //disable key press
}
}


/*******************Characters + numbers only*********************/
function charonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode);
if (unicode==9 || unicode==13 || unicode==46){return true}	
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<65||unicode>90 && unicode<97||unicode>122) //if not a number
return false //disable key press
}
}
