﻿<!--

// GOOGLE ANALYTICS CODE - - - - - - - - - -  -

    var gaJsHost = (("https:" == document.location.protocol) ?
    "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost +
    "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

    function sgTracking(client) {
        var pageTracker = _gat._getTracker("UA-1391620-5");
        pageTracker._initData();
        pageTracker._trackPageview();
        pageTracker._setVar(client);
        }

// WARN BEFORE NAVIGATING AWAY - - - - - - - - - - - 
    var needToConfirm = false;
    window.onbeforeunload = confirmExit;
    function confirmExit()  {
    if (needToConfirm) {
        needToConfirm = false;
        return "If you have made any changes to your application without \nclicking the Save button, your changes will be lost. \n\nAre you sure you want to exit this page? \n\nClick CANCEL below to return to your application.";
        }
  }

// CLIENT SIDE REDIRECT - - - - - - - - - -  -
    function js_redirect(url) {
        window.location.href=url;
    }

// BACK BUTTON DISABLER - - - - - - - - - -  -

    // Disable the back button - works if JS enabled on browser. Needs to be registered for 
    // those pages that do not tolerate use of back button.
    function js_noBackButtonsAllowed() {
        //window.history.forward(1);
    }
    
// BUTTON HANDLERS - - - - - - - - - -  -

    // Generic close button handler
	function js_close() {
	    window.close();
	}

	// Confirm deletion Button handler
	function js_confirmDelete() {
		// Ask for confirmation and return false if not given
		var msg = "Are you sure you wish to delete this account? \nClick CANCEL to retain the account.";
		if (confirm(msg)) {
			window.close();
		}
	}

	// Close popup and refresh the parent all in one go
    function refreshParent(buttonID) {

        try {
            // Resubmit the parent form using the specified button's clientID (assigned by ASP.NET when form is rendered)
            window.opener.document.getElementById(buttonID).click(); // This executes a click;
        } 
        catch(ex){
            // Parent window must have been closed - just carry on
        }

        // Close the popup
        window.close();
        
        // NOTE: Some other possibilities:
        //window.opener.document.forms[0].submit();  //--> This forces a postback to the server
        //window.opener.reload  //--> This reloads the form from the server
    }

    // Generic close button handler - with confirmation message
	function js_confirm_close() {
		// Ask for confirmation and return false if not given
		var msg = "Are you sure you wish to close this form? Any information you have entered will be lost.";
		if (confirm(msg)) {
			window.close();
		}
	}

	// Generic Cancel Button handler
	function js_cancel() {
		// Ask for confirmation and return false if not given
		var msg = "Are you sure you wish to cancel your application?";
		if (confirm(msg)) {
			window.close();
		}
	}

	// For null tabs
    function unloadFunction() {
        // Used to stop tab buttons causing a postback

        return false
    }

	// Print current form
	function js_Print() {
	    window.print()
	}

    // Popup
    function js_popup(url) {
	    window.open(url ,"","scrollbars=1, resizable=1, height=750, width=750, left=50, top=50")
    }


// UTILITIES - - - - - - - - - -  -

    // Function - reset scroll position to top of page
    function resetScrollPosition(y) {
    // This Javascript routines allows the scroll position to be reset to the 
    // top of the page when the server requests it. 
    //
    // Reference:
    // http://www.thescripts.com/forum/thread601271.html
    //
    //
    // Registered this routine in an event handler to ensure that scroll position restoration 
    // is switched off for the very next postback. Register using: 
    //    Page.ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), Page.ClientID, "resetScrollPosition();", True)
    //

        // Read the scroll position recorded by MaintainScrollPositionOnPostBack 
        var scrollX = document.getElementById('__SCROLLPOSITIONX');
        var scrollY = document.getElementById('__SCROLLPOSITIONY');

        // If they are set, reset them to zero - when the scroll position is 
        // restored later in the page lifecycle, it will be restored to 
        // x = zero and y = zero. 
        if(scrollX != null && scrollY != null)
        {
            scrollX.value = 0;
            scrollY.value = y;
        }
    }

-->