
    var goOnWnd;
    var shpWnd;

    function init()
    {
        try
        {
            var txtSHipmentAWB = GetCtrl('txtSHipmentAWB');
            if(IsValid(txtSHipmentAWB))
                HideButton('btnGetShpAWBReport', txtSHipmentAWB.value == "");
            HideButton('btnLogon', true);
            
            var txtPassword = GetCtrl('txtPassword');
            var txtUserName = GetCtrl('txtUserName');

            var referee = document.referrer;
            var pos = referee.search("TabularReport.aspx");
            if(txtUserName != null && txtUserName != "undefined" && pos == -1)
            {
                if(txtUserName.disabled == false)
                    txtUserName.focus();
                else 
                {
                    //var hddUP = document.getElementById('hddUP');
                    //if(hddUP != null && hddUP != undefined && hddUP.value != "")
                    //    txtPassword.value = hddUP.value;
                        
                    var btnJoin = GetCtrl('btnJoin');
                    if(btnJoin != null && btnJoin != undefined && btnJoin.disabled == false)
                        btnJoin.focus();
                }
            }
                
            if(txtSHipmentAWB != null && txtSHipmentAWB != "undefined" && txtSHipmentAWB.value != "")
                txtSHipmentAWB.focus();
            return true; 
        }
        catch(e){} 
    }
	function SearchUser_OnPaste()
	{
	    try
	    {
	        var txtUserName = GetCtrl('txtUserName');
            txtUserName.value = window.clipboardData.getData("Text");
            SearchUser_OnKeyUp();
        }
        catch(e){}
    }
	function closeSession_2(e)
    {
        try
        {
    	    var hddLastMouseEvt = GetCtrl('hddLastMouseEvt');
            if(hddLastMouseEvt.value == true || hddLastMouseEvt.value == 'true' || hddLastMouseEvt.value == '1' || IsClosingBrowser(e))
            {
                window.open("Shutdown.aspx");
                return false;
            }
        }
        catch(e){}
        return true;
    }
    //--->manage Shipment/ Package searching
    function OnClickShp()
    {
        try
        {
            var txtSHipmentAWB = GetCtrl('txtSHipmentAWB');
	        if(IsValid(txtSHipmentAWB))
                SearchShipment(txtSHipmentAWB.value);
            //window.focus();
            return false;
        }
        catch(e){}
    }    
    function EvalIfKnowsTheShipment()
    {
        try
        {
            shpWnd = window.open('LoginDispatcher.aspx?Nobo=1');
            //window.focus();
            return false;
        }
        catch(e){}
    }
    function SearchShipment(shpCode) 
    {
        try
        {
            var surl = "ShipmentOrPackageChecker.aspx?SID=" + shpCode;
	        $.post(surl, SearchShipmentCallback, "json");
	    }
	    catch(ex){}
    }
    function SearchShipmentCallback(data, txtStatus)
    {
        try
        {
            var edge = data.length;
            var theMesage = "";
            var msgStartIdx = data.indexOf("*");
            if(msgStartIdx != -1)
            {
                //didn't found a shipment/ package with the specified number
                theMesage = data.substring(msgStartIdx + 1, edge);
                var lblError = GetCtrl('lblError');
                if(IsValid(lblError))
                    lblError.innerHTML = theMesage;
                //window.opener = top;
                shpWnd.close();
                return false;
            }
            else     
            {       
                //otherwise, it found a shipment...
                var shpID = data;
                shpWnd.location.href = "../ReportingManager.UI/ShipmentDetailsView.aspx?SID=" + shpID;
                shpWnd.focus();
                return false;
            }
        }
        catch(ex){}
    }  
    //<---manage Shipment/ Package searching

    //--->manage logging into portal - from SmoothStart
    function EvalItMightGoFurther() 
    {
        try
        {
            goOnWnd = window.open('LoginDispatcher.aspx?Nobo=1');
            //goOnWnd.focus();
            return false;
        }
        catch (e) { }
    }
    function OnClickAgo(sDir)
    {
        try
        {
	        var txtPassword = GetCtrl('txtPassword');
	        var txtUserName = GetCtrl('txtUserName');
	        if(IsValid(txtPassword) && IsValid(txtUserName))
                EvalCredentials(txtUserName.value, txtPassword.value, sDir);
            return false;
        }
        catch(e){}
    }
    function EvalCredentials(uid, psw, sDir) 
    {
        try
        {
            var surl = "CredentialsChecker.aspx?UID=" + uid + "&PIS=" + psw + "&Dir=" + sDir;
	        $.post(surl, EvalCredentialsCallback, "json");
	    }
	    catch(ex){}
	}
	function EvalCredentialsCallback(data, txtStatus) 
	{
	    return GeneralEvalCredentialsCallback(data, txtStatus, true);
	}
    function OnJoinClick()
    {
        try
        {
	        var questJoin = GetCtrl('questJoin');
            if(IsValid(questJoin))
                questJoin.style.display = 'none'; 
            DisableCtrlByID('txtSHipmentAWB', false);
            DisableCtrlByID('txtUserName', false);
            DisableCtrlByID('txtPassword', false);
            OnClickAgo("3");        
            return true;
        }
        catch(ex){}
    }  
	//<---manage logging into portal - from SmoothStart
	function SayThereIsAPopupBlocker(wndObj) 
	{
	    if (wndObj == null || wndObj == undefined)
	        alert("There is a popup blocker for Consignor-portal website from EDI-Soft AS. Turn it off in order to continue.")
	    else
	        wndObj.focus();
	}   
