//Login scripts

function login() {
if ((document.BIPLlogin.txtUsername.value != "") && (document.BIPLlogin.txtPassword.value != "")) {
	var BIPLlogin_xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
BIPLlogin_xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
BIPLlogin_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
BIPLlogin_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
    BIPLlogin_xmlHttp.onreadystatechange=function() {
      if (BIPLlogin_xmlHttp.readyState==4) {
if (BIPLlogin_xmlHttp.responseText != "") {
	if (BIPLlogin_xmlHttp.responseText == "1") {
	document.BIPLlogin.submit();
	}
else {
	alert("Login credentials do not match - invalid user");
	};
}
};};
	BIPLlogin_C = "ajax/login/BIPLlogin.asp";
    BIPLlogin_xmlHttp.open("POST",BIPLlogin_C,true);
	BIPLlogin_xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
    BIPLlogin_xmlHttp.send("txtUsername=" + document.BIPLlogin.txtUsername.value + "&txtPassword=" + document.BIPLlogin.txtPassword.value);	
}
else {
	alert("Please enter both Username and Password\nto access login verification.");
};
}

function logout() {
	var BIPLlogout_xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
BIPLlogout_xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
BIPLlogout_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
BIPLlogout_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
    BIPLlogout_xmlHttp.onreadystatechange=function() {
      if (BIPLlogout_xmlHttp.readyState==4) {
if (BIPLlogout_xmlHttp.responseText != "") {
	document.BIPLlogin.submit();
}
};};
	BIPLlogout_C = "ajax/login/BIPLlogout.asp";
    BIPLlogout_xmlHttp.open("POST",BIPLlogout_C,true);
	BIPLlogout_xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
    BIPLlogout_xmlHttp.send();	
}

function showLogin() {
	document.getElementById("loginpanel").style.display = '';
	document.getElementById("login_c").innerHTML = "<table with='150px' cellpadding='2' cellspacing='0' border='0'><tr><td class='vsmall_white'>Username:</td><td><input name='txtUsername' type='text' value='' size='10' maxlength='10' class='filters' id='UN'  /></td></tr><tr><td class='vsmall_white'>Password:</td><td><input name='txtPassword' type='password' value='' size='10' maxlength='10' class='filters'  /></td></tr><tr><td>&nbsp;</td><td align='right'><input name='cmdLogin' type='button' value='Login' class='filters'  onclick='login();' /></td></tr></table>";
	document.getElementById("UN").focus();
}

document.getElementById("loginpanel").style.display = 'none';

document.onclick=check; 
function check(e){
	if (document.getElementById('loginpanel').style.display == '') {
var target = (e && e.target) || (event && event.srcElement); 
var obj = document.getElementById('loginpanel'); 

var parent = checkParentL(target); 
if(parent){
obj.style.display='none';
}
}

}

function checkParentL(t){ 
while(t.parentNode){ 
if((t==document.getElementById('loginpanel')) || (t==document.getElementById('LoginLink'))){ 
return false 
} 
t=t.parentNode 
} 
return true 
} 
