var xmlHttpLogin


//xmlHttpLogin
function GetXmlHttpObject()
{
var xmlHttpLogin=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpLogin=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpLogin=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpLogin=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpLogin;
}



//xmlHttpLogin
function loginValidation()
{ 
xmlHttpLogin=GetXmlHttpObject();

if (xmlHttpLogin==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
document.getElementById("loginValidation").style.display = 'block';
var url="loginValidation.asp?username="+document.loginform.username.value;
url=url+"&password="+hex_sha256(document.loginform.password.value);
url=url+"&sid="+Math.random();
xmlHttpLogin.onreadystatechange=stateChanged1;
xmlHttpLogin.open("GET",url,true);
xmlHttpLogin.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpLogin.send(null);

}

function stateChanged1() 
{ 
	if (xmlHttpLogin.readyState==4)
	{ 

		window.parent.location = 'src/admin/admin.asp'

//		if (xmlHttpLogin.responseText == "Yes")
//		{
//			window.parent.location = 'src/others/others.asp'
//		}
//		else if (xmlHttpLogin.responseText == "Yes1")
//		{
//			window.parent.location = 'src/student/student.asp'
//		}
//		else if (xmlHttpLogin.responseText == "Yes2")
//		{
//			window.parent.location = 'src/teacher/teacher.asp'
//		}
//		else if (xmlHttpLogin.responseText == "Yes3")
//		{
//			window.parent.location = 'src/admin/admin.asp'
////			window.open('src/admin/admin.asp','Admin','width=document.body.offsetWidth,height=document.body.offsetHeight');
//		}
//		else if (xmlHttpLogin.responseText == "Yes4")	
//		{
//			window.parent.location = 'src/librarian/librarian.asp'
//		}
//
//		else if (xmlHttpLogin.responseText == "10")
//		{
//			alert('Access Denied');
//		}
//		else if (xmlHttpLogin.responseText == "11")
//		{
//			alert('User Expired');
//		}
//		else if (xmlHttpLogin.responseText == "Yes12")
//		{
//			//OTHERS ROLE
//			window.parent.location = 'src/others/others.asp'
//		}
//
//		else
//		{
//
//			document.getElementById("loginValidation").innerHTML=xmlHttpLogin.responseText;
//		}
	}
}


