function isBlank( s )
{
	if(trim(s).length == 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//Trim
function ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}

function trim ( s )
{
	return rtrim(ltrim(s));
}


//email validate
function validateEmail(str)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	{
		return false;
	}
	return true;
}

function isDigit (c)
{
   return ((c >= "0") && (c <= "9"))
}

function isFloat (s)
{
    var decimalPointDelimiter = "."
    var i;
    var seenDecimalPoint = false;

    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isProper(string) {

   if (!string) return false;
   var iChars = "~!^&+=-*|,:<>[]{}`\';()@&$#%\".";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
} 

function getOSPlatform()	
{
	var agt=navigator.userAgent.toLowerCase();
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

	if(is_win == true)
	{
		if(is_win95 == true){return "win95"; return false;}
		if(is_win16 == true){return "win16"; return false;}
		if(is_win31 == true){return "win31"; return false;}
		if(is_winme == true){return "winme"; return false;}
		if(is_win2k == true){return "win2k"; return false;}
		if(is_win98 == true){return "win98"; return false;}
		if(is_winnt == true){return "winnt"; return false;}
		if(is_win32 == true){return "win32"; return false;}
	}
}

function selectdatabasevalue(toselect,cmb) //compares value not text
{
	for(i=0;i<eval(cmb).length;i++)
	{
		if(eval(cmb).options[i].value==toselect)
		{
			eval(cmb).selectedIndex = i;
		}
	}
}

function openExit(sPageUrl)
{
	if(window.screenLeft >= 10004)
 	{
		var nwindow = window.open(sPageUrl,'','width=800,height=270');
		nwindow.moveTo(screen.availWidth/2-400,screen.availHeight/2-135);
	}
}

