
function isEmpty(input) {
    return (input.value.length == 0);
}

function alertInputLength(name, input) {
    alert("Input "+name+" length="+input.value.length);
    return true;
}
function setStatus(msg) {
    window.status = msg;
}


function reqParam( name )
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
        return null;
    else
        return results[1];
}
   
// whitespace characters
var DEF_WHITESPACE = " \t\n\r";
   
function containsWhitespace(input) {
    var s = input.value;
    var i;
    // Search through string's characters one by one
    // until we find a whitespace character.
    // When we do, return true; if we don't, return false.

    for(i = 0; i < s.length; i++) {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if(DEF_WHITESPACE.indexOf(c) != -1) {
            return true;
        }
    }
    // All characters are whitespace.
    return false;
}
   
function isEmail(input) {   
    if(isEmpty(input)) {
        return false;
    }
    // is s whitespace?
    if(containsWhitespace(input)) {
        return false;
    }

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var s = input.value;
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@")) { 
        i++;
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) {
        return false;
    }else{
        i += 2;
    }

    // look for .
    while ((i < sLength) && (s.charAt(i) != ".")) { 
        i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) {
        return false;
    }else{
        return true;
    }
}   
   
/*
    var nav = new TNav();
    if(nav.isN4()) {
        debug.prn("debug is on");    
    }
    if(nav.isIE4()) {
    }
*/

function TNav() {
    this.isN4 = TNav_isN4;
    this.isIE4 = TNav_isIE4;
        
    if(TNav_isN4() && (typeof document.jstb == 'undefined')){
        document.jstb = new Object;
        document.jstb.ns4bugfix = new Object;
        document.jstb.ns4bugfix.startWidth = window.innerWidth;
        document.jstb.ns4bugfix.startHeight = window.innerHeight;
        window.onresize = ns4bugfix;
    }
        
}

function TNav_isN4() {
    if(document.layers) {
        // Navigator 4.0
        return true;
    }else{
        return false;
    }
}
function TNav_isIE4() {
    if(document.all) {
        // IE4
        return true;
    }else{
        return false;
    }
}

/******/

/* This section of code fixes a netscape resizing bug for DHTML pages.
If you use this code please leave these comments in place so that
others may benefit.  For use by anyone who needs it, this code
was created for by Glenn Davis of Project Cool, Inc. */

function ns4bugfix(){
    if (document.jstb.ns4bugfix.startWidth != window.innerWidth ||
        document.jstb.ns4bugfix.startHeight != window.innerHeight){
        document.location = document.location
    }
}
/*****/

/********* TDebug *************/


/*
    <script src="http://www.jutil.com/scripts/jsutil/jsutil.js" 
	language="JavaScript1.2"></script>


    var debug = new TDebug(true);
    if(debug.debug) {
        debug.prn("debug is on");    
    }
    debug.prn("debug is on");
    debug.prnln("debug is on");

	TPrintWriter writer = new TPrintWriter();
	writer.prn(":: ");
	writer.prnln("starting application...");
	writer.prnln(":: ");
	writer.prnln(":: ");
	writer.prnln(":: ");
	writer.prn(":: ");
	writer.prnln("closing application...");

*/
function TDebug(debug) {
    function prnMsg(msg) {
        if(debug) {
            dbuf.push(""+msg);
        }
    }
    function prnlnMsg(msg) {
        if(debug) {
            dbuf.push(msg+"\n");
        }
    }
    function flushBuff() {
        if(debug) {
            document.writeln("<b> START DEBUG MESSAGES </b><pre>");
            document.writeln(dbuf.join(""));
            document.writeln("</pre><b>END DEBUG MESSAGES </b>");
        }
        dbuf = [""];
    }
    this.prn = prnMsg;
    this.prnln = prnlnMsg;
    this.flush = flushBuff;
    var dbuf = [""];

}

/********* TDebug *************/


/********* TPrintWriter *************/
function TPrintWriter() {
    function prnMsg(msg){
        pbuf.push(""+msg);
    }
    function prnlnMsg(msg){
        pbuf.push(""+msg+"\n");
    }
    function flushBuff(){
        document.writeln(pbuf.join(""));
        pbuf = [""];
    }
    this.prn    = prnMsg;
    this.prnln  = prnlnMsg;
    this.flush  = flushBuff;
    var pbuf = [""];
}


function prn(msg){
    document.write(msg);
}

function prnln(msg){
    document.writeln(msg);
   
}
/********* TPrintWriter *************/



