function trim(string)
{
	return string.replace(/(^\s*)|(\s*$)/g,'');
}

function Clear_History() 
{
	if (document.layers) 
	{
    	    var output = '';
    	    for (var i=0;i<window.history.length;i++);
    	    output += window.history[i] + '\n';
       	    alert(output);
       	}
}




function button1_onclick()
{
	var temp;
	if (document.LOGIN.empid.value == "")
	{
		alert("Enter Employee ID");
		document.LOGIN.empid.focus();
	}
	else
	{
		if (document.LOGIN.domainname.value=="")
		{
			alert("Enter Domain name");
			document.LOGIN.domainname.focus();
		}
		else
		{
			if(document.LOGIN.rolename.value=="") 
			{
				alert("Enter Role Name");
				document.LOGIN.rolename.focus();
			}
			else
			{
				if(trim(document.LOGIN.rolename.value.toUpperCase())=="FLEXI") 
				{
					alert("Flexi is locked !!! ");
					document.LOGIN.rolename.value=""
					document.LOGIN.domainname.value=""
					document.LOGIN.empid.value=""
					document.LOGIN.password.value=""
					return;
					document.LOGIN.rolename.focus();
					//document.LOGIN.action="http://10.2.0.174/PowerApps_flexi/login.aspx"


				//Added By Kunal 13-09-2006 @ LnT
				document.LOGIN.action="http://10.2.0.166/PowerApp_flexi/Login.aspx"								
					document.LOGIN.submit();
					return;
				}

				document.LOGIN.submit();
			}
		}
	}
}

function rolename_keypress()
{
	var temp;
	if (event.keyCode==13)
	{
		if (document.LOGIN.empid.value == "")
		{
			alert("Enter Employee ID");
			document.LOGIN.empid.focus();
		}
		else
		{
			if (document.LOGIN.domainname.value=="")
			{
				alert("Enter Domain name");
				document.LOGIN.domainname.focus();
			}
			else
			{
				if(document.LOGIN.rolename.value=="") 
				{
					alert("Enter Role Name");
					document.LOGIN.rolename.focus();
				}
				else
				{

					if(trim(document.LOGIN.rolename.value.toUpperCase())=="FLEXI") 
					{
					alert("Flexi is locked !!! ");
					document.LOGIN.rolename.value=""
					document.LOGIN.domainname.value=""
					document.LOGIN.empid.value=""
					document.LOGIN.password.value=""
					return;
					
						//alert("You can not login Self from this page");
						//document.LOGIN.rolename.focus();
						document.LOGIN.action="http://10.2.0.174/PowerApps_flexi/login.aspx"
						document.LOGIN.submit();
						return;
					}

					document.LOGIN.submit();
				}
			}
		}
	}
}

function id_keypress()
{
	if (event.keyCode==39)
	{
		 event.returnValue=false;
	}
	if (event.keyCode==13)
	{
	document.LOGIN.password.focus();
	}
}

function password_keypress()
{
	if (event.keyCode==39)
	{
		 event.returnValue=false;
	}
	if (event.keyCode==13)
	{
		document.LOGIN.domainname.focus();
	}
}

function domain_keypress()
{
	if(event.keyCode==13)
	document.LOGIN.rolename.focus();  
}

function button2_onclick()
{
	LOGIN.empid.value ="";
	LOGIN.password.value ="";
}

//function DisableRightMouseButton(e) 
//{
 // if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) 
 // {
 // 	return false;
 // }
 // else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) 
 // {
   // alert("Sorry, right-click feature disabled");
  //  return false;
 // }
 // return true;
//}
//document.onmousedown=DisableRightMouseButton;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//window.onmousedown=DisableRightMouseButton;



