﻿//RequestRegisterXMLHTTP("RequestType=Register&rmode=mobile&rvalue=" + mno,"Handlers/login.ashx"); 

function checklogin()
{
if (document.getElementById('txtUserName').value == '')
alert('Please enter the username!');
else if (document.getElementById('txtPassword').value == '')
alert('Please enter the password!');
else
Call();
}

function Call()
{
     var xmlHttp;
     var result;
      
      try
      {
        try
            {xmlHttp=new XMLHttpRequest();}
        catch (e)
            {
                try
                {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
                catch (e)
                {try
                    {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
                    catch (e)
                    { 
                        return false;      
                    }
                }  
            }
            
            document.getElementById("LoginTop").style.display='block';
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                document.getElementById("LoginTop").style.display='none';
                result = xmlHttp.responseText;
                //alert(result);
                if (result == '1')
                    window.location.href = 'Main.aspx';
                else if (result == 'admin')
                    window.location.href = 'admin.aspx';
                else
                    alert('Invalid username and password.');    
                xmlHttp=null;
            }
        }
    
        xmlHttp.open("POST","Handlers/login.ashx?U=" + document.getElementById('txtUserName').value + "&P=" + document.getElementById('txtPassword').value + "&Guid=" + new Date().getTime(),true);       
        xmlHttp.send(null);  
     
    }
    catch(e)
    {
        
    }
}