// JavaScript Document
function loginajaxFunction()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	    document.getElementById("himage").style.display="none";
      	//document.myForm.time.value=xmlHttp.responseText;
		if(xmlHttp.responseText=='loggedon'){
			document.getElementById("loginerror").style.display="none";
			location.href='portfolio.php';
			//progress_update()
			document.loginform.reset();			
			
		}
		else if(xmlHttp.responseText=='Sorry try latter!')
		{
			document.getElementById("loginimg").style.display="none";
			document.getElementById("loginfailed").style.display="block";
			document.getElementById("loginerror").innerHTML="Your login attempts has expired. Please try again tomorrow!";
			document.loginform.user_id.disabled=true;
			document.loginform.password.disabled=true;
		}
		else
		{
			document.getElementById("loginerror").style.display="block";
			document.getElementById("loginerror").innerHTML=xmlHttp.responseText;	
			document.loginform.reset();

		}
      }
    }
	document.getElementById("himage").style.display="block";
	var user_id=document.loginform.user_id.value;
	var password=document.loginform.password.value;
	var url="./ajaxLogin.php?action=login&user_id="+user_id+"&password="+password;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }

function ajaxContact() {
var frmEl = document.getElementById('loginform');
addEvent(frmEl, 'submit', loginajaxFunction, false);
frmEl.onsubmit = function() { return false; }
}
addEvent(window, 'load',ajaxContact, false);