// Unpublished Work. ©Financial Industry Regulatory Authority, Inc.
/******************************************************************************
* Function: 
*  JSetAndSub
* 
* Purpose:
*  This function will save 2 form variables before submiting the page.  it is
*      used to pass in query parameters to the VB Com layer instead of using the
*			 querystring attribute of the request object.
*
******************************************************************************/
		function JSetAndSub(val1, val2, val3, val4)
		{
			document.Content.action = val1;
			document.Content.ORG_PK.value = val2;
			document.Content.STATE_CD.value = val3;
			if (val4 == undefined) val4 = "N";
			if (val4 == "Y") {
			    document.Content.target = "_blank";}
			    else {
			        document.Content.target = "";
			    }
		    			document.Content.submit()
		    
        }

        function JSub(val1) {
            var url;
            var bkLocation = val1.indexOf('#')
            if (bkLocation == -1) 
                url = val1 + "?ORG_PK=" + getQueryVariable("ORG_PK") + '&RGLTR_PK=' + getQueryVariable("RGLTR_PK") + "&STATE_CD=" + getQueryVariable("STATE_CD") + "&FLNG_PK=" + getQueryVariable("FLNG_PK");
             else
                 url = val1.substr(0, bkLocation) + "?ORG_PK=" + getQueryVariable("ORG_PK") + '&RGLTR_PK=' + getQueryVariable("RGLTR_PK") + "&STATE_CD=" + getQueryVariable("STATE_CD") + "&FLNG_PK=" + getQueryVariable("FLNG_PK") + val1.substr(bkLocation);
             window.location.href = url;
        }

        function JNav(val1) {
            window.location.href = val1;
        }
 function JSubNew(val1) {
    document.Content.target = "_blank";
    document.Content.action = val1;
    document.Content.submit();
}


/******************************************************************************
* Function: 
*  AutoSubmitOnTextBox
* 
* Purpose:
*  This function will verify the correct submit button got clicked when user press enter instead of Go button
******************************************************************************/

function AutoSubmitOnTextBox(ctlSubmitBtnID, e) {
		   
		    var ctlSubmitBtnName;

		    var key;
		     {
		         if (window.event)
		            key = window.event.keyCode;     //IE
		        else
		            key = e.which;     //firefox
		    }
		    if (key == 13) {
		        //Get the button the user wants to have clicked
		        ctlSubmitBtnName = document.getElementById(ctlSubmitBtnID).name ;
		        if (ctlSubmitBtnName != null) { //If we find the button click it
		            document.getElementById(ctlSubmitBtnID).click();
		            event.keyCode = 0
		        }
		    }
		}
		
/******************************************************************************
* Function: 
*  JNavigate
* 
* Purpose:
*  This function will verify the page is done loading before navigation is
*  allowed.*
******************************************************************************/
function JNavigate(strHref)
{

	// If the page is not done loading, just set the window to the new location
	if (bDoneLoading == "N")
	{
		window.location = strHref; 
		return;
	}
	
		window.location = strHref;
}

function jRedirectSearch(url, orgpk) {
    window.location.href = url + "?ORG_PK=" + orgpk;
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}

//SCR#: 37205 - Start
function JOpenPrintAllPagesWindow(sHREF) {
    // This function is used to calculate the number of minutes to generate
    // view all pages information.
    var sQS = "";
    if (document.forms.Content != null)
         sQS = document.forms.Content.elements["PrtVwAllPages"].value;
    if (sQS == "" || sQS == "/") {
        sQS = '?ORG_PK=' + getQueryVariable("ORG_PK") + '&RGLTR_PK=' + getQueryVariable("RGLTR_PK") + '&STATE_CD=' + getQueryVariable("STATE_CD") + '&FLNG_PK=' + getQueryVariable("FLNG_PK")  + '&Print=Y';
    }
    var sURL = sHREF + sQS;
    window.open(sURL, 'Print', 'toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars,resizable,width=640,height=600,top=0,left=0');
    return;
}
//SCR#: 37205 - End 
