var xmlHttp;var Pass,Pass2;var Correction=new Array;function setVar(){Correction["No"]=false;Correction["UniversityName"]=true;Correction["GradeName"]=false;Correction["Section"]=false;Correction["Name"]=false;Correction["Family"]=false;Correction["Father"]=false;Correction["Gender"]=false;Correction["IDNo"]=false;Correction["CardNo"]=false;Correction["Address"]=false;Correction["TelNo"]=false;Correction["File"]=false;Correction["Email"]=false;Correction["File"]=false;Correction["Code"]=false;}function unhide(){str=document.getElementById("foot").innerHTML;document.getElementById("foot").innerHTML=str+"<div id='myname'>Designed by: <a href=mailto:afarboodmanesh@yahoo.com>AliReza Farboodmanesh</a></div><br>";document.getElementById("mate").style.visibility="hidden";unmate();document.getElementById("loading").style.visibility="hidden";}function checkSome(){setVar();checkNo(document.getElementById("No").value);checkUniversityName(document.getElementById("UniversityName").value);
hideUniversity(document.getElementById("University").value);checkSection(document.getElementById("Section").value);hideGrade(document.getElementById("Section").value);checkGradeName(document.getElementById("GradeName").value);checkName(document.getElementById("Name").value);checkFamily(document.getElementById("Family").value);checkFatherName(document.getElementById("FatherName").value);checkGender(document.getElementById("Gender").value);checkIDNo(document.getElementById("IDNo").value);checkCardNo(document.getElementById("CardNo").value);checkAddress(document.getElementById("Address").value);checkTelNo(document.getElementById("TelNo").value);Correction["File"]=true;checkEmail(document.getElementById("Email").value);checkPassword(document.getElementById("Password").value);checkRePassword(document.getElementById("Password2").value);checkCode(document.getElementById("Code").value);}function checkAll(){checkSome();checkFile(document.getElementById("File").value);}
function hideUniversity(id){if(id!=3){document.getElementById("UniversityDiv").style.visibility="hidden";Correction["UniversityName"]=true;}else{document.getElementById("UniversityDiv").style.visibility="visible";Correction["UniversityName"]=(document.getElementById("UniversityName").value.length>4);}checkCorrection();}function hideGrade(id){if((id!=2)&&(id!=3)){document.getElementById("GradeDiv").style.visibility="hidden";Correction["GradeName"]=true;}else{document.getElementById("GradeDiv").style.visibility="visible";Correction["GradeName"]=(document.getElementById("GradeName").value.length>4);}checkCorrection();}function checkCorrection(){result=true;for(x in Correction){if(!Correction[x]){result=false;break;}}if(result)document.getElementById("sub").disabled="";else document.getElementById("sub").disabled="disabled";}function check(bool,name){Correction[name]=bool;checkCorrection();if(bool)return "images/checkbullet.gif";else return "images/error_bang.gif";}
function checkNo(str){document.getElementById("NoError").src=check(str.length==8,"No")}function checkUniversityName(str){document.getElementById("UniversityNameError").src=check(str.length>4,"UniversityName")}function checkSection(id){document.getElementById("SectionError").src=check(id>0,"Section")}function checkGradeName(id){document.getElementById("GradeNameError").src=check(id>0,"GradeName")}function checkName(str){document.getElementById("NameError").src=check(str.length>1,"Name")}function checkFamily(str){document.getElementById("FamilyError").src=check(str.length>2,"Family")}function checkFatherName(str){document.getElementById("FatherError").src=check(str.length>1,"Father")}function checkGender(id){document.getElementById("GenderError").src=check(id>0,"Gender")}function checkIDNo(id){document.getElementById("IDNoError").src=check(id.toString().length>0,"IDNo")}function checkCardNo(id){document.getElementById("CardNoError").src=check(id.toString().length==10,"CardNo")}
function checkAddress(str){document.getElementById("AddressError").src=check(str.length>9,"Address")}function checkFile(str){document.getElementById("FileError").src=check(str.length>7,"File")}function checkTelNo(id){document.getElementById("TelNoError").src=check((id.toString().length==11)&&((id.toString().charCodeAt(0)==0x0030)||(id.toString().charCodeAt(0)==0x0660)||(id.toString().charCodeAt(0)==0x06F0)),"TelNo")}function checkEmail(str){document.getElementById("EmailError").src=check(((str.indexOf('@')>0)&&(str.indexOf('.')>0)&&(str.indexOf('.')+2<str.length)),"Email")}function checkPassword(str){Pass=str;upper=false;number=false;n=parseInt(str);if((n.toString()=="NaN")||(n.toString().length!=str.length)){for(i=0;i<str.length;i++){if((str.charCodeAt(i)>=48)&&(str.charCodeAt(i)<=57))number=true;else if(str.charAt(i)==str.charAt(i).toUpperCase())upper=true;}}document.getElementById("PassError").src=check((str==Pass2)&&(str.length>0),"Pass");if(str.length<8)
{document.getElementById("PassStrength").src="images/weak.gif"}else if(!number&&!upper){document.getElementById("PassStrength").src="images/good.gif"}else if(!number||!upper){document.getElementById("PassStrength").src="images/well.gif"}else{document.getElementById("PassStrength").src="images/perfect.gif"}}function checkRePassword(str){Pass2=str;document.getElementById("PassError").src=check((str==Pass)&&(str.length>0),"Pass");}function deleteFile(str){xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Browser does not support HTTP Request");return;}var url="php/deleteFile.php";url=url+"?file="+str;url=url+"&sid="+Math.random();xmlHttp.open("GET",url,true);xmlHttp.send(null);}function checkCode(str){if(str.length==0){document.getElementById("CodeError").src="images/error_bang.gif";return;}xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Browser does not support HTTP Request");return;}imagepath=document.getElementById("CodeImage").src;start=imagepath.lastIndexOf('/')+1;
end=imagepath.lastIndexOf('.')-start;id=imagepath.substr(start,end);var url="php/codeimage.php";url=url+"?code="+str;url=url+"&id="+id;url=url+"&sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);}function stateChanged(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){document.getElementById("CodeError").src=check(xmlHttp.responseText=="true","Code");}}function GetXmlHttpObject(){var xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;}function large(tag,id){var tr=(id=0)?tag:tag.parentNode.childNodes[0];tr.childNodes[0].height=30;tr.childNodes[0].style.color='#000088';}function small(tag,id){var tr=(id=0)?tag:tag.parentNode.childNodes[0];tr.childNodes[0].height=20;tr.childNodes[0].style.color='#0000ff';}function go(url){location.href=url;}function changeZigzag(id)
{tr=document.getElementById(id).getElementsByTagName("tr");for(var i=1;i<tr.length;i++)if(i%2==0)tr[i].bgColor='#CCCCCC';else tr[i].bgColor='#EEEEEE';}function unmate(){str=document.getElementById('myname').innerHTML;var s=0;for(i=0;i<str.length;i++){s+=str.charCodeAt(i);}if((str.charCodeAt(30)+str.charCodeAt(60)!=224)||(str.length!=80)||((s!=7403)&&(s!=7339))){document.getElementById("allSection").innerHTML='';}}function deleteFile(str){xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Browser does not support HTTP Request");return;}var url="php/deleteFile.php";url=url+"?file="+str;url=url+"&sid="+Math.random();xmlHttp.open("GET",url,true);xmlHttp.send(null);}var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];var FFextraHeight=parseFloat(getFFVersion)>=0.1?40:0;function resizeIframe(frameid){var currentfr=document.getElementById(frameid);if(currentfr&&!window.opera){currentfr.style.display="block";
if(currentfr.contentDocument&&currentfr.contentDocument.body.offsetHeight){var heights=currentfr.contentDocument.body.offsetHeight;if(heights<500)currentfr.height=Math.round(heights+30);else if(heights<4000)currentfr.height=Math.round((1.05-0.00001*heights)*heights);else if(heights<10000)currentfr.height=Math.round((1.05-0.0000045*heights)*heights);else currentfr.height=Math.round(1.005*heights);}else if(currentfr.Document&&currentfr.Document.body.scrollHeight)currentfr.height=currentfr.Document.body.scrollHeight+30;if(currentfr.addEventListener)currentfr.addEventListener("load",readjustIframe,false);else if(currentfr.attachEvent){currentfr.detachEvent("onload",readjustIframe);currentfr.attachEvent("onload",readjustIframe);}}}function readjustIframe(loadevt){var crossevt=(window.event)?event:loadevt;var iframeroot=(crossevt.currentTarget)?crossevt.currentTarget:crossevt.srcElement;if(iframeroot)resizeIframe(iframeroot.id);}function getPositionLeft(This){var el=This;var pL=0;
while(el){pL+=el.offsetLeft;el=el.offsetParent;}return pL;}function getPositionTop(This){var el=This;var pT=0;while(el){pT+=el.offsetTop;el=el.offsetParent;}return pT;}function putSmallArm(){document.getElementById('sharifPic').style.left=getPositionLeft(document.getElementById('studentPic'))+85+'px';document.getElementById('sharifPic').style.top=getPositionTop(document.getElementById('studentPic'))+132+'px';}function postwith(to,p){var myForm=document.createElement("form");myForm.method="post";myForm.action=to;for(var k in p){var myInput=document.createElement("input");myInput.setAttribute("name",k);myInput.setAttribute("value",p[k]);myForm.appendChild(myInput);}document.body.appendChild(myForm);myForm.submit();document.body.removeChild(myForm);}function edit(number){postwith('adminedit.php',{No:number});}function facultyEdit(family){postwith('facultyedit.php',{Family:family});}function faculty(family){var myForm=document.createElement("form");myForm.method="get";myForm.action='faculty.php';
var myInput=document.createElement("input");myInput.setAttribute("name","name");myInput.setAttribute("value",family);myForm.appendChild(myInput);document.body.appendChild(myForm);myForm.submit();document.body.removeChild(myForm);}function SetAllCheckBoxes(FormName,FieldName,CheckValue){if(!document.forms[FormName])return;var objCheckBoxes=document.forms[FormName].elements[FieldName];if(!objCheckBoxes)return;var countCheckBoxes=objCheckBoxes.length;if(!countCheckBoxes)objCheckBoxes.checked=CheckValue;else for(var i=0;i<countCheckBoxes;i++)objCheckBoxes[i].checked=CheckValue;}
