﻿
function pageLoad()
{
    if($get('ctl00_Login1_PasswordTextBox')!=null)
    {
        $addHandler($get('ctl00_Login1_PasswordTextBox'), 'keydown', PasswordTextBox_KeyDown);
    }
    if($get('ctl00_Login_Popup1_PasswordTextBox')!=null)
    {
        $addHandler($get('ctl00_Login_Popup1_PasswordTextBox'), 'keydown', PasswordTextBox_KeyDown);
    }
}


function PasswordTextBox_KeyDown(evt){
       
  // Check to see if it's the enter key that raised
  //  the keydown event.
    if (evt.keyCode == Sys.UI.Key.enter)
    {

        if (document.getElementById('ctl00_Login_Popup1_BodyPanel').style.display == 'none')
        {
            
            var ua = navigator.userAgent.toLowerCase();
            if ( ua.indexOf( "msie" ) != -1 )
            {
               __doPostBack('ctl00$Login1$LoginButton','');
            }
            else if ( ua.indexOf( "mozilla" ) != -1 )
            {
                if ( ua.indexOf( "firefox" ) != -1 )
                {
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
                }
                else{
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);           
                }
            } 
        }
        else if (document.getElementById('ctl00_Login_Popup1_BodyPanel').style.display == 'block')
        {
            var ua = navigator.userAgent.toLowerCase();
            if ( ua.indexOf( "msie" ) != -1 )
            {
                __doPostBack('ctl00$Login_Popup1$LoginButton','');
            }    
            else if ( ua.indexOf( "mozilla" ) != -1 )
            {
                if ( ua.indexOf( "firefox" ) != -1 )
                {
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest1);
                }
                else
                {
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest1);
                }
            }    
        }
    }
}

function EndRequest()
{
    __doPostBack('ctl00$Login1$LoginButton','');
}
function EndRequest1()
{
    __doPostBack('ctl00$Login_Popup1$LoginButton','');
}


  
//Sys.Application.add_init(OnEnter);

//document.getElementById('body').onkeydown= function(e){OnEnter(e);};
//function OnEnter(e)
//{   
//    var e=window.event? event : e
//    if(e.which || e.keyCode)
//    {
//        if ((e.which == 13) || (e.keyCode == 13))
//        {
//            if (document.getElementById('ctl00_Login_Popup1_BodyPanel').style.display == 'none')
//            {
//                var ua = navigator.userAgent.toLowerCase();
//                if ( ua.indexOf( "msie" ) != -1 )
//                {
//                    __doPostBack('ctl00$Login1$LoginButton','');
//                }
//                else if ( ua.indexOf( "mozilla" ) != -1 )
//                {
//                    if ( ua.indexOf( "firefox" ) != -1 )
//                    {
//                        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);

//                    }
//                    else
//                    {
//                         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);

//                    }
//                } 
//            }
//            else if (document.getElementById('ctl00_Login_Popup1_BodyPanel').style.display == 'block')
//            {
//                var ua = navigator.userAgent.toLowerCase();
//                if ( ua.indexOf( "msie" ) != -1 )
//                {
//                    __doPostBack('ctl00$Login_Popup1$LoginButton','');
//                }    
//                else if ( ua.indexOf( "mozilla" ) != -1 )
//                {
//                    if ( ua.indexOf( "firefox" ) != -1 )
//                    {
//                        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest1);
//                    }
//                    else
//                    {
//                         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest1);
//                    }
//                }    
//                
//            }    
//        }
//        else
//            return true;
//    }
//}

//function EndRequest()
//{
//    __doPostBack('ctl00$Login1$LoginButton','');
//}
//function EndRequest1()
//{
//    __doPostBack('ctl00$Login_Popup1$LoginButton','');
//}