﻿// JScript File

    var ajax=new FrameWork.AJAX;
    var USER;
    var PASSWORD;
    var prefix="ctl00_ContentPlaceHolder_";
   
    ajax.OnLoading=fnAjaxLoading;
    ajax.OnComplete=fnAjaxComplete;
  
    function fnAjaxLoading(){
        
        document.getElementById('imgprogress').style.visibility='visible';
        document.getElementById(prefix+"lblErrorString").style.color="blue";
        document.getElementById(prefix+"lblErrorString").innerHTML="Logging in! Please wait...";
       }

    function fnAjaxCall(){
       
        USER=document.getElementById(prefix+"txtUserName").value;
        PASSWORD=document.getElementById(prefix+"txtPassword").value;
        if (USER=="" || PASSWORD==""){
           if (USER==""){
               alert("User name should not blank.");
               document.getElementById(prefix+"txtUserName").focus();
               return false;
               }
           else if(PASSWORD==""){
               alert("Password should not blank.");
               document.getElementById(prefix+"txtPassword").focus();
               return false;
               }
        }
        document.getElementById('btnSignIn').disabled=true;
        ajax.makeRequest("frmAjaxHandler.aspx?form=frmLogin&query=login&user="+USER+"&pass="+PASSWORD+"&q=");
        return false;
    }

    function fnAjaxComplete(response,xmltext){
        if (response=="Success"){
            window.location.href="./frmMenu.aspx";
            }
        else{
            document.getElementById('imgprogress').style.visibility='hidden';
            document.getElementById(prefix+"lblErrorString").innerHTML="";
            document.getElementById(prefix+"lblErrorString").style.color="red";
            document.getElementById(prefix+"lblErrorString").innerHTML=response;
            document.getElementById('btnSignIn').disabled=false;
            document.getElementById(prefix+"txtUserName").value="";
            document.getElementById(prefix+"txtPassword").value="";
            document.getElementById(prefix+"txtUserName").focus();
            }
        return false;
    }

