// JavaScript Document
// Created By: Rajesh Yadav<yadavrajesh25june@gmail.com>   
//Updated By: Sudeep Srivastava


function all_form()
{
	//alert();
	 var len=document.f2.elements.length;
	for(i=0;i<len;i++)
	{
		//alert( document.form1.elements[i].selectedIndex==0);
		if(document.f2.elements[i].type=='select-one' && document.f2.elements[i].value=="")
		{
			alert('Please fill the form properly!');
			document.f2.elements[i].focus();
			return false;
			
		}
		
	}
	var name=document.f2.firstname.value
	if(name=="")
	{
		alert("Applicant's Name Should not be blank");
		document.f2.firstname.focus()
		return false
	}
	var email=document.f2.email.value;
	if(email=="")
	{
		alert("E-mail Should not be blank");
		document.f2.email.focus()
		return false
	}
		
	emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
apos=emailfilter.test(email);
if (apos==false) 
  {
	  alert("Invalid e-mail address. Please enter right e-mail.");
	  document.f2.email.focus()
	  return false;
 }
 ///Adress
 
 if(document.f2.pr_line1.value=="")
 {
alert("Address in Correspondence Address Should not be blank");
document.f2.pr_line1.focus()
return false	 
 }
 if(document.f2.city.value=="")
 {
alert("City in Correspondence Address Should not be blank");
document.f2.city.focus()
return false
 }
if(document.f2.pin.value=="")
 {
alert("Pin in Correspondence Address Should not be blank");
document.f2.pin.focus()
return false
 }

  if(document.f2.mobile.value=="")
 {
alert("Mobile No. in Correspondence Address Should not be blank");
document.f2.mobile.focus()
return false
 }
 //Adress2
  if(document.f2.pe_line1.value=="")
 {
alert("Address in Permanent Address Should not be blank");
document.f2.pe_line1.focus()
return false	 
 }
 if(document.f2.city2.value=="")
 {
alert("City in Permanent Address Should not be blank");
document.f2.city2.focus()
return false
 }

//10th vel
 if(document.f2.hid_val.value=="6" || document.f2.hid_val.value=="7")
 {
 }
 else
 {
	 if(document.f2.pin2.value=="")
 {
alert("Pin in Permanent Address Should not be blank");
document.f2.pin2.focus()
return false
 }

  if(document.f2.mobile2.value=="")
 {
alert("Mobile No. in Permanent Address Should not be blank");
document.f2.mobile2.focus()
return false
 }
if(document.f2.mark1.value=="")
 {
alert("% of Marks in 10th Education Should not be blank");
document.f2.mark1.focus()
return false
 }
 if(document.f2.colL1.value=="")
 {
alert("College / Institute with Place in 10th Education Should not be blank");
document.f2.colL1.focus()
return false
 }
 if(document.f2.year1.value=="")
 {
alert("Year Of Completion in 10th Education Should not be blank");
document.f2.year1.focus()
return false
 }
//12th val
if(document.f2.mark2.value=="")
 {
alert("% of Marks in 12th Education Should not be blank");
document.f2.mark2.focus()
return false
 }
 if(document.f2.colL2.value=="")
 {
alert("College / Institute with Place in 12th Education Should not be blank");
document.f2.colL2.focus()
return false
 }
 if(document.f2.year2.value=="")
 {
alert("Year Of Completion in 12th Education Should not be blank");
document.f2.year2.focus()
return false
 }
 ///Graduation
 if(document.f2.mark3.value=="")
 {
alert("% of Marks in Graduation Education Should not be blank");
document.f2.mark3.focus()
return false
 }
 if(document.f2.colL3.value=="")
 {
alert("College / Institute with Place in Graduation Education Should not be blank");
document.f2.colL3.focus()
return false
 }
 if(document.f2.year3.value=="")
 {
alert("Year Of Completion in Graduation Education Should not be blank");
document.f2.year3.focus()
return false
 }
 ////Post Gread
 

 if(document.f2.mark4.value=="")
 {
alert("% of Marks in Post Graduation Education Should not be blank");
document.f2.mark4.focus()
return false
 }
 if(document.f2.colL4.value=="")
 {
alert("College / Institute with Place in Post Graduation Education Should not be blank");
document.f2.colL4.focus()
return false
 }
 if(document.f2.year4.value=="")
 {
alert("Year Of Completion in Post Graduation Education Should not be blank");
document.f2.year4.focus()
return false
 }
 }
 var val_typ_phd=document.f2.val_typ_phd.value
 
// alert(val_typ_phd);
 if(document.f2.val_typ_phd.value=="Completed")
 {
	 //alert(document.f2.mark5.value)
 if(document.f2.mark5.value=="")
 {
	 //alert('Test')
alert("% of Marks in Ph.D Education Should not be blank");
document.f2.mark5.focus()
return false
 }
 if(document.f2.colL5.value=="")
 {
alert("College / Institute with Place in Ph.D Education Should not be blank");
document.f2.colL5.focus()
return false
 }
 if(document.f2.year5.value=="")
 {
alert("Year Of Completion in Ph.D Education Should not be blank");
document.f2.year5.focus()
return false
 }



}
if(val_typ_phd=="Pursuing")
 {

 if(document.f2.colL5.value=="")
 {
alert("College / Institute with Place in Ph.D Education Should not be blank");
document.f2.colL5.focus()
return false
 }
 
 }
 
 if(document.f2.ufile.value.lastIndexOf(".doc")==-1 || document.f2.ufile.value.lastIndexOf(".doc")=="" )
 {
alert("Kindly Attach CV. It should be .doc extention file");
document.f2.ufile.focus()
return false
 }
	return true;

	
}
function charValidation(e) // function for validating year
{
	//alert(e.which);
	var keynum
	var keychar
	if(window.event) // IE
	{
  		
	keynum = e.keyCode
	//alert(keynum);
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}
	keychar=String.fromCharCode(keynum)
	if(keynum==32 || keynum==46 || (keynum>=37 && keynum<=40) || keynum==9)
	{
	   return true
	}
	else if(keynum==110 || (keynum>=96 && keynum<=106) ||keynum==190 )
	{
		return false
	}
	else
	   return isNaN(keychar)
	   
	   //call as numberValidation(event) on keyDown Event
}

function numValidation(e) // function for validating year
{
	//alert(e.which);
	var keynum
	var keychar
	if(window.event) // IE
	{
  		
	keynum = e.keyCode
	//alert(keynum);
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}
	keychar=String.fromCharCode(keynum)
	 if((keynum>=48 && keynum<=57)|| (keynum>=96 && keynum<=106) || keynum==9)
	{
		return true
	}
	else if(keynum>=65 && keynum<=95)
	{
	   return false
	}

	else
	   return isNaN(keychar)
	   
	   //call as numberValidation(event) on keyDown Event
}

function changeCase(frmObj) 
{
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;

tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;

if (strLen > 0) 
{
for (index = 0; index < strLen; index++) 
{
if (index == 0)  
{
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else
{
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  
{
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
}
}
}
}
frmObj.value = tmpStr;
}
