var request=null;var urlbase='http://engineer.org.in/include/';var count=0;function createRequest(){try{request=new XMLHttpRequest();}
catch(IE){try{request=new ActiveXObject("Msxml2.XMLHTTP");}
catch(IE1){try{request=new ActiveXObject("Microsoft.XMLHTTP");}
catch(Failed){request=null;}}}}
function checkpass(val){if(val==''){}}
function comPass(){var a=document.getElementById('conpass').value;var b=document.getElementById('password').value;if(a.indexOf(' ')>-1)
chan('perror','Password must not contain spaces',1);else{if(a.length<6)
chan('perror','Password length minimum 6 characters',1);else{if(!(a==b)){document.myform1.conpass.focus();chan('perror','Passwords do not match',1);}
else{count=count+1;chan('perror','Passwords match',3);}}}}
function checkLen(a){if(a.indexOf(' ')>-1){document.getElementById('password').focus();chan('perror','Password must not contain spaces',1);}
else if(a.length<6){document.getElementById('password').focus();chan('perror','Password length minimum 6 characters',1);}
else
document.getElementById('perror').style.display='none'}
function validate(){document.getElementById('regsuc').style.display='none'
if(document.getElementById('usernamel').value==''){document.getElementById('login_error1').style.display='block'
document.getElementById('login_error2').style.display='none'
document.getElementById('login_error3').style.display='none'
return false;}
else if(document.getElementById('passwordl').value==''){document.getElementById('login_error1').style.display='none'
document.getElementById('login_error2').style.display='block'
document.getElementById('login_error3').style.display='none'
return false;}
else{document.getElementById('login_error1').style.display='none'
document.getElementById('login_error2').style.display='none'
document.getElementById('login_error3').style.display='none'}}
function check_existence(){if(document.getElementById('username').value==''){chan('uerror','Please Enter a valid Username',1);}
else{createRequest();if(request==null)
alert("Error in Connection. Could not Validate. Please Re-Try");else{var url=urlbase+"username_avail.php";request.open("POST",url,true);request.onreadystatechange=username_existence;request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");request.send("username="+escape(document.getElementById('username').value));}}}
function username_existence(){if(request.readyState==4&&request.status==200){document.getElementById('goodtogo').value=0;var s=request.responseText;if(s==0){document.getElementById('goodtogo').value=1;count=count+1;chan('uerror','Username is available',3);}
if(s==1){document.getElementById('username').focus();chan('uerror','No username to verify availability',1);}
if(s==6){document.getElementById('username').focus();chan('uerror','Username cannot start with a space',1);}
if(s==7){document.getElementById('username').focus();chan('uerror','Username cannot end with a space',1);}
if(s==8){document.getElementById('username').focus();chan('uerror','Username must not contain spaces',1);}
if(s==9){document.getElementById('username').focus();chan('uerror','Username cannot contain invalid characters',1);}
if(s==10){document.getElementById('username').focus();chan('uerror','Username must contain 3-30 characters',1);}
if(s==4){document.getElementById('username').focus();chan('uerror','Username has already been taken.',2);}}
else{chan('uerror','Checking Username Availability.',4);}}
function settings_validate(){document.getElementById('fempty').style.display='none'
document.getElementById('curerr').style.display='none'
document.getElementById('perror').style.display='none'
if(document.getElementById('curpass').value==''){chan('fempty','Enter current password',1);return false;}
if(document.getElementById('password').value==''){chan('fempty','Enter new password',1);return false;}
if(document.getElementById('conpass').value==''){chan('fempty','Confirm new password',1);return false;}
if(document.getElementById('password').value){chan('fempty','Confirm new password',1);return false;}
if(!(document.getElementById('password').value==document.getElementById('conpass').value)){chan('perror','Passwords donot match',1);return false;}}
function register_validate(){close_all();if(document.getElementById('name').value==''){chan('fempty','You have not Entered your Name',1);chan('fempty1','You have not Entered your Name',1);return false;}
else if(document.getElementById('contactno').value==''){chan('fempty','You have not Entered your Contact Number',1);chan('fempty1','You have not Entered your Contact Number',1);return false;}
else if(document.getElementById('email').value==''){chan('fempty','You have not Entered your Email-ID',1);chan('fempty1','You have not Entered your Email-ID',1);return false;}
else if(document.getElementById('username').value==''){chan('fempty','You have not Entered your Login Username',1);chan('fempty1','You have not Entered your Login Username',1);return false;}
else if(document.getElementById('password').value==''||document.getElementById('conpass').value==''){chan('fempty','You have not Entered your Login Password',1);chan('fempty1','You have not Entered your Login Password',1);return false;}
else if(!(document.getElementById('password').value==document.getElementById('conpass').value)){document.getElementById('perror').style.display='block';return false;}
else if(document.getElementById('year').value==0){chan('fempty','Please select your current Academic year',1);chan('fempty1','Please select your current Academic year',1);return false;}
else if(document.getElementById('country').value==102&&document.getElementById('college').value=="other"&&document.getElementById('colalter').value==""){chan('fempty','Please specify the College Name',1);chan('fempty1','Please specify the College Name',1);return false;}
else if(document.getElementById('country').value==0){chan('fempty','Please select your country',1);chan('fempty1','Please select your country',1);return false;}
else if(document.getElementById('accomdate').value==1){if(document.getElementById('arr_time').value==0){chan('fempty','You have not Entered your arriving time',1);chan('fempty1','You have not Entered your arriving time',1);return false;}
else if(document.getElementById('dep_time').value==0){chan('fempty','You have not Entered your Departure time',1);chan('fempty1','You have not Entered your Departure time',1);return false;}}
else if(document.getElementById('goodtogo').value==0){return false;}
else if(document.getElementById('goodtogo1').value==0){return false;}
else
return true;}
function close_all(){document.getElementById('fempty').style.display='none'
document.getElementById('fempty1').style.display='none'
document.getElementById('eerror').style.display='none'
document.getElementById('uerror').style.display='none'
document.getElementById('perror').style.display='none'
document.getElementById('phperr1').style.display='none'}
function chan(id,txt,error){var cell=document.getElementById(id);if(cell.hasChildNodes())
{while(cell.childNodes.length>=1)
{cell.removeChild(cell.firstChild);}}
var a=document.createElement("img");switch(error){case 1:a.src="./img/wrong.png";a.alt="Error";break;case 2:a.src="./img/error_icon.png";a.alt="Error";break;case 3:a.src="./img/tick.png";a.alt="Available";break;case 4:a.src="img/loading.gif";a.alt="Loading";break;}
cell.appendChild(a);var c=document.createElement('strong');var b=document.createTextNode(" "+txt);c.appendChild(b);cell.appendChild(c);cell.style.display='block'}
function remove_text(){if(document.getElementById('othersource').value=='Optional Field'){document.getElementById('othersource').value='';}}
function validate_email(){var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;var address=document.getElementById('email').value;if(reg.test(address)==false){chan('eerror','You have Entered Invalid Email ID',1);}
else{createRequest();if(request==null)
alert("Error in Connection. Could not Validate. Please Re-Try");else{var url=urlbase+"username_avail.php";request.open("POST",url,true);request.onreadystatechange=email_existence;request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");request.send("email="+escape(address));}}}
function email_existence(){if(request.readyState==4&&request.status==200){document.getElementById('goodtogo1').value=0;var s=request.responseText;if(s==0){document.getElementById('goodtogo1').value=1;document.getElementById('eerror').style.display='none'}
if(s==5){document.getElementById('email').focus();chan('eerror','Account already exists with this Email-ID.',2);}}
else{chan('eerror','Validating Email-ID.',4);}}
function check_if_done(){if(count==7){}}
function getList(h){closediv();if(h==102){document.getElementById('1').style.display='block'
document.getElementById('one1').style.display='block'}
else if(h==0){alert("Select Country");}
else{document.getElementById('3').style.display='block'
document.getElementById('three3').style.display='block'}}
function closediv(){document.getElementById('1').style.display='none'
document.getElementById('one1').style.display='none'
document.getElementById('2').style.display='none'
document.getElementById('two2').style.display='none'
document.getElementById('3').style.display='none'
document.getElementById('three3').style.display='none'
document.getElementById("colalter").value="";}
function getListCol(h){if(h==0){alert('Select a state');}
else{createRequest();if(request==null)
alert("Error in Connection. Could not Validate. Please Re-Try");else{var url=urlbase+"collist.php";request.open("POST",url,true);request.onreadystatechange=printList;request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");request.send("id="+escape(h));}}}
function printList(){if(request.readyState==4&&request.status==200){document.getElementById('lding').style.display='none';var s=request.responseText;document.getElementById('2').style.display='block'
document.getElementById('two2').style.display='block'
var ele=document.getElementById('college');var i=0;if(ele.hasChildNodes()){var len=ele.options.length;for(i=0;i<len;i++){ele.remove(0);}}
var child=document.createElement("option");var b=s.split("|||||");i=0;while(b[i]!=""){var child=document.createElement("option");child.value=b[i];child.text=b[i];ele.options.add(child);i++;}
child=document.createElement("option");child.value="other";child.text="Other";ele.options.add(child);}
else{document.getElementById('lding').style.display='block';}}
function getText(h){if(h=="other"){document.getElementById('3').style.display='block'
document.getElementById('three3').style.display='block'
document.getElementById('four4').style.display='none'}
else{document.getElementById('3').style.display='none'
document.getElementById('three3').style.display='none'}
if(h!="National Institute of Technology Karnataka (NITK), Surathkal")
{document.getElementById('four4').style.display='block'}
else
{document.getElementById('four4').style.display='none'}}
function showOther(h){if(h=="other"){document.getElementById("4").style.display="block"}
else{document.getElementById("4").style.display="none"
document.getElementById("othersource").value="";}}
function getCheckVal(h){if(document.getElementById('accomodate').checked==true)
{document.getElementById('arr_date').selectedIndex=0;document.getElementById('five5').style.display='block';}
else
{document.getElementById('five5').style.display='none';document.getElementById('six6').style.display='none';}}
function getDepDate(h){if(h==0){alert('Select a date');}
else{var ele=document.getElementById('dep_date');var i=0;if(ele.hasChildNodes()){var len=ele.options.length;for(i=0;i<len;i++){ele.remove(0);}}
child=document.createElement("option");child.value="0";child.text="--Select Departure date--";ele.options.add(child);var y=parseInt(h,10);switch(y)
{case 29:var child=document.createElement("option");child.value="29";child.text="October 29";ele.options.add(child);case 30:var child=document.createElement("option");child.value="30";child.text="October 30";ele.options.add(child);case 31:var child=document.createElement("option");child.value="31";child.text="October 31";ele.options.add(child);case 1:var child=document.createElement("option");child.value="1";child.text="November 01";ele.options.add(child);}
document.getElementById('six6').style.display='block';}}