
/***************************************************/
/*  The following section checks the string values */
/***************************************************/
//this function goto a specifie window
function gotoInternalPage(path)
{
        window.location.href=path;
}


function isLetter (c)
{
        //don't allow blanks as well as letters
        return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}

function isInteger (s)
{
    var i;
    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return false;
       else return (isInteger.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }

    return true;
}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)

{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function isvalidEmailChar (s)
{   var i;

    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) || (c=='@') || (c=='.') || (c=='_') || (c=='-') || (c=='+')) ) {
                return false;
        }
    }

    return true;
}

function isEmail (s)
{

        if (isEmpty(s))
                if (isEmail.arguments.length == 1)
                        return false;
                else
                        return (isEmail.arguments[1] == true);


        if (isWhitespace(s))
                return false;

        if (!isvalidEmailChar(s))
                return false;

        var atOffset = s.lastIndexOf('@');


        if (atOffset < 1 ) {
                return false;
        } else {
                var dotOffset = s.indexOf('.', atOffset);

                if ( dotOffset < atOffset + 2 || dotOffset > s.length - 2 ) {
                        return false;
                }
        }


        return true;
}
