

//////////////////////////////////////////////////////////////////////
//******************************************
// Functions Contained In This Utility: -dal/9/1
//******************************************
//function isDateString(datvar) 
//function charInString(c, s)
//function daysInFebruary(year)
//function isDate(year, month, day)
//function isDay(s)
//function isDigit(c)
//function isInteger(s)
//function isIntegerInRange(s, a, b)
//function isMonth(s)
//function isNonnegativeInteger(s)
//function isSignedInteger(s)
//function isYear(s)
//function lTrim(s)
//function makeArray(n)
//function rTrim(s)
//function trim(s)
//
//function isValidEmail(str) 
//
//////////////////////////////////////////////////////////////////
//	

function changeImages() 
{
	document[changeImages.arguments[0]].src = eval(changeImages.arguments[1] + ".src");
}

function newImage(arg) 
{
	
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function isDateString(datvar) 
{

	var theString = new String(datvar);
	var delimiterCharacter

	vIsValidDelimiter=0
	if ( theString.indexOf('/') > 0 )
	{
		delimiterCharacter = '/';
		vIsValidDelimiter=1;
	}
	if ( theString.indexOf('-') > 0 )
	{
		delimiterCharacter = '-';
		vIsValidDelimiter+=1;
	}
	if ( theString.indexOf(' ') > 0 )
	{
		delimiterCharacter = ' ';
		vIsValidDelimiter+=1;
	}

	if(vIsValidDelimiter != 1)
		return false;

// there must be three tokens
	var theTokens = theString.split(delimiterCharacter);
	if ( theTokens.length != 3 )
		return false;


// all of the tokens must be positive integers
	for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) 
	{
		if ( ! isNonnegativeInteger(theTokens[tokenIndex]) )
				return false;
	}

	return isDate(theTokens[0], theTokens[1], theTokens[2]);
}

////////////////////////////////////


	// most of the following was derived from Netscape's FormChek.js
	// library, which should be reviewed for documentation and comments

	var daysInMonth = makeArray(12);
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;

	var whitespace = " \t\n\r";

	function charInString(c, s) {
		for (i = 0; i < s.length; i++) {
			if (s.charAt(i) == c)
				return true;
	    }
	    return false
	}

	function daysInFebruary(year) {
	    return ( ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}

function isDate(month, day,year) 
{
	if ( ! ( isYear(year) && isMonth(month) && isDay(day) ) ) 
		return false;

	var intYear = parseInt(year);
	var intMonth = parseInt(month);
	var intDay = parseInt(day);

	if ( intDay > daysInMonth[intMonth] ) 
		return false; 

	if ( ( intMonth == 2 ) && ( intDay > daysInFebruary(intYear) ) ) 
		return false;

	return true;
}

	function isDay(s) {
	    return isIntegerInRange(s, 1, 31);
	}

	function isDigit(c) {
		return ( ( c >= "0" ) && ( c <= "9" ) )
	}

	function isInteger(s) {
		var i;
	    for ( i = 0; i < s.length; i++ )
	    {   
	        var c = s.charAt(i);
	        if ( ! (isDigit(c)) ) 
				if ( (i == 0) && (c != "-") )
					return false;
	    }
	    return true;
	}

	function isIntegerInRange(s, a, b) {

	    if ( ! isInteger(s) ) return false;
	    var num = parseInt (s);

	    return ( ( num >= a ) && ( num <= b ) );
	}

	function isMonth(s) {
	    return isIntegerInRange (s, 1, 12);
	}

	function isNonnegativeInteger(s) {
	    return ( isSignedInteger(s) && ( parseInt(s) >= 0 ) );
	}

	function isSignedInteger(s) {
	    var startPos = 0;
	    if ( ( s.charAt(0) == "-" ) || ( s.charAt(0) == "+" ) )
	       startPos = 1;    
	    return ( isInteger(s.substring(startPos, s.length)) )
	}

function isYear(s) 
{
	if ( ! isNonnegativeInteger(s) ) return false;
	    return ( (s.length == 1) || (s.length == 2) || (s.length == 4) );
}

	function lTrim(s) {
		var i = 0;
	    while ( (i < s.length) && charInString(s.charAt(i), whitespace) )
	       i++;
	    return s.substring(i, s.length);
	}

	function makeArray(n) {
	   for ( var i = 1; i <= n; i++ ) {
	      this[i] = 0
	   } 
	   return this
	}

	function rTrim(s) {
		var i = 0;
	    while ( (i < s.length) && charInString(s.charAt(i), whitespace) )
	       i++;
	    return s.substring(i, s.length);
	}

	function trim(s) {
		return lTrim(rTrim(s));
	}

/////////////////////////////////////////////////
//

function isValidEmail(str) 
{
	// are regular expressions supported?
	var supported = 0;
	if (window.RegExp) 
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	//	return (!r1.test(str) && r2.test(str));
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

   
function openAndCenterWindow(urlToOpenInNewWindow,w,h)
{

	var vjNeedToOpenNewWindow=1;  //default: open new window
	
	// Does the window exist, or has it previously been opened?
	if(window.vjPopupWindow)
	{
		// Having once been opened, is it now closed?
		if(vjPopupWindow.closed)
		{
			vjNeedToOpenNewWindow=1   // closed, so open again
		}
		else
		{
			vjNeedToOpenNewWindow=0   // still open so set focus instead of open again
		}
	}
	
	else
	{
		vjNeedToOpenNewWindow=1   // never opened, so open new
	}
	
	
	if(vjNeedToOpenNewWindow == 0)
	{
		vjPopupWindow.focus()
	}
	else
	{

	var myScreenWidth = screen.width;
	var myScreenHeight= screen.height;
	
	var puWindowWidth	= (6*myScreenWidth)/8;
	var puWindowHeight	= (8*myScreenHeight)/10;

	var puLeft	= myScreenWidth/8;
	var puTop	= myScreenHeight/10;
		
	vjPopupWindow = window.open(urlToOpenInNewWindow,"myPopUpWindow", "width=" + puWindowWidth + ",height=" + puWindowHeight + " screenX=" + puLeft + ",left=" + puLeft	+ ",screenY=" + puTop + ",top=" + puTop + ",scrollbars=Yes,resizable=Yes")
	
	}
}


	
function openAndCenterWindow_WithToolbars(urlToOpenInNewWindow,w,h)
{

	var vjNeedToOpenNewWindow=1;  //default: open new window
	
	// Does the window exist, or has it previously been opened?
	if(window.vjPopupWindow)
	{
		// Having once been opened, is it now closed?
		if(vjPopupWindow.closed)
		{
			vjNeedToOpenNewWindow=1   // closed, so open again
		}
		else
		{
			vjNeedToOpenNewWindow=0   // still open so set focus instead of open again
		}
	}
	
	else
	{
		vjNeedToOpenNewWindow=1   // never opened, so open new
	}
	
	
	if(vjNeedToOpenNewWindow == 0)
	{
		vjPopupWindow.focus()
	}
	else
	{

	var myScreenWidth = screen.width;
	var myScreenHeight= screen.height;
	
	var puWindowWidth	= (6*myScreenWidth)/8;
	var puWindowHeight	= (8*myScreenHeight)/10;

	var puLeft	= myScreenWidth/8;
	var puTop	= myScreenHeight/10;
		
	vjPopupWindow = window.open(urlToOpenInNewWindow,"myPopUpWindow", "width=" + puWindowWidth + ",height=" + puWindowHeight + " screenX=" + puLeft + ",left=" + puLeft	+ ",screenY=" + puTop + ",top=" + puTop + ",scrollbars=No,menubar=Yes,resizable=Yes")
	
	}
}


function changeOpac(opc, id) 
{ 

//window.status="opc-id: " + opc + " : " + id;
	var object = document.getElementById(id).style; 
	object.opacity = (opc / 100); 
	object.MozOpacity = (opc / 100); 
	object.KhtmlOpacity = (opc / 100); 
	object.filter = "alpha(opacity=" + opc + ")"; 
	
	//if(document.getElementById)
          //document.getElementById(curNav).style.visibility='visible';
	//else if(document.layers)
		//document.layers[curNav].visibility="show";
	//else if(document.all)
		//document.all(curNav).style.visibility="visible";
}
	