// JavaScript Document

function clear_signup()
{
document.signup.reset();
}
function clear_forgotpass()
{
document.forgotpass.reset();
}
function clearForm(star1,rating1,star2,rating2,star3,rating3,form)
{
document.getElementById(form).reset();
width=0;
star = document.getElementById(star1)
star.style.width = (width) +"px";
document.getElementById(rating1).value = 0;
star = document.getElementById(star2)
star.style.width = (width) +"px";
document.getElementById(rating2).value = 0;
star = document.getElementById(star3)
star.style.width = (width) +"px";
document.getElementById(rating3).value = 0;
}
var r={'special':/[\W]/g}
function valid(o,w)
{
  o.value = o.value.replace(r[w],' ');
}
function validation2()
{
if(document.form2.name.value==0)
{
alert("Please enter teacher name")
document.form2.name.focus()
return false
}
if(document.form2.institute.value==0)
{
alert("Please enter institute name")
document.form2.institute.focus()
return false
}
if(document.form2.city.value==0)
{
alert("Please enter city")
document.form2.city.focus()
return false
}
if(document.form2.state.selectedIndex == 0)
{
alert("Please select state")
document.form2.state.focus()
return false
}
if(document.form2.rating_knowledge.value == 0)
{
alert("Please select subject knowledge rating")
return false
}
if(document.form2.rating_teaching_style.value == 0)
{
alert("Please select teaching style rating")
return false
}
if(document.form2.rating_overall_behaviour.value == 0)
{
alert("Please select accessibility rating")
return false
}
}
function validation3()
{
if(document.form2.rating_knowledge.value == 0)
{
alert("Please select subject knowledge rating")
return false
}
if(document.form2.rating_teaching_style.value == 0)
{
alert("Please select teaching style rating")
return false
}
if(document.form2.rating_overall_behaviour.value == 0)
{
alert("Please select accessibility rating")
return false
}
}
function validation_ontdetail()
{
if(document.form_ontdetail.name_ontdetail.value==0)
{
alert("Please enter teacher name")
document.form_ontdetail.name_ontdetail.focus()
return false
}
if(document.form_ontdetail.institute_ontdetail.value==0)
{
alert("Please enter institute name")
document.form_ontdetail.institute_ontdetail.focus()
return false
}
if(document.form_ontdetail.city.value==0)
{
alert("Please enter city")
document.form_ontdetail.city.focus()
return false
}
if(document.form_ontdetail.state_ontdetail.selectedIndex == 0)
{
alert("Please select state")
document.form_ontdetail.state_ontdetail.focus()
return false
}
if(document.form_ontdetail.rating_knowledge_ontdetail.value == 0)
{
alert("Please select subject knowledge rating")
return false
}
if(document.form_ontdetail.rating_teaching_style_ontdetail.value == 0)
{
alert("Please select teaching style rating")
return false
}
if(document.form_ontdetail.rating_overall_behaviour_ontdetail.value == 0)
{
alert("Please select accessibility rating")
return false
}
}
function validate_login()
{
if(document.login.username.value==0)
{
alert("Please enter your email")
document.login.username.focus()
return false
}
str=document.login.username.value
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.login.username.value=""
		   document.login.username.focus()
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.login.username.value=""
		   document.login.username.focus()
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.login.username.value=""
			document.login.username.focus()
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.login.username.value=""
			document.login.username.focus()
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.login.username.value=""
			document.login.username.focus()
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.login.username.value=""
			document.login.username.focus()
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.login.username.value=""
			document.login.username.focus()
		    return false
		 }
if(document.login.password.value==0)
{
alert("Please enter your password")
document.login.password.focus()
return false
}
}
function validate_signup()
{
if(document.signup.user_name.value==0)
{
alert("Please enter your name")
document.signup.user_name.focus()
return false
}
if(document.signup.user_email.value==0)
{
alert("Please enter your email")
document.signup.user_email.focus()
return false
}
str=document.signup.user_email.value
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.signup.user_email.value=""
		   document.signup.user_email.focus()
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.signup.user_email.value=""
		   document.signup.user_email.focus()
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.signup.user_email.value=""
			document.signup.user_email.focus()
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.signup.user_email.value=""
			document.signup.user_email.focus()
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.signup.user_email.value=""
			document.signup.user_email.focus()
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.signup.user_email.value=""
			document.signup.user_email.focus()
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.signup.user_email.value=""
			document.signup.user_email.focus()
		    return false
		 }
if(document.signup.user_gender.value==0)
{
alert("Please select your gender")
document.signup.user_gender.focus()
return false
}
if(document.signup.user_password.value==0)
{
alert("Please enter your password")
document.signup.user_password.focus()
return false
}
if(document.signup.user_password.value.length<5)
{
alert("Minimum password length is 5 characters")
document.signup.user_password.value=""
document.signup.user_password.focus()
return false
}
if(document.signup.confirm_password.value==0)
{
alert("Please confirm your password")
document.signup.confirm_password.focus()
return false
}
if(document.signup.user_password.value!=document.signup.confirm_password.value)
{
alert("Passwords don't match")
document.signup.user_password.value=""
document.signup.confirm_password.value=""
document.signup.user_password.focus()
return false
}
return true;
}
function validate_settings()
{
if(document.updatesettings.s_pass.value==0)
{
alert("Please enter your current password")
document.updatesettings.s_pass.focus()
return false
}
if(document.updatesettings.s_pass.value.length<5)
{
alert("Minimum password length is 5 characters")
document.updatesettings.s_pass.value=""
document.updatesettings.s_pass.focus()
return false
}
if(document.updatesettings.s_newpass.value==0)
{
alert("Please enter your new password")
document.updatesettings.s_newpass.focus()
return false
}
if(document.updatesettings.s_newpass.value.length<5)
{
alert("Minimum password length is 5 characters")
document.updatesettings.s_newpass.value=""
document.updatesettings.s_newpass.focus()
return false
}
if(document.updatesettings.s_cnfrmpass.value==0)
{
alert("Please confirm your new password")
document.updatesettings.s_cnfrmpass.focus()
return false
}
if(document.updatesettings.s_newpass.value!=document.updatesettings.s_cnfrmpass.value)
{
alert("Passwords don't match")
document.updatesettings.s_newpass.value=""
document.updatesettings.s_cnfrmpass.value=""
document.updatesettings.s_newpass.focus()
return false
}
}
function validate_general()
{
if(document.updategeneral.g_name.value==0)
{
alert("Please enter your name")
document.updategeneral.g_name.focus()
return false
}
if(document.updategeneral.birth_day.value==0)
{
alert("Please select day")
document.updategeneral.birth_day.focus()
return false
}
if(document.updategeneral.birth_month.value==0)
{
alert("Please select month")
document.updategeneral.birth_month.focus()
return false
}
if(document.updategeneral.birth_year.value==0)
{
alert("Please select year")
document.updategeneral.birth_year.focus()
return false
}
var d = new Date();
var current_date=(((1+d.getMonth())<10) ? "0" + (d.getMonth()+1): d.getMonth()+ 1) + "/" + (d.getDate() < 10? "0"+d.getDate() : d.getDate()) + "/" + d.getFullYear();
var month=(((1+d.getMonth())<10) ? "0" + (d.getMonth()+1): d.getMonth()+ 1);
var day=(d.getDate() < 10? "0"+d.getDate() : d.getDate());
var year=d.getFullYear();
var str=document.getElementById("g_dob").value
var abc=str.split("/")
var mm=abc[1]-month;
var dd=abc[0]-day;
var yyyy=abc[2]-year;
var diff=mm*30+dd+yyyy*365;
if(diff>0)
{
alert("DOB cannot be greater than current date")
document.updategeneral.g_dob.focus()
return false	
}
}
function validate_education()
{
if((document.updateeducation.qualification1.value==0) && (document.updateeducation.specialization1.value!=0 || document.updateeducation.institute1.value!=0 || document.updateeducation.yop1.value!=0))
{
alert("Please enter your highest qualification")
document.updateeducation.qualification1.focus()
return false
}
if((document.updateeducation.qualification2.value==0) && (document.updateeducation.specialization2.value!=0 || document.updateeducation.institute2.value!=0 || document.updateeducation.yop2.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification2.focus()
return false
}
if((document.updateeducation.qualification3.value==0) && (document.updateeducation.specialization3.value!=0 || document.updateeducation.institute3.value!=0 || document.updateeducation.yop3.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification3.focus()
return false
}
if((document.updateeducation.qualification4.value==0) && (document.updateeducation.specialization4.value!=0 || document.updateeducation.institute4.value!=0 || document.updateeducation.yop4.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification4.focus()
return false
}
if((document.updateeducation.qualification5.value==0) && (document.updateeducation.specialization5.value!=0 || document.updateeducation.institute5.value!=0 || document.updateeducation.yop5.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification5.focus()
return false
}
if((document.updateeducation.qualification6.value==0) && (document.updateeducation.specialization6.value!=0 || document.updateeducation.institute6.value!=0 || document.updateeducation.yop6.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification6.focus()
return false
}
if((document.updateeducation.qualification7.value==0) && (document.updateeducation.specialization7.value!=0 || document.updateeducation.institute7.value!=0 || document.updateeducation.yop7.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification7.focus()
return false
}
if((document.updateeducation.qualification8.value==0) && (document.updateeducation.specialization8.value!=0 || document.updateeducation.institute8.value!=0 || document.updateeducation.yop8.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification8.focus()
return false
}
if((document.updateeducation.qualification9.value==0) && (document.updateeducation.specialization9.value!=0 || document.updateeducation.institute9.value!=0 || document.updateeducation.yop9.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification9.focus()
return false
}
if((document.updateeducation.qualification10.value==0) && (document.updateeducation.specialization10.value!=0 || document.updateeducation.institute10.value!=0 || document.updateeducation.yop10.value!=0))
{
alert("Please enter your qualification")
document.updateeducation.qualification10.focus()
return false
}
}
function validate_forgotpass()
{
if(document.forgotpass.user_email_forgotpass.value==0)
{
alert("Please enter your email")
document.forgotpass.user_email_forgotpass.focus()
return false
}
str=document.forgotpass.user_email_forgotpass.value
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.forgotpass.user_email_forgotpass.value=""
		   document.forgotpass.user_email_forgotpass.focus()
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter your e-mail address in the format someone@example.com")
		   document.forgotpass.user_email_forgotpass.value=""
		   document.forgotpass.user_email_forgotpass.focus()
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.forgotpass.user_email_forgotpass.value=""
			document.forgotpass.user_email_forgotpass.focus()
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.forgotpass.user_email_forgotpass.value=""
			document.forgotpass.user_email_forgotpass.focus()
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.forgotpass.user_email_forgotpass.value=""
			document.forgotpass.user_email_forgotpass.focus()
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.forgotpass.user_email_forgotpass.value=""
			document.forgotpass.user_email_forgotpass.focus()
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter your e-mail address in the format someone@example.com")
			document.forgotpass.user_email_forgotpass.value=""
			document.forgotpass.user_email_forgotpass.focus()
		    return false
		 }
}
function validate_image()
{
if(document.updateimage.file.value==0)
{
alert("Please select a file to upload")
document.updateimage.file.focus()
return false
}
}
function del_comment(comment_id)
{
 var confirm_msg= confirm("Are you sure you want to delete this comment?");
 if (confirm_msg== true)
 {
   var uri= "delete_comment.php?com_id="+comment_id;
   window.location=uri;
 }
}
function del_comment_td(comment_id, tid)
{
 var confirm_msg= confirm("Are you sure you want to delete this comment?");
 if (confirm_msg== true)
 {
   var uri= "delete_comment_td.php?com_id="+comment_id+"&tid="+tid;
   window.location=uri;
 }
}
function select_all()
{
var selectAll = document.getElementById('hide_all');
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++)
{
if (inputs[i].type == 'checkbox' && inputs[i].id == 'chk') {
if(selectAll.checked==true)
inputs[i].checked = true;
else
inputs[i].checked = false;
}
}
}
function del_inst(id,id1)
{
 var confirm_msg= confirm("Are you sure you want to remove this qualification?");
 if (confirm_msg== true)
 {	
 	var x = document.getElementById('table').value;
	document.getElementById('table').value=parseInt(x)-1;
	if(document.getElementById('table').value<=10)
		{
			document.getElementById('add_qualification').style.display='block';
		}
   document.getElementById(id1).style.display='none';
   var uri= "updateprofile.php?action=8&id="+id+"&id1="+id1;
   window.location=uri;
 }
}
function remove_qualification(id,remove)
{
var y = document.getElementById(id).value;
var z = document.getElementById(remove).value; 
if(y!='')
{
	del_inst(y,z);
}
else
{
	var x = document.getElementById('table').value;
	document.getElementById('table').value=parseInt(x)-1;
	var m = document.getElementById('table').value;
	document.getElementById(m).style.display='none';
	var n=z;
	if(n==m)
	{
	document.getElementById('qualification'+n).value='';
	document.getElementById('specialization'+n).value='';
	document.getElementById('institute'+n).value='';
	document.getElementById('yop'+n).value='';
	}
	else{
	for(n=z; n<m; n++)
	{
	var k=parseInt(n)+1;
	document.getElementById('qualification'+n).value=document.getElementById('qualification'+k).value;
	document.getElementById('specialization'+n).value=document.getElementById('specialization'+k).value;
	document.getElementById('institute'+n).value=document.getElementById('institute'+k).value;
	document.getElementById('yop'+n).value=document.getElementById('yop'+k).value;
	k++;
	}
	k--;
	document.getElementById('qualification'+k).value='';
	document.getElementById('specialization'+k).value='';
	document.getElementById('institute'+k).value='';
	document.getElementById('yop'+k).value='';
	}
	if(document.getElementById('table').value<=10)
		{
			document.getElementById('add_qualification').style.display='block';
		}
}
}
function show_info(id)
{
if(id=='div1')
{
	if(document.getElementById('div1').style.display=='none')
	{
		document.getElementById('div1').style.display='block';
		document.getElementById('div2').style.display='none';
		document.getElementById('div3').style.display='none';
		document.getElementById('div4').style.display='none';
		document.getElementById('link1').style.backgroundImage='url(images/arrowdown.gif)';
		document.getElementById('link2').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link3').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link4').style.backgroundImage='url(images/arrow.gif)';
	}
	else
	{
		document.getElementById('div1').style.display='none';
		document.getElementById('link1').style.backgroundImage='url(images/arrow.gif)';
	}
	if(calendarDiv.style.display=='block'){closeCalendar();}
}
if(id=='div2')
{
	if(document.getElementById('div2').style.display=='none')
	{
		document.getElementById('div2').style.display='block';
		document.getElementById('div1').style.display='none';
		document.getElementById('div3').style.display='none';
		document.getElementById('div4').style.display='none';
		document.getElementById('link1').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link2').style.backgroundImage='url(images/arrowdown.gif)';
		document.getElementById('link3').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link4').style.backgroundImage='url(images/arrow.gif)';
	}
	else
	{
		document.getElementById('div2').style.display='none';
		document.getElementById('link2').style.backgroundImage='url(images/arrow.gif)';
	}
	if(calendarDiv.style.display=='block'){closeCalendar();}
}
if(id=='div3')
{
	if(document.getElementById('div3').style.display=='none')
	{
		document.getElementById('div3').style.display='block';
		document.getElementById('div1').style.display='none';
		document.getElementById('div2').style.display='none';
		document.getElementById('div4').style.display='none';
		document.getElementById('link1').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link2').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link3').style.backgroundImage='url(images/arrowdown.gif)';
		document.getElementById('link4').style.backgroundImage='url(images/arrow.gif)';
	}
	else
	{
		document.getElementById('div3').style.display='none';
		document.getElementById('link3').style.backgroundImage='url(images/arrow.gif)';
	}
	if(calendarDiv.style.display=='block'){closeCalendar();}
}
if(id=='div4')
{
	if(document.getElementById('div4').style.display=='none')
	{
		document.getElementById('div4').style.display='block';
		document.getElementById('div1').style.display='none';
		document.getElementById('div2').style.display='none';
		document.getElementById('div3').style.display='none';
		document.getElementById('link1').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link2').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link3').style.backgroundImage='url(images/arrow.gif)';
		document.getElementById('link4').style.backgroundImage='url(images/arrowdown.gif)';
	}
	else
	{
		document.getElementById('div4').style.display='none';
		document.getElementById('link4').style.backgroundImage='url(images/arrow.gif)';
	}
	if(calendarDiv.style.display=='block'){closeCalendar();}
}
}
function validate_date(id1,id2,id3) {
var birth_year = document.getElementById(id3).value;
var birth_month = document.getElementById(id2).value;
var elSel = document.getElementById("birth_day");
if(birth_month == "" || birth_month == "1" || birth_month == "3" || birth_month == "5" || birth_month == "7" || birth_month == "8" || birth_month == "10" || birth_month == "12")
{
  if (elSel.length == 29)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '29';
	elOptNew.value = '29';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }
  if (elSel.length == 30)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '30';
	elOptNew.value = '30';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }
  if (elSel.length == 31)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '31';
	elOptNew.value = '31';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }
}
if(birth_month == "4" || birth_month == "6" || birth_month == "9" || birth_month == "11")
{
  if (elSel.length == 29)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '29';
	elOptNew.value = '29';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }
  if (elSel.length == 30)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '30';
	elOptNew.value = '30';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }
  if (elSel.length > 31)
  {
    elSel.remove(elSel.length - 1);
  }
}
if(birth_month == "2" && (parseInt(birth_year)%4==0 || birth_year == ""))
{
  if (elSel.length == 32)
  {
    elSel.remove(elSel.length - 2);
  }
  if (elSel.length == 31)
  {
    elSel.remove(elSel.length - 1);
  }
  if (elSel.length == 29)
  {
    var elOptNew = document.createElement('option');
	elOptNew.text = '29';
	elOptNew.value = '29';
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  }  
}
if(birth_month == "2" && parseInt(birth_year)%4!=0 && birth_year!="")
{
  if (elSel.length == 32)
  {
    elSel.remove(elSel.length - 3);
  }
  if (elSel.length == 31)
  {
    elSel.remove(elSel.length - 2);
  }
  if (elSel.length == 30)
  {
    elSel.remove(elSel.length - 1);
  }
}
var day_birth = document.getElementById(id1).value;
day_birth = day_birth < 10? "0"+day_birth : day_birth;
var month_birth = document.getElementById(id2).value;
month_birth = month_birth < 10? "0"+month_birth : month_birth;
document.getElementById("g_dob").value = day_birth+"/"+month_birth+"/"+document.getElementById(id3).value;
}