//document edit

function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if ((charCode >=48 && charCode <=57 )|| (charCode == 46 )||(charCode == 10 )||(charCode == 13 )|| (charCode == 8)||(charCode == 32)||(charCode == 45))
        {
	       return true; 
        }
         else
          {
	         alert("Please Enter Only Numbers");
            return false;
        }
        
    }

function accountform()
{
	
	var roll=document.getElementById("roll").value;
	var pass=document.getElementById("pass").value;
	var cpass=document.getElementById("cpass").value;
	var fname=document.getElementById("fname").value;
	var lname=document.getElementById("lname").value;
	var nickname=document.getElementById("nickname").value;
	
	var batch=document.getElementById("batch").value;
	var house=document.getElementById("house").value;
	
    
// validation for roll number
	 if(roll=="")
	 {
		
		alert("Please enter the roll number");
		document.frm.roll.focus();
		document.frm.roll.select();
		return false;
		
	}

	if(roll!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|@._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for(i=0; i<invalids.length; i++) 
		{
			if(roll.indexOf(invalids.charAt(i)) >= 0 )
			{
				alert("Roll number should be in numbers");
				document.frm.roll.value="";
				document.frm.roll.focus();
				document.frm.roll.select();
				return false;
				
			}
		}
	}
	
	if(roll.length>4)
		{
		alert("Enter only 4 digits");
		document.frm.roll.value="";
		document.frm.roll.focus();
		document.frm.roll.select();
		 return false;
		}
	

	//validation for password

if(pass==""){
		alert("Please enter the Password");
		document.frm.pass.focus();
		document.frm.pass.select();
		return false;
		
	}
	if(pass.length<5){
		alert("The password should be enter 6 or more characters");
		document.frm.pass.value="";
		document.frm.pass.focus();
		document.frm.pass.select();
		return false;
	}
	
	if(cpass==""){
		alert("Please enter the Confirm Password");
		document.frm.cpass.focus();
		document.frm.cpass.select();
		return false;
	}
	if(pass!=cpass){
		alert("Passwords are not same, Please Re-enter");
		document.frm.pass.value="";
		document.frm.cpass.value="";
		document.frm.pass.focus();
		document.frm.pass.select();
		return false;
		
	}



	//validation for First name


 if(fname=="")
	 {
		alert("Please enter the First name");
		document.frm.fname.focus();
		document.frm.fname.select();
		return false;
	}



	if(fname!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
		for(i=0; i<invalids.length; i++) 
		{
			if(fname.indexOf(invalids.charAt(i)) >= 0 )
			{
				alert("First Name should be contains Alphabets");
				document.frm.fname.value="";
				document.frm.fname.focus();
				document.frm.fname.select();
				return false;
			}
		}
	}
	
	if(fname.length<3){
		alert("Enter 3 or more characters");
		document.frm.fname.value="";
		document.frm.fname.focus();
		document.frm.fname.select();
		return false;
	}

//validation for last name

//if(lname=="")
//	 {
////		document.getElementById("err_lname").className='error';
////		document.getElementById("err_lastname").innerHTML="Please enter the Last name";
//		alert("Please enter the Last name");
//		document.frm.lname.focus();
//		document.frm.lname.select();
//		return false;
//		//isvalid =false;
//	}

	if(lname!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
		for(i=0; i<invalids.length; i++) 
		{
			if(lname.indexOf(invalids.charAt(i)) >= 0 )
			{
				alert("Last Name should be contains Alphabets");
				document.frm.lname.value="";
				document.frm.lname.focus();
				document.frm.lname.select();
				return false;
				
			}
		}
	
	}
//	if(lname.length<1){
////		document.getElementById("err_lname").className='error';
////		document.getElementById("err_lastname").innerHTML="Enter 3 or more characters";
//		alert("The Last name should be enter 3 or more characters");
//		document.frm.lname.value="";
//		document.frm.lname.focus();
//		document.frm.lname.select();
//		return false;
//		//isvalid =false;
//	}



	//validation for nickname

//if(nickname=="")
//	 {
////		document.getElementById("err_nname").className='error';
////		document.getElementById("err_nickname").innerHTML="Please enter the nick name";
//		alert("Please enter the nick name");
//		document.frm.nickname.focus();
//		document.frm.nickname.select();
//		return false;
//		//isvalid =false;
//	}

	if(nickname!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
		for(i=0; i<invalids.length; i++) 
		{
			if(nickname.indexOf(invalids.charAt(i)) >= 0 )
			{	
				alert("Nick Name should be contains Alphabets");
				document.frm.nickname.value="";
				document.frm.nickname.focus();
				document.frm.nickname.select();
				return false;
				
			}
		}
	}
	
//	if(nickname.length<1){
////		document.getElementById("err_nname").className='error';
////		document.getElementById("err_nickname").innerHTML="Enter 3 or more characters";
//		alert("Enter 3 or more characters");
//		document.frm.nickname.value="";
//		document.frm.nickname.focus();
//		document.frm.nickname.select();
//		return false;
//		//isvalid =false;
//	}

	
	// validation for batch
	
	if(batch=="0")
		{
		alert("Please select batch");
		document.frm.batch.focus();
		return false;
		}

// validation for house

		if(house=="0"){
		alert("Please select house");
		document.frm.house.focus();
		return false;
		
	}



return true;

document.frm.submit();
}

//////////////////////////////////////////////////////////////////////////////////////


function datevali()
{
//var arr=document.getElementById("datee").value.split('-');
//var myDate = new Date;

 date1 = new Array();
 date2 = new Array();
 date1 = document.frm.datee.value.split("-");
 date2 = document.frm.vali.value.split("-");
 var sub1=new Date(date1[2], date1[1]-1, date1[0]);
 var sub2=new Date(date2[2], date2[1]-1, date2[0]);
 var one_day=1000*60*60*24;
 
 var lastdatetimeleft =Math.ceil((sub1.getTime()-sub2.getTime())/(one_day));
 var startdatetimeleft =Math.ceil((sub2.getTime()-sub1.getTime())/(one_day));
  
  if(startdatetimeleft < '0'){
  alert("Date should not be Greater than Today Date");

  return false;
  }

return true;

document.frm.submit();
}


// Validation for Personal Details

function personalform()
{
	//validate date 
		

		var arr=document.getElementById("datee").value.split('-');
		var myDate = new Date;
		myDate.setDate(parseInt(arr[2]));
		myDate.setMonth(parseInt(arr[1])-1); // January = 0
		myDate.setFullYear(parseInt(arr[0])); 
		var today = new Date;
		today.setFullYear(parseInt(today.getFullYear())-11);
		if (myDate > today) 
		{
		alert('Age must above 11years so, Please Re-enter  ');
		document.frm.datee.focus();
		document.frm.datee.value='';
		document.frm.datee.select();
		return false;
		}

	var datee=document.getElementById("datee").value;
	var peraddress=document.getElementById("peraddress").value;
	var countryy=document.getElementById("countryy").value;
	var statee=document.getElementById("statee").value;
	var cityy=document.getElementById("cityy").value;

	//var mycountry=document.getElementById("mycountry").value;
	var mystatee=document.getElementById("mystatee").value;
	var mycitye=document.getElementById("mycitye").value;
	
	
	
// validation for date

if(datee=="")
	 {
		alert("Please select the date");
		document.frm.datee.focus();
		document.frm.datee.select();
		return false;
		//isvalid =false;
	}


	
//validation for permanent address

if(peraddress=="")
	 {
		alert("Please enter the address");
		document.frm.peraddress.focus();
		document.frm.peraddress.select();
		return false;
		//isvalid =false;
	}

//	if(peraddress!="")
//	{
//		var invalids = "!#$%^&*()-=[]{}`~'<>/?;:\|_";
//		for(i=0; i<invalids.length; i++) 
//		{
//			if(peraddress.indexOf(invalids.charAt(i)) >= 0 )
//			{	
//				alert("Address should not be contains any special characters");
//				document.frm.peraddress.value="";
//				document.frm.peraddress.focus();
//				document.frm.peraddress.select();
//				return false;
//				//isvalid =false;
//			}
//		}
//	}
	
	if(peraddress.length<3){
		alert("Enter 3 or more characters");
		document.frm.peraddress.value="";
		document.frm.peraddress.focus();
		document.frm.peraddress.select();
		return false;
		
	}
// validation for country
	
	if(countryy=="0"){
		alert("Please select country");
		document.frm.countryy.focus();
		return false;
		
	}
// validation for state


if(statee=="0" && mystatee=="")
	{
		alert("Please select state");
		document.frm.statee.focus();
		return false;
		
	}

	
// validation for city

	
	if(cityy=="0" && mycitye=="")
		{

		alert("Please select city");
		document.frm.cityy.focus();
		return false;
		
		}






return true;
document.frm.submit();

}


////enable the my country
//function mycountryenable()
//{
//	
//	if(document.getElementById("mycoun").checked)
//	{
//		
//		document.getElementById("my_country").style.display = "block"; 
//	}
//	else 
//	{
//		document.getElementById("mycountry").value="";
//		document.getElementById("my_country").style.display = "none"; 
//	}
//	
//
//}
//enable the my college
function mycollenable()
{
	
	if(document.getElementById("mycoll").checked)
	{
		document.getElementById("ecollege_name").value="Other";
		document.getElementById("my_coll").style.display = "block"; 
	}
	else 
	{
		document.getElementById("mycolle").value="";
		document.getElementById("my_coll").style.display = "none"; 
	}
	

}




function myqualifienable()
{
	
	if(document.getElementById("myquall").checked)
	{
		document.getElementById("edegree").value="34";
		document.getElementById("my_quali").style.display = "block"; 

	}
	else 
	{
		document.getElementById("myqul").value="";
		document.getElementById("my_quali").style.display = "none"; 
	}
	

}


//enable the my country
function mystateenable()
{
	
	if(document.getElementById("mystate").checked)
	{
		
		document.getElementById("my_state").style.display = "block"; 
	}
	else 
	{
		document.getElementById("mystate").value="";
		document.getElementById("my_state").style.display = "none"; 
	}
	

}

//enable the my city
function mycityenable()
{
	
	if(document.getElementById("mycity").checked)
	{
		
		document.getElementById("my_city").style.display = "block"; 
	}
	else 
	{
		document.getElementById("mycity").value="";
		document.getElementById("my_city").style.display = "none"; 
	}
	

}



function educationval()
{
	var eleftclass=document.getElementById("eleftclass").value;
	var eleftyear=document.getElementById("eleftyear").value;
	var edegree=document.getElementById("edegree").value;
	var myqul=document.getElementById("myqul").value;
	var ecollege_name=document.getElementById("ecollege_name").value;
	var mycolle=document.getElementById("mycolle").value;
	var eyear_pass_outt=document.getElementById("eyear_pass_outt").value;
	
//validation for leftclass

		if(eleftclass=="0"){
		alert("Please select the Std");
		document.frm.eleftclass.focus();
		return false;
		}	
		

//validation for leftyear

if(eleftyear=="0"){

		alert("Please select the Year");
		document.frm.eleftyear.focus();
		return false;
		}	

//validation for degree_level_highest

if(edegree=="0" && myqul==""){

		alert("Please select the qualification");
		document.frm.edegree.focus();
		return false;
		}	

//validation for universityid_sechighest

	if(ecollege_name=="0" && mycolle=="")
		{
		alert("Please select the College name");
		document.frm.ecollege_name.focus();
		return false;
		}	

//validation for year_pass_out

if(eyear_pass_outt=="0"){

		alert("Please select the Year pass out");
		document.frm.eyear_pass_outt.focus();
		return false;
		}	



return true;
document.frm.submit();
}

//////////////////////////////////////////////////////////////////////////////////////////////////

function Email(str)
 {
      var supported = 0;
   if (window.RegExp)
   {
   var tStr = "a";
   var tReg = new RegExp(tStr);
   if (tReg.test(tStr)) supported = 1;
   }
   if (!supported)
   return (str.indexOf(".") <= 2) || (str.indexOf("@") < 0);
   var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
   var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
   return (r1.test(str) || !r2.test(str));
  }

//////////////////////////////////////////////////////////////////////////////
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

//    Official VAlidation come here

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
///////////////////////////////////////////////////////////////////////////////



// validation for family form

function familyvalidation()
{
	var fmartial_status=document.getElementById("fmartial_status").value;
	var fspouse_name=document.getElementById("fspouse_name").value;
	var fdatee=document.getElementById("fdatee").value;
	


//validation for fmartial_status


if(fmartial_status=="0")
	{
		alert("Please select the martial status");
		document.frm.fmartial_status.focus();
		return false;
	}	


//validation for fspouse_name
if(fmartial_status!="Single")
{
if(fspouse_name=="")
	 {
		
		alert("Please enter the spouse name");
		document.frm.fspouse_name.focus();
		document.frm.fspouse_name.select();
		return false;
		//isvalid =false;
	}

//	if(fspouse_name!="")
//	{
//		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
//		for(i=0; i<invalids.length; i++) 
//		{
//			if(fspouse_name.indexOf(invalids.charAt(i)) >= 0 )
//			{
//				
//				alert("Name should be contains Alphabets");
//				document.frm.fspouse_name.value="";
//				document.frm.fspouse_name.focus();
//				document.frm.fspouse_name.select();
//				return false;
//				//isvalid =false;
//			}
//		}
//	}
	
	if(fspouse_name.length<3){
		
		alert("Enter 3 or more characters");
		document.frm.fspouse_name.value="";
		document.frm.fspouse_name.focus();
		document.frm.fspouse_name.select();
		return false;
	}


//validation for fdatee


if(fdatee=="")
	 {

		alert("Please select the date");
		document.frm.fdatee.focus();
		document.frm.fdatee.select();
		return false;
		//isvalid =false;
	}
}




return true;
document.frm.submit();

}

var uploadfileformat = new Array(".jpg", ".png", ".gif");

function contactvalidation()
{
	var cpresent_address=document.getElementById("cpresent_address").value;
	var photo=document.getElementById("photo").value;
	var cprimary_email=document.getElementById("cprimary_email").value;
	var csecondary_email=document.getElementById("csecondary_email").value;
	var ctelephone=document.getElementById("ctelephone").value;
	var cmobile_no=document.getElementById("cmobile_no").value;
	

//validation for cpresent_address


if(cpresent_address=="")
	 {

		alert("Please enter the Present address");
		document.frm.cpresent_address.focus();
		document.frm.cpresent_address.select();
		return false;
		//isvalid =false;
	}

//	if(cpresent_address!="")
//	{
//		var invalids = "!#$%^&*()-=[]{}`~'<>/?;:\|_";
//		for(i=0; i<invalids.length; i++) 
//		{
//			if(cpresent_address.indexOf(invalids.charAt(i)) >= 0 )
//			{	
//
//				alert("Address should not be contains any special characters");
//				document.frm.cpresent_address.value="";
//				document.frm.cpresent_address.focus();
//				document.frm.cpresent_address.select();
//				return false;
//				//isvalid =false;
//			}
//		}
//	}
	
	if(cpresent_address.length<3){

		alert("Enter 3 or more characters");
		document.frm.cpresent_address.value="";
		document.frm.cpresent_address.focus();
		document.frm.cpresent_address.select();
		return false;
		//isvalid =false;
	}





	//Validation for Photo Upload
if(photo!='')
	{
	
		fileformat=	photo.substring(photo.lastIndexOf("."),photo.length).toLowerCase();
		
		isValidImg=false;
		for(i=0;i< uploadfileformat.length;i++)
		{
			if(uploadfileformat[i]==fileformat)
			{
				isValidImg=true;
				break;
			}
		}
		if(isValidImg==false)
		{
			alert('Please Upload image type like  ".jpg", ".png", ".gif"');
			document.frm.photo.value="";
			document.frm.photo.focus();
			return false;

		}

	}






//validation for cprimary_email


if(cprimary_email=="")
	{
	alert("Please enter the Email address!");
	document.frm.cprimary_email.focus();
	document.frm.cprimary_email.select();
	return false;
	}
	else if(cprimary_email!=""){
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frm.cprimary_email.value)) 
	{
		}
		else
		{
		alert("Invalid E-mail Address! Please Re-enter.");
		document.frm.cprimary_email.value="";
		document.frm.cprimary_email.focus();
		document.frm.cprimary_email.select();
		return false;
		}
	}


//validation for csecondary_email

if(csecondary_email!=""){
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frm.csecondary_email.value)) 
	{
		}
		else
		{
		alert("Invalid E-mail Address! Please Re-enter.");
		document.frm.csecondary_email.value="";
		document.frm.csecondary_email.focus();
		document.frm.csecondary_email.select();
		return false;
		}
	}

//validation for ctelephone


if(ctelephone!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|@._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for(i=0; i<invalids.length; i++) 
		{
			if(ctelephone.indexOf(invalids.charAt(i)) >= 0 )
			{
				alert("Telephone number should be in numbers");
				
				document.frm.ctelephone.value="";
				document.frm.ctelephone.focus();
				document.frm.ctelephone.select();
				return false;
				//isvalid =false;
			}
			
		}
	}



//validation for cmobile_no


if(cmobile_no!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|@._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for(i=0; i<invalids.length; i++) 
		{
			if(cmobile_no.indexOf(invalids.charAt(i)) >= 0 )
			{
				alert("Mobile number should be in numbers");
				
				document.frm.cmobile_no.value="";
				document.frm.cmobile_no.focus();
				document.frm.cmobile_no.select();
				return false;
				//isvalid =false;
			}
			
		}
	}




	return true;
document.frm.submit();

}




function invitefriend()
{
	
	var fname=document.getElementById("fname").value;
	//var lname=document.getElementById("lname").value;
	var email=document.getElementById("email").value;

// validation for First name 

if(fname=="")
	 {
		//document.getElementById("err_fname").className='error';
		//document.getElementById("err_fastname").innerHTML="Please enter the First name";
		alert("Please enter the First name");
		document.frm.fname.focus();
		document.frm.fname.select();
		return false;
		//isvalid =false;
	}

if(fname!="")
	{
		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
		for(i=0; i<invalids.length; i++) 
		{
			if(fname.indexOf(invalids.charAt(i)) >= 0 )
			{
				//document.getElementById("err_fname").className='error';
				//document.getElementById("err_fastname").innerHTML="Name should be contains Alphabets";
				alert("Name should be contains Alphabets");
				document.frm.fname.value="";
				document.frm.fname.focus();
				document.frm.fname.select();
				return false;
				//isvalid =false;
			}
		}
	}
	
	if(fname.length<3){
		//document.getElementById("err_fname").className='error';
		//document.getElementById("err_fastname").innerHTML="Enter 3 or more characters";
		alert("Enter 3 or more characters");
		document.frm.fname.value="";
		document.frm.fname.focus();
		document.frm.fname.select();
		return false;
	}



//		//validation for last name
//
//
//	if(lname!="")
//	{
//		var invalids = "!#$%^&*()-=[]{}`~,'<>/?;:\|0123456789@._";
//		for(i=0; i<invalids.length; i++) 
//		{
//			if(lname.indexOf(invalids.charAt(i)) >= 0 )
//			{
//
//				alert("Name should be contains Alphabets");
//				document.frm.lname.value="";
//				document.frm.lname.focus();
//				document.frm.lname.select();
//				return false;
//				//isvalid =false;
//			}
//		}
//	
//	
//	if(lname.length<3){
//
//		alert("The Last name should be enter 3 or more characters");
//		document.frm.lname.value="";
//		document.frm.lname.focus();
//		document.frm.lname.select();
//		return false;
//		//isvalid =false;
//	}
//
//}


	if(email=="")
	{
	alert("Please enter the Email address!");
	document.frm.email.focus();
	document.frm.email.select();
	return false;
	}
	else if(email!=""){
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.email.value)) 
	{
		}
		else
		{
		alert("Invalid E-mail Address! Please Re-enter.");
		document.frm.email.value="";
		document.frm.email.focus();
		document.frm.email.select();
		return false;
		}
	}

	return true;


}

function convertalive()
{
	
	var alive=document.getElementById("alive").value;

	if(alive=="0")
	{
		alert("Please select the Roll no to Change");
		document.frm.alive.focus();
		return false;
	}	


	return true;
}