﻿function openWindow(location)
{
    mywindow = window.open (location, "mywindow","left=0, top=0, location=no, toolbar=no, menubar=no, status=no, scrollbars=yes, width=800, height=600, resizable=yes");    
    var w = (screen.availWidth||screen.width) * 0.9;
    var h = (screen.availHeight||screen.height) * 0.7;
    mywindow.moveTo(0,0);
    mywindow.resizeTo(w,h);
} 	

function openSmallWindow(location)
{
    mywindow = window.open (location, "mywindow","left=0, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes");
    var w = (screen.availWidth||screen.width) * 0.5;
    var h = (screen.availHeight||screen.height) * 0.7;
    mywindow.moveTo(0,0);
    mywindow.resizeTo(w,h);
} 	

function LoginButtonHandler(e)
{   
    // process only the Enter key
    if (e.keyCode == 13)
    {
        // cancel the default submit
        e.returnValue=false;
        e.cancel = true;
        // submit the form by programmatically clicking the specified button
        document.getElementById('ctl00_btnLogin').click();
    }
}

/* from http://www.webtoolkit.info/javascript-trim.html
This Javascript code trim implementation removes all leading and trailing occurrences of a set of characters specified. If no characters are specified it will trim whitespace characters from the beginning or end or both of the string.

Without the second parameter, Javascript function will trim these characters:

” ” (ASCII 32 (0×20)), an ordinary space. 
“\t” (ASCII 9 (0×09)), a tab. 
“\n” (ASCII 10 (0×0A)), a new line (line feed). 
“\r” (ASCII 13 (0×0D)), a carriage return. 
“\0″ (ASCII 0 (0×00)), the NUL-byte. 
“\x0B” (ASCII 11 (0×0B)), a vertical tab. 
*/

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
