function SendData(str) { var strShowMessage = document.getElementById('ShowMessages'); var strfrmLogin = document.getElementById('LoginForm'); var strShowLoginProgressbar = document.getElementById('ShowLoginProgressbar'); var strLoginProgressbarImg = document.getElementById('LoginProgressbarImg'); var strLoginProgressbarMessage = document.getElementById('LoginProgressbarMessage'); //show message from ajax function ShowMessage(strMessage) { strShowMessage.style.display = 'inline'; strShowMessage.innerHTML = strMessage; } //show progress bar function ShowProgressBar(status) { if (status == true) { strfrmLogin.style.display = 'none'; strShowLoginProgressbar.style.display = 'inline'; strLoginProgressbarImg.style.display = 'inline'; strLoginProgressbarMessage.innerHTML = 'Please Wait'; strLoginProgressbarMessage.style.color="white"; } else { strfrmLogin.style.display = 'inline'; strShowLoginProgressbar.style.display = 'none'; strLoginProgressbarImg.style.display = 'none'; strLoginProgressbarMessage.innerHTML = ''; } } //Check fileds if (document.frmLogin.loginId.value == "" || document.frmLogin.loginPassword.value == "") { strShowMessage.style.display = 'inline'; strShowMessage.innerHTML = 'All fields requested to fill.'; return false; } //Clear error message if (strShowMessage.style.display=='inline') { strShowMessage.style.display = 'none'; } ShowProgressBar(true); SendGet('CheckUser.asp'); function SendGet(URL) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlHttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { switch (xmlHttp.responseText) { //Everything is OK: case "00" : frmLogin.style.display = 'none'; ShowProgressBar(false); strShowLoginProgressbar.style.display = 'inline'; strLoginProgressbarMessage.innerHTML = 'Authentication was passed, Please Wait'; strLoginProgressbarMessage.style.color="white"; alert("مجوز ورود به سیستم به صورت دائمی صادر شده\n لطفا پس از خاتمه ی کار حتما با استفاده از دکمه Logout از سیستم خارج شوید"); setTimeout("window.location.href='';", 200); break; //Incorrect username or password case "01" : ShowMessage('Incorrect ID or Password'); ShowProgressBar(false); break; //Error in db connection: case "04" : ShowMessage('The database is not available or an error occurred in connection process.'); ShowProgressBar(false); break; default : ShowMessage('System Error: ' + xmlHttp.status); ShowProgressBar(false); } } } xmlHttp.open("POST", URL,true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.setRequestHeader('encoding', 'windows-1256'); xmlHttp.send("loginid=" + document.all.loginId.value + "&loginpassword=" + document.all.loginPassword.value); } }