﻿    // Description:  This function prevents the enter key from submitting
    //               a form.  It can be applied to the form as a whole or
    //               a specific element in the form such as a textbox.
    //
    // Here is a C# example:
    // txtName.Attributes.Add("onKeyDown", "return DisableEnterKey(event);");
    //
    // http://www.w3schools.com/jsref/jsref_onkeydown.asp
    // http://www.bloggingdeveloper.com/post/Disable-Form-Submit-on-Enter-Key-Press.aspx
    function DisableEnterKey(e)
    {
        var keynum;
        
        // IE
        if (window.event)
        {
            keynum = e.keyCode;
        }
        // Firefox/Netscape/Opera
        else if (e.which)
        {
            keynum = e.which;
        }    
    
        // If the "Enter" key was pressed then
        // cancel the event.
        return (keynum != 13);
    }
    
    
    
    
    //_________________________________________________________________________________________________________________________
    // Description:  Opens a pop-up window.
    // Author:  John Hanold
    // Created:  3/20/2008.
    // Notes:
    //
    // url:  The url to be opened in the window.
    // name:  The unique name of the window.
    // width:  The width of the window.
    // height:  The height of the window.
    // toolbar:  Display the toolbar. 1 = yes, 0 = no.
    // menubar:  Display the menubar. 1 = yes, 0 = no.
    // resizalbe:  Allow the window to be resizable.  1 = yes, 0 = no.
    // scrollbars:  Display scrollbars.  1 = yes, 0 = no.
    // status:  Display the status bar.  1 = yes, 0 = no.
    // location: Display the location bar.  1 = yes, 0 = no.
    function PopUpWindow(url, name, width, height, toolbar, menubar, resizable, scrollbars, status, location)
    {
      var options = "top=5,left=5,width=" + width + ",height=" + height + 
                    ",toolbar=" + toolbar + ",menubar=" + menubar + ",resizable=" + resizable + 
                    ",scrollbars=" + scrollbars + ",status=" + status + ",location=" + location;

      newwindow = window.open(url, name, options);
      newwindow.focus();
    }

    //_________________________________________________________________________________________________________________________
    // Description: When the enter key is pressed, intercept and click the intended button.
    // Author:      John Reiner
    // Created:     10/20/2008
    function PressButtonOnEnter(buttonName) {
        if (!event) var event = window.event;
        try {
            if (event.keyCode == 13) {
                event.cancelBubble = true;
                event.returnValue = false;
                document.getElementById(buttonName).click();
            }
        } catch (e) { }
    }

