function Login()
{
	var txtusername=document.getElementById("username").value;
	var txtpassword=document.getElementById("password").value;
	var xmlhttp=false;
	
	if(txtusername=="")
	{
		document.getElementById('error_div').innerHTML = "<font color='#FF0000' font face='Arial' size='2'><b>Please enter username</b></font>";
		return false;
	}
	else if(txtpassword=="")
	{
		document.getElementById('error_div').innerHTML = "<font color='#FF0000' font face='Arial' size='2'><b>Please enter password</b></font>";
		return false;
	}
	else
	{
		//create browser specific objects
		browser=navigator.userAgent.toLowerCase();
		
		if(browser.indexOf("msie")!=-1)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			xmlhttp=new XMLHttpRequest();
		}
		document.getElementById('button_div').innerHTML = "<font color='#FF0000' font face='arial' size='2'><b>Please wait...</b></font>";
		loginurl="chk_distributor_login.php?username="+txtusername+"&password="+txtpassword;
		xmlhttp.open("GET",loginurl,true);
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4)
			{
				var result=xmlhttp.responseText;
				if(result=="authlogin")
				{
					window.status="";
					var frm=document.getElementById("frm_distributor_login"); 
					frm.submit();
				}
				else if (result=="invuname")
				{
					document.getElementById('error_div').innerHTML = "<font color='#FF0000' font face='arial' size='2'><b>Invalid username</b></font>";
					document.getElementById('button_div').innerHTML = "<img src='images/submit_button.jpg'  id='btn_login' onclick='Login();'>";
				}
				else if (result=="invpwd")
				{
					document.getElementById('error_div').innerHTML = "<font color='#FF0000' font face='arial' size='2'><b>Invalid password</b></font>";
					document.getElementById('button_div').innerHTML = "<img src='../images/submit_button.jpg'  id='btn_login' onclick='Login();'>";
				}
			}
			else
			{
				document.getElementById('button_div').innerHTML = "<font color='#FF0000' font face='arial' size='2'><b>Please wait...</b></font>";
			}
		} 
	}
}