//validation
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;

var iChars = "'\<>";
var iChars1 = "'\<>";
//var iChars1 = "!@$^*()=[]\';{}|\"<>";

// JavaScript Document for ARC

// Check Text or Not
			function isText(str)
			{
			var i=0;
			if(str.charAt(0)==' ')i++;
			while(i<str.length)
			{
			if (str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
			return false;
			i++;
			}
			return true;
			}

//Check city or not
			function isCity(str)
			{
			var i=0;
			while(i<str.length)
			{
			if (str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
			{
			return false;
			}
			i++;
			}
			return true;
			}
			
// Check Phone Number or not
			function isTelephoneNumber(str)
			{
			var i=0;
			if(str.charAt(0)=='+')i++;
			while(i<str.length)
			{
			if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' ' || str.charAt(i)=='-' || str.charAt(i)=='(' || str.charAt(i)==')') )
			return false;
			i++;
			}
			return true;
			}
// Check Phone Number length
			function isLength(str)
			{
			var len=str.length;
			if(len<10)
			{
			return false;
			}
			return true;
			}
// Check Number or Not
			function isNumeric(str)
			{
			var i=0;
			while(i<str.length)
			{
			if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' '))
			return false;
			i++;
			}
			return true;
			}
			
// Remove the empty space
			function trim(String)
			{
			if (String == null)
			{   
			return ("");
			}
			return String.replace(/(^\s+)|(\s+$)/g,"");
			}
function career_validation()
{
	if(document.getElementById("clinician").value == 'Clinician'){	
		if (document.getElementById("app_position").value==0){
			alert ("Please select applied position");
			document.getElementById("app_position").focus();
			return false;
		}
	}
	if (document.getElementById("name").value==0){
		alert ("Please enter your name");
		document.getElementById("name").focus();
		return false;}
		else if(!isText(document.getElementById("name").value))
				{
				alert("Name field will only accept alphabetic values");
				document.getElementById("name").focus();
				return false;
				}
		if (document.getElementById("dob").value==""){
		alert ("Please select date of birth");
		document.getElementById("dob").focus();
		return false;}
	if (document.getElementById("contact_detail").value=='') {
		alert ("Please enter contact details");
		document.getElementById("contact_detail").focus();
		return false;}
		
	if (emailfilter.test(document.getElementById("email").value)==false) {
		alert ("Please enter valid e-mail id");
		document.getElementById("email").focus();
		return false;}
	
		
	if (document.getElementById("speciality").value==0){
		alert ("Please enter speciality");
		document.getElementById("speciality").focus();
		return false;}
		else if(!isText(document.getElementById("speciality").value))
				{
				alert("Speciality field will only accept alphabetic values");
				document.getElementById("speciality").focus();
				return false;
				}
	if (document.getElementById("speciality").value=='Others'){
		   if (document.getElementById("oth_speciality").value==0){
			alert ("Please enter other speciality");
			document.getElementById("oth_speciality").focus();
			return false;}
			else if(!isText(document.getElementById("oth_speciality").value))
				{
				alert("Speciality field will only accept alphabetic values");
				document.getElementById("oth_speciality").focus();
				return false;
				}
	}
	/*if (document.getElementById("fname").value==0){
		alert ("Please enter your father's name");
		document.getElementById("fname").focus();
		return false;}
		else if(!isText(document.getElementById("fname").value))
				{
				alert("Father's Name field will only accept alphabetic values");
				document.getElementById("fname").focus();
				return false;
				}
	if (document.getElementById("mname").value==0){
		alert ("Please enter your mother's name");
		document.getElementById("mname").focus();
		return false;}
		else if(!isText(document.getElementById("mname").value))
				{
				alert("Mother's Name field will only accept alphabetic values");
				document.getElementById("mname").focus();
				return false;
				}
		
      if (document.getElementById("contact_no").value==0){
		alert ("Please select your contact no");
		document.getElementById("contact_no").focus();
		return false;}
	if (document.getElementById("contact_no").value!="") {
		if(isNaN(document.getElementById("contact_no").value))
		{
		alert ("Contact number should be numeric");
		document.getElementById("contact_no").value="";
		document.getElementById("contact_no").focus();
		return false;}
	}			
		
	
   		
	  if (document.getElementById("current_org").value==0){
		alert ("Please enter current organization");
		document.getElementById("current_org").focus();
		return false;}
     if (document.getElementById("current_des").value==0){
		alert ("Please enter current designation");
		document.getElementById("current_des").focus();
		return false;}
	if (document.getElementById("pg").checked==true){
		if(document.getElementById("ins_name1").value==""){
		alert ("Please enter name of institue");
		document.getElementById("ins_name1").focus();
		return false;}	
		if(document.getElementById("year_passing1").value==""){
		alert ("Please enter your year passing");
		document.getElementById("year_passing1").focus();
		return false;}	
		if (document.getElementById("year_passing1").value!="") {
		if(isNaN(document.getElementById("year_passing1").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing1").value="";
		document.getElementById("year_passing1").focus();
		return false;}
	}			
		if(document.getElementById("grade1").value==""){
		alert ("Please enter your grade");
		document.getElementById("grade1").focus();
		return false;}	
		if (document.getElementById("year_passing2").value!="") {
		if(isNaN(document.getElementById("year_passing2").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing2").value="";
		document.getElementById("year_passing2").focus();
		return false;}
	  }	
	  if (document.getElementById("year_passing3").value!="") {
		if(isNaN(document.getElementById("year_passing3").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing3").value="";
		document.getElementById("year_passing3").focus();
		return false;}
	}	
     }
	  if (document.frm.g.checked==false){
		alert ("Please select your ug");
		document.frm.g.focus();
		return false;}	
	 if (document.getElementById("g").checked==true){
		if(document.getElementById("ins_name4").value==""){
		alert ("Please enter name of institue");
		document.getElementById("ins_name4").focus();
		return false;}	
		if(document.getElementById("year_passing4").value==""){
		alert ("Please enter your year passing");
		document.getElementById("year_passing4").focus();
		return false;}	
		if (document.getElementById("year_passing4").value!="") {
		if(isNaN(document.getElementById("year_passing4").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing4").value="";
		document.getElementById("year_passing4").focus();
		return false;}
	}	
		if(document.getElementById("grade4").value==""){
		alert ("Please enter your grade");
		document.getElementById("grade4").focus();
		return false;}	
		if (document.getElementById("year_passing5").value!="") {
		if(isNaN(document.getElementById("year_passing5").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing5").value="";
		document.getElementById("year_passing5").focus();
		return false;}
	}	
	if (document.getElementById("year_passing6").value!="") {
		if(isNaN(document.getElementById("year_passing6").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing6").value="";
		document.getElementById("year_passing6").focus();
		return false;}
	}	
   }
	  if (document.getElementById("twelve").checked==false){
		alert ("Please select your XII");
		document.getElementById("twelve").focus();
		return false;}	
	 if (document.getElementById("twelve").checked==true){
		if(document.getElementById("ins_name7").value==""){
		alert ("Please enter name of institue");
		document.getElementById("ins_name7").focus();
		return false;}	
		if(document.getElementById("year_passing7").value==""){
		alert ("Please enter your year passing");
		document.getElementById("year_passing7").focus();
		return false;}	
		if (document.getElementById("year_passing7").value!="") {
		if(isNaN(document.getElementById("year_passing7").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing7").value="";
		document.getElementById("year_passing7").focus();
		return false;}
	}	
		if(document.getElementById("grade7").value==""){
		alert ("Please enter your grade");
		document.getElementById("grade7").focus();
		return false;}	
     }
	  if (document.getElementById("ten").checked==false){
		alert ("Please select your X");
		document.getElementById("ten").focus();
		return false;}	
	 if (document.getElementById("ten").checked==true){
		if(document.getElementById("ins_name8").value==""){
		alert ("Please enter name of institue");
		document.getElementById("ins_name8").focus();
		return false;}	
		if(document.getElementById("year_passing8").value==""){
		alert ("Please enter your year passing");
		document.getElementById("year_passing8").focus();
		return false;}	
		if (document.getElementById("year_passing8").value!="") {
		if(isNaN(document.getElementById("year_passing8").value))
		{
		alert ("year passing number should be numeric");
		document.getElementById("year_passing8").value="";
		document.getElementById("year_passing8").focus();
		return false;}
	}	
		if(document.getElementById("grade8").value==""){
		alert ("Please enter your grade");
		document.getElementById("grade8").focus();
		return false;}	
     }*/
	if (document.getElementById("location").value==0){
		alert ("Please select preference location");
		document.getElementById("location").focus();
		return false;}	
    if (document.getElementById("upload").value==0){
		alert ("Please select attach file document file");
		document.getElementById("upload").focus();
		return false;}	
		   var aa=document.getElementById("upload").value;
		 var bb=aa.indexOf(".doc");
		 var cc=aa.indexOf(".docx");
		 var dd=aa.indexOf(".pdf");
		 if((bb==-1) && (cc==-1) &&(dd==-1)){
		alert ("Please attach document file only");
		document.getElementById("upload").focus();
		return false;} 
/*for (var i = 0; i < document.getElementById("address").value.length; i++) {
  	if (iChars1.indexOf(document.getElementById("address").value.charAt(i)) != -1) {
  	alert ("Your address has special characters. \nThese are not allowed.");
  	return false;
  	}
}
 if (document.getElementById("txtcity2").value==0){
		alert ("Please enter your city");
		document.getElementById("txtcity2").focus();
		return false;}
		else if(!isText(document.getElementById("txtcity2").value))
				{
				alert("This field will only accept alphabetic values");
				document.getElementById("txtcity2").focus();
				return false;
		
    if (document.getElementById("txtcomments2").value==0){
		alert ("Please enter your comments");
		document.getElementById("txtcomments2").focus();
		return false;	}
  if (document.getElementById("txtcomments2").value!=""){
  var cou=document.getElementById("txtcomments2").value.length;		
     if(cou>1500)
      {    
        alert ("Please enter your comments maxium 1500");
		document.getElementById("txtcomments2").focus();
		return false;	
      }
   }
for (var i = 0; i < document.getElementById("txtcomments2").value.length; i++) {
  	if (iChars.indexOf(document.getElementById("txtcomments2").value.charAt(i)) != -1) {
  	alert ("Your comments has special characters. \nThese are not allowed.");
  	return false;
  	}
}*/
var uword = hex_md5(document.getElementById(jfldid).value);

if (uword==cword[anum-1]) {
//dfsf
}
else {
alert("Enter the code as it is shown.");
document.getElementById(jfldid).focus();
return false;
}
return true;
}

function getquoteValidation()
{
	var txtname=document.getElementById("name");
	var email=document.getElementById("email");
	var address=document.getElementById("address");
	var objcomments=document.getElementById("txtcomments");
		
	if (document.getElementById("name").value==0){
		alert ("Please enter your name");
		document.getElementById("name").focus();
		return false;}
		else if(!isText(document.getElementById("name").value))
				{
				alert("Name will only accept alphabetic values");
				document.getElementById("name").focus();
				return false;
				}
	if (emailfilter.test(email.value)==false) {
		alert ("please enter valid E-Mail ID");
		email.focus();
		return false;
	}
	if (address.value==""){
		alert ("please enter your Address");
		address.focus();
		return false;
	} 
	if (document.getElementById("address").value!=""){
  var cou1=document.getElementById("address").value.length;		
     if(cou1>100)
      {    
        alert ("Please enter your adrress maxium 100");
		document.getElementById("address").focus();
		return false;	
      }
   }
   for (var i = 0; i < document.getElementById("address").value.length; i++) {
  	if (iChars.indexOf(document.getElementById("address").value.charAt(i)) != -1) {
  	alert ("Your address has special characters(single, double and <,>). \nThese are not allowed.");
  	return false;
  	}
}
	 if (objcomments.value==""){
		alert ("please enter your comments");
		objcomments.focus();
		return false;
	}
	if (document.getElementById("txtcomments").value!=""){
    var cou=document.getElementById("txtcomments").value.length;		
        if(cou>1500)
         {    
        alert ("Please enter your comments maxium 1500");
		document.getElementById("txtcomments").focus();
		return false;	
        }
     }
	for (var i = 0; i < document.getElementById("txtcomments").value.length; i++) {
  	if (iChars.indexOf(document.getElementById("txtcomments").value.charAt(i)) != -1) {
  	alert ("Your message has special characters(single, double and <,>). \nThese are not allowed.");
  	return false;
  	}
}
	/* if (document.getElementById("upload").value==""){
		alert ("Please Browse your attach file");
		document.getElementById("upload").focus();
		return false;}  */
	  	if (document.getElementById("upload").value!=""){
		 var aa1=document.getElementById("upload").value;
		 var bb1=aa1.indexOf(".jpg");
		 var cc1=aa1.indexOf(".jpeg");
		 var dd1=aa1.indexOf(".gif");
		 var ee1=aa1.indexOf(".png");
		 var ff1=aa1.indexOf(".doc");
		 var gg1=aa1.indexOf(".xls");
		 var hh1=aa1.indexOf(".ppt");
		 var jj1=aa1.indexOf(".pdf");
		 if((bb1==-1)&&(cc1==-1)&&(dd1==-1)&&(ee1==-1)&&(ff1==-1)&&(gg1==-1)&&(hh1==-1)&&(jj1==-1)){
		alert ("Please attach .jpg, .gif, .png, .doc, .xls, .ppt, .pdf format only");
		document.getElementById("upload").focus();
		return false;} 
		}
	var uword = hex_md5(document.getElementById(jfldid).value);

if (uword==cword[anum-1]) {
//document.frm.submit();
//return true;
}
else {
alert("Enter the code as it is shown.");
document.getElementById(jfldid).focus();
return false;
}
return true;
}
