var xmlHttp
function login(){ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert("Your browser does not support AJAX!")
  return
  } 
var email = document.getElementById('lemail').value
var pass = document.getElementById('lpass').value
var url="login.php"
var data="email="+encodeURIComponent(email)
data+="&pass="+encodeURIComponent(pass)
xmlHttp.open("POST",url,true)
xmlHttp.onreadystatechange=stateChanged
xmlHttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-Length", encodeURIComponent(data.length));
xmlHttp.send(data)

}
function login2(){ 
document.getElementById("txtHint").innerHTML='<label for="user">Email</label><input class="inputfld" type="text" name="lemail" id="lemail" /><label for="user">Password</label><input type="password" name="lpass" class="inputfld" id="lpass"/><p align="right"><a style="cursor:pointer" onclick="login()"><img src="img/signin.gif" width="83" height="44" /></a></p><p><a href="#">Forgot your password?</a></p>'
}
function logout()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert("Your browser does not support AJAX!")
  return
  } 
var url="logout.php"
var data="";
xmlHttp.open("POST",url,true)
xmlHttp.onreadystatechange=stateChanged
xmlHttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-Length", encodeURIComponent(data.length));
xmlHttp.send(data)
}
function submit(){
document.zona.submit()
}
function captcha_focus(){
document.zona.code.focus()
window.scrollBy(0,700)
}
function stateChanged() 
{ 
var ok=true
if (xmlHttp.readyState==4)
{ 
if(xmlHttp.responseText.indexOf("myprofile")>-1){
window.location="./myprofile"
ok=false
}
if(xmlHttp.responseText.indexOf("edit")>-1){

window.location="./friendbook/edit"
ok=false
}
if(xmlHttp.responseText.indexOf("show")>-1){
window.location="./friendbook/show"
ok=false
}
if(ok){
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
}

function submitform(e)
{
     var key

     if(window.event){
          key = window.event.keyCode  
		  }   //IE
     else{
          key = e.which     //firefox
}
     if(key == 13){
     login()
     }
         
}

function GetXmlHttpObject()
{
var xmlHttp=null
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest()
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
  }
return xmlHttp
}