function showLogin () { 
  document.getElementById('LoginPos').style.color='#FFF8AF';
  document.getElementById('LoginPos').style.background='#3E4095';
  document.getElementById('LoginPos').style.borderBottomRightRadius ='0px';  
  document.getElementById('LoginPos').style.MozBorderRadiusBottomright ='0px';  
  document.getElementById('LoginPos').style.webkitBorderBottomRightRadius ='0px';  
  document.getElementById('LoginPos').style.borderBottomLeftRadius ='0px';  
  document.getElementById('LoginPos').style.MozBorderRadiusBottomleft ='0px';  
  document.getElementById('LoginPos').style.webkitBorderBottomLeftRadius ='0px';  				
  document.getElementById('LoginBox').style.top=document.getElementById('LoginPos').offsetTop+30+'px';
  document.getElementById('LoginBox').style.left=(document.getElementById('LoginPos').offsetLeft-190)+'px';
  document.getElementById('LoginBox').style.visibility = 'visible';
  }
  
function hideLogin () {	
  document.getElementById('LoginPos').style.background='#FFF8AF';
  document.getElementById('LoginPos').style.color='#3E4095';
  document.getElementById('LoginPos').style.borderBottomRightRadius ='10px';  
  document.getElementById('LoginPos').style.MozBorderRadiusBottomright ='10px';  
  document.getElementById('LoginPos').style.webkitBorderBottomRightRadius ='10px';  
  document.getElementById('LoginPos').style.borderBottomLeftRadius ='10px';  
  document.getElementById('LoginPos').style.MozBorderRadiusBottomleft ='10px';  
  document.getElementById('LoginPos').style.webkitBorderBottomLeftRadius ='10px';  
  document.getElementById('LoginBox').style.visibility = 'hidden';
  } 
  
function setUsername() { if (document.getElementById('loginusername').value=="Username") { document.getElementById('loginusername').value=""; } }
function setPassword() { if (document.getElementById('loginpassword').value=="Password") { document.getElementById('loginpassword').value=""; } }

function confirmUser(user, pass) {
  if (user.length==0) { alert("Username may not be blank!"); return; }
  if (window.XMLHttpRequest)  { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) { 
	  document.getElementById("headerRight").innerHTML=xmlhttp.responseText;
	  if(xmlhttp.responseText.indexOf("Invalid username / password!")>0) { 
		document.getElementById('LoginBox').style.top=document.getElementById('LoginPos').offsetTop+30+'px';
		document.getElementById('LoginBox').style.left=(document.getElementById('LoginPos').offsetLeft-190)+'px';
		document.getElementById('loginusername').value=user;
		document.getElementById('LoginPos').style.color='#FFF8AF';
		document.getElementById('LoginPos').style.background='#3E4095';
		document.getElementById('LoginPos').style.borderBottomRightRadius ='0px';  
		document.getElementById('LoginPos').style.MozBorderRadiusBottomright ='0px';  
		document.getElementById('LoginPos').style.webkitBorderBottomRightRadius ='0px';  
		document.getElementById('LoginPos').style.borderBottomLeftRadius ='0px';  
		document.getElementById('LoginPos').style.MozBorderRadiusBottomleft ='0px';  
		document.getElementById('LoginPos').style.webkitBorderBottomLeftRadius ='0px'; 
	    document.getElementById('LoginBox').style.visibility = 'visible';
		document.getElementById('loginpassword').focus();
		}
	  }
    }
  xmlhttp.open("GET","../users/chklogin.php?q="+user+"&r="+pass,true);
  xmlhttp.send();
  }

function logoutUser() {
  if (window.XMLHttpRequest)  { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("headerRight").innerHTML=xmlhttp.responseText; }
    }
  xmlhttp.open("GET","../users/logout.php",true);
  xmlhttp.send();
}
