function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

// Login
function login_user(username, password,type, URL){
	var validationSuccess = 1;
	if(username != '' & password != ''){
		var xmlhttp = GetXmlHttpObject();
		// clear div contents
		document.getElementById('nav').innerHTML = 'processing...';		
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				var mystr=xmlhttp.responseText;
				if(mystr.replace(/^\s+|\s+$/g,"")=="1"){
					window.location.href=URL;
				}
				else
				{
				var validationSuccess = 0;	
				document.getElementById('contentSection').style.display = 'block';
				document.getElementById('nav').style.display = 'block';
				document.getElementById('nav').innerHTML = xmlhttp.responseText;
				}
			}
		}
	}
	else
	{
		var validationSuccess = 0;
		document.getElementById('contentSection').style.display = 'block';
		document.getElementById('nav').style.display = 'block';
		document.getElementById('nav').innerHTML = 'Please enter a login name and password.';
	}
	
	if (validationSuccess == 1) {
		// set form field value
		var params = "username="+username+"&password="+password+"&type="+type;
		xmlhttp.open("POST","/process/login.cfm",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
		xmlhttp.send(params);
	}
}
