/*
	$Workfile: $
	
	Copyright (c) 2001 - Quartz Imaging Corporation
	
	Purpose : General Purpose Javascript functionality
	
	$Archive: $
	$Author: $
	$Date: $
	$Revision: $
	
*/

//
// Sniff the browser
//
var g_ns4 = false;
var g_ns6 = false;
var g_ie4 = false;
var g_ie5 = false;
var g_op5 = false;
if (document.layers)				{g_ns4 = true;}
if (!document.all && document.getElementById)	{g_ns6 = true;}
if (document.all && !document.getElementById)	{g_ie4 = true;}			
if (document.all && document.getElementById)	{g_ie5 = true;}
if (window.opera && document.getElementById)	{g_op5 = true;}




// Track the mouse
var nCurrentX;
var nCurrentY;
if (document.layers)
{
	document.captureEvents( Event.MOUSEUP );
}
document.onmousemove = 
function (evt) 
{
	nCurrentX = document.layers ? evt.pageX : document.all ? event.x : evt.clientX;
	nCurrentY = document.layers ? evt.pageY : document.all ? event.y : evt.clientY;
	//window.status = x + ':' + y;
};




//
// Clear the right hand browse pane
//
function ClearBrowse()
{
	ReplaceBrowsePaneContents("../Welcome.asp")
}

function DefaultBrowse()
{
	ReplaceBrowsePaneContents("../DefaultBrowseContents.asp")
}


//
// Replace the contents of the browse pane with the passed in filename.
//
function ReplaceBrowsePaneContents(strPath)
{
	parent.browse.location.href = strPath;
	//top.browse.location.replace(strPath);
}


//
// Replace the contents of the query pane with the passed in filename.
//
function ReplaceQueryPaneContents(strPath)
{
	parent.query.location.replace(strPath);
}

function newWindow(file, window) 
{
	msgWindow=open(file,window,'width=400,height=600,top=50,left=600,resizable=yes,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,location=window');
	if (msgWindow.creator == null) 
		msgWindow.creator = self;
}

function newBrowseWindow(file, window) 
{
	msgWindow=open(file,window,'width=400,height=600,top=50,left=600,resizable=yes,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,location=window');
	if (msgWindow.creator == null) 
		msgWindow.creator = self;
}

function newCalendarWindow(strURL, TargetControl, ParentWindow) 
{
	//
	// These will be the width and height of the window.
	//
	var WIDTH 	= 280;
	//var HEIGHT 	= 350;
	var HEIGHT 	= 380;
	
	var x,y;
	x = nCurrentX;
	y = nCurrentY;


	// IE
	if (document.all)
	{
		x = window.screenLeft + event.x;
		y = window.screenTop + event.y;
	}
	// Netscape 4
	else if (document.layers)
	{
		// These lines are for Netscape
		if (x == undefined)
			x = screen.availWidth/2;
	
		if (y == undefined)
			y = screen.availHeight/2;
	
		//x = window.screenX + event.x;
		//y = window.screenY + event.y;
	}
	// Netscape 6
	else if (document.getElementById)
	{
		// These lines are for Netscape
		if (x == undefined)
			x = screen.availWidth/2;
	
		if (y == undefined)
			y = screen.availHeight/2;
	
      	//x = window.pageXOffset + event.clientX;
      	//y = window.pageYOffset + event.clientY;
	}
/*
	if ( (y+215) > screen.availHeight)
		y = y - 215;
	
	if ( (x+275) > screen.availWidth)
		x = x - 275;
*/

	if ( (y+HEIGHT) > screen.availHeight)
		y = y - HEIGHT;
	
	if ( (x+WIDTH) > screen.availWidth)
		x = x - WIDTH;
		
	var strParams = "width=" + WIDTH + ",height=" + HEIGHT + ",left=" + x + ",top=" + y + ",screenx=" + x + ",screeny=" + y + ",fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";

	// Tack on the width and height of the window
	strURL = strURL + "&W=" + WIDTH + "&H=" + HEIGHT;		
	
	// Open the window
	msgWindow = window.open(strURL, "cal_window", strParams);
	msgWindow.focus();

	if (msgWindow.creator == null) 
		msgWindow.creator = self;
}



function test(file)
{
  var opts = "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
  var x,y;

  elDateField = null;
  elDateField = item;

  x = window.screenLeft + event.x;
  y = window.screenTop + event.y;

  curDate = item.value;
  curMonth = null;
  curDay = null;
  curYear = null;
  
  if (!win)
  {
    win = window.open('cal.htm','DatePicker', opts);
    win.blur();
    window.focus();

    win.resizeTo(275,215);
    
    if ( (y+215) > screen.availHeight)
      y = y - 215;
    
    if ( (x+275) > screen.availWidth)
      x = x - 275;
    
    win.moveTo(x,y);
  }
  win.focus();
}







function openIT(windowtitle, theURL, W, H, wname) 
{
	   CLOSEdwn = "../Javascript/close_dwn.gif"
	   CLOSEup = "../Javascript/close_up.gif"
	   CLOSEovr = "../Javascript/close_ovr.gif"
	   MINIdwn = "../Javascript/mini_dwn.gif"
	   MINIup = "../Javascript/mini_up.gif"
	   MINIovr = "../Javascript/mini_ovr.gif"
	   NONEgrf = "../Javascript/none.gif"
	   CLOCKgrf = "../Javascript/clock.gif"
	   titHTML = windowtitle; //change to your desired window title
	   titWIN = "window title" //your desired status bar title
	   winBORDERCOLOR = "#000000" //change to your desired border color
	   winBORDERCOLORsel = "#DDDDDD" //change to your desired selected border color
	   winBGCOLOR = "#dddddd" //change to your desired top bar background color
	   winBGCOLORsel = "#cccccc" //change to your desired top bar selected background color
	   mywin = openchromeless(theURL, wname, W, H, NONEgrf, CLOSEdwn, CLOSEup, CLOSEovr, MINIdwn, MINIup, MINIovr, CLOCKgrf, titHTML, titWIN, winBORDERCOLOR, winBORDERCOLORsel, winBGCOLOR, winBGCOLORsel);
}
		


		
		
		


function isLeapYear(yr) 
{
	/* classic leap year calculation:
		if the year is:
		evenly divisible by 4 and not evenly divisible by 100
		or
		evenly divisible by 400
		then it is a leap year,
		Otherwise it is not a leap year
	*/
	
	if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) 
	{
		return true;
	} 
	else 
	{ 
		return false;
	} 
 }



// Private function used by IsValidDate()
function getNumberOfDaysInMonth(year, month) 
{
	var nDaysInMonth = 0;
	
	switch (month)
	{
		case 1:		// Jan
		case 3: 	// Mar
		case 5: 	// May
		case 7: 	// Jul
		case 8: 	// Aug
		case 10: 	// Oct
		case 12: 	// Dec
			nDaysInMonth = 31;
			break;
			
		case 2: 	// Feb
			if (isLeapYear(year) == true)
			{
				nDaysInMonth = 29;
			}
			else
			{
				nDaysInMonth = 28;
			}
			break;
			
		case 4: 	// Apr
		case 6: 	// Jun
		case 9: 	// Sept
		case 11: 	// Nov
			nDaysInMonth = 30;
			break;
		
		default:
			nDaysInMonth = 0;
			break
	}
	//alert("nDaysInMonth = " + nDaysInMonth);
	return nDaysInMonth;

	//var temp1 = new Date(year, month, 1);
	//alert(temp1);
	//var temp2 = temp1.getDate();
	//alert(temp2);
	//return temp2
	//return (new Date(year, month, 0).getDate());
}



function IsValidDate(datestring) 
{
	// Declare all of the variables
	var bStatus = true;
	var strDay, strMonth, strYear;
	var strHour, strMinute, strSecond;
	var strD, strM, strY, strH, strMn, strS;
	var strDate;

	// Convert the string into a date object	
	strDate = new Date(datestring);
	
	// Get the component parts
	
	// Date
	
	//
	// This function returns the day of the month
	// getDay() returns the day of the week (0-6).  This is not what we want!
	//
	strDay 		= strDate.getDate();  
	
	strMonth 	= strDate.getMonth();
	strYear 	= strDate.getYear();
	
	// Time
	strHour		= strDate.getHours();
	strMinute	= strDate.getMinutes();
	strSecond	= strDate.getSeconds();


	strD		= new String(strDay);
	strM		= new String(strMonth);
	strY		= new String(strYear);

	//var strTemp;
	//strTemp = "Day = " + strDay + "\nMonth = " + strMonth + "\nYear = " + strYear + "\nHour = " + strHour + "\nMinute = " + strMinute + "\nSecond = " + strSecond;
	//alert(strTemp);
	
	
	// Is the date being passed in of bad form?
	if (isNaN(strDate))
	{
		//alert("isNaN");
		bStatus = false
	}
	// If eny of the strings are empty then return false
	else if (!strD.length || !strM.length || !strY.length ) 
	{
		//alert("Empty String");
		bStatus = false;
	} 
	else 
	{
		var nYear, nMonth, nDay;
		
		nYear	= parseInt(strYear);
		//alert("nYear = " + nYear);
		
		// Months start at zero, so let's add one to it.
		nMonth	= parseInt(strMonth);
		nMonth+=1;
		
		nDay	= parseInt(strDay);

		
		//
		// Need to add 1900 to any year that is less than 2000
		// the getYear() function above cannot handle years < 1999 properly.
		//
		// Plus a couple of workarounds for crappy Netscape 4.7 and up.
		if (nYear <= 99 || document.layers)// || document.getElementById)
		{
			nYear = nYear + 1900;
		}		
		

		if (nYear<1950 || nYear>2050 || nYear==0 || nMonth==0 || nDay==0 ) 
		{
			//alert("bad year");
			bStatus = false;
		} 
		else 
		{
			if (nMonth>12 || nMonth<1)
			{
				//alert("bad month");
				bStatus = false;
			} 
			else 
			{
				if (nDay<1 || nDay>getNumberOfDaysInMonth(nYear, nMonth)) 
				{
					//alert("bad day");
					bStatus = false;
				}
			}
		}
	}

	return bStatus;
}



//
// Makes the year two digits instead of four.
// Interpci.dll calls require this.
//
function ReformatDate(strAppLanguage, datestring)
{

	// 
	// We will assume that the actual format of the date is OK at
	// this point.
	// IsValidDate() should have been called previously to this.
	//
	
	// Declare all of the variables
	var strDay, strMonth, strYear;
	var strHour, strMinute, strSecond;
	var strD, strM, strY, strH, strMn, strS;
	var strDate;
	var strReturn;
	
	// Set this to a default value.
	strReturn = datestring;
	

	// Convert the string into a date object	
	strDate = new Date(datestring);
	//alert("strDate = " + strDate);
	
	// Get the component parts
	
	// Date
	strDay 		= strDate.getDate();
	
	// getMonth() returns 0 throught 11, so we have to add one to it!
	strMonth 	= strDate.getMonth();
	strMonth += 1;
	
	strYear 	= strDate.getYear();

	
	// Time
	strHour		= strDate.getHours();
	strMinute	= strDate.getMinutes();
	strSecond	= strDate.getSeconds();

	//alert("strHour = " + strHour + "   strMinute = " + strMinute + "   strSecond = " + strSecond);
	
	
	var nYear, nMonth, nDay
	nYear	= parseInt(strYear);
	nMonth	= parseInt(strMonth);
	nDay	= parseInt(strDay);

	var nHour, nMinute, nSecond
	nHour	= parseInt(strHour);
	nMinute = parseInt(strMinute);
	nSecond = parseInt(strSecond);
	
	//alert("nHour = " + nHour + "   nMinute = " + nMinute + "   nSecond = " + nSecond);
	
	
	//
	// Need to add 1900 to any year that is less than 2000
	// the getYear() function above cannot handle years < 1999 properly.
	//
	if (nYear >= 2000)
	{
		//
		// We need to truncate the first two digits
		//
		var nLen;
		var strYearTemp1, strYearTemp2;
		strYearTemp1 = new String(nYear);
		nLen = strYearTemp1.length;
		
		if (nLen == 4)
		{
			// We have a four digit year, so let's get the last two digits.
			strYearTemp2 = strYearTemp1.substring(2);
			
			// Now Pad all of the values with zeros.
			// so instead of 3/5/01 we get 03/05/01
			strMonth = DatePad(strMonth);
			strDay = DatePad(strDay);
			
			if (strAppLanguage == "ENGLISH" || strAppLanguage == "")
			{
				strReturn = strMonth + "/" + strDay + "/" + strYearTemp2;
			}
			else if (strAppLanguage == "JAPANESE")
			{
				strReturn = strYearTemp2 + "/" + strMonth + "/" + strDay;
			}
			
			if (!isNaN(nHour))
			{
				strReturn += " " + DatePad(strHour);
				
				if (!isNaN(nMinute))
				{
					strReturn += ":" + DatePad(strMinute);
					
					if (!isNaN(nSecond))
					{
						strReturn += ":" + DatePad(strSecond);
					}
				}
			}
			//alert(strReturn);
		}
		
	}		
	
	return strReturn;
}


function DatePad(nVal)
{
	var strReturn;
	strReturn = nVal;
	
	if (nVal <= 9)
	{
		strReturn = "0" + nVal;
	}
	return strReturn;
}







/*
	This function will compare two dates to
	see if the first falls before the second.
*/
function ValidDateRange(date1, date2)
{
	var bStatus = true;

	// Convert to dates first	
	var d1 = Date.parse(date1);
	var d2 = Date.parse(date2);

	// If both fields are not empty
	if (d1 != "" && d2 != "") 
	{
		// If falls after date to then
		// return an error
		if (d1 > d2) 
		{
		  bStatus = false;
		}
	}

	return bStatus;
}



function Is() 
{
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	
	//
	// Netscape
	//
	this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 3));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major >= 4));
	
	//
	// IE
	//
	this.ie   = (agent.indexOf("msie") != -1);
	this.ie3  = (this.ie && (this.major == 2));
	this.ie4  = (this.ie && (this.major >= 4));

	//
	// Opera	
	//
	this.op3 = (agent.indexOf("opera") != -1);
}





var g_colorBackgroundCurrent, g_colorTextCurrent;
function Highlight(element, bOnOff)
{
	if (bOnOff == 1)
	{
		// Save the current colors
		g_colorBackgroundCurrent  		= element.style.backgroundColor;
		g_colorTextCurrent      		= element.style.color;
		
		// Assign the new colors
		element.style.backgroundColor 	= "#cccccc";
		element.style.color				= "#000000";
	}
	else
	{
		element.style.backgroundColor 	= g_colorBackgroundCurrent;
		element.style.color 			= g_colorTextCurrent;
	}
}


var g_colorBackgroundCurrent, g_colorTextCurrent;
function Highlight(element, bOnOff)
{
	if (bOnOff == 1)
	{	
		// Save the current colors
		g_colorBackgroundCurrent  		= element.style.backgroundColor;
		g_colorTextCurrent      		= element.style.color;
		
		// Assign the new colors
		element.style.backgroundColor 	= "#cccccc";
		element.style.color				= "#000000";
	}
	else
	{
		element.style.backgroundColor 	= g_colorBackgroundCurrent;
		element.style.color 			= g_colorTextCurrent;
	}
}


function GetScreenWidth()
{
	var nWidth = 0;

	if (self.screen) 
	{     
		// for NN4 and IE4
        nWidth = screen.width;
	}
	
	return nWidth;
}


function GetScreenHeight()
{
	var nHeight = 0;
	
	if (self.screen) 
	{     
		// for NN4 and IE4
        nHeight = screen.height;
	}
	
	return nHeight;
}


function CreateWindowCenteringParameters(nDesiredWidth, nDesiredHeight)
{
	var strParams;
	
	// Get the dimensions of the screen
	var nScreenWidth, nScreenHeight;
	nScreenWidth = GetScreenWidth();
	nScreenHeight = GetScreenHeight();
	
	// Set the desired window width and height
	var nWindowWidth = nDesiredWidth;
	var nWindowHeight = nDesiredHeight;
	
	// Now calculate the x and y starting points!
	var nLocationX = (nScreenWidth - nWindowWidth)/2;
	var nLocationY = (nScreenHeight - nWindowHeight)/2;
	
	strParams = "width=" + nWindowWidth + ",height=" + nWindowHeight + ",left=" + nLocationX + ",top=" + nLocationY + ",screenx=" + nLocationX + ",screeny=" + nLocationY;
	
	return strParams;
}
		
var g_PleaseWaitPopupWindow;		




function OpenCenteredWindow(nDesiredWidth, nDesiredHeight, strURL, strWindowName)
{
	var strParams;
	
	// Get the starting X and Y coordinates of the new window, based
	// on the desired width and height passed in.
	strParams = CreateWindowCenteringParameters(nDesiredWidth, nDesiredHeight);
	
	// Add on the other parameters
	strParams += ",toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes";

	// Display the window
	var win;
	win = window.open(strURL, strWindowName, strParams);
	
	return win;
}


function OpenCenteredWindow_ShowScrollbars(nDesiredWidth, nDesiredHeight, strURL, strWindowName)
{
	var strParams;
	
	// Get the starting X and Y coordinates of the new window, based
	// on the desired width and height passed in.
	strParams = CreateWindowCenteringParameters(nDesiredWidth, nDesiredHeight);
	
	// Add on the other parameters
	strParams += ",toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";

	// Display the window
	var win;
	win = window.open(strURL, strWindowName, strParams);
	
	return win;
}


function ShowHelp(strTopic)
{
	// Build the URL and display the window
	var strURL = "../Utility/Help.asp?id="+strTopic;
	var win = OpenCenteredWindow(800, 600, strURL, "help_window");
}

function BrowserWarning(strBrowserType)
{
	alert("Reference Number : 4\n\nThis application works best with Internet Explorer Version 5.0 and greater or Netscape Version 6.0 or greater.\n\nYou appear to be using '" + strBrowserType +"'.\n\nSome functionality will not work correctly with this browser.\nQuartz Imaging is in the process of upgrading the application to better support your browser.");
}



function DisplayBrowsePopup(nWidth, nHeight, strTargetFrameName, strTargetFormName, strTargetFormFieldName, strTableName, strTableFieldName, strDescription)
{
	var nWindowWidth  = nWidth;
	var nWindowHeight = nHeight;
	
	// Build the URL
	var strURL = "../Utility/Browse.asp?TargetFrameName=" + escape(strTargetFrameName) + "&FrmName=" + escape(strTargetFormName) + "&InputName=" + escape(strTargetFormFieldName) + "&TableName=" + escape(strTableName) + "&FieldName=" + escape(strTableFieldName) + "&FieldDesc=" + escape(strDescription) + "&SQLStart=0&ReplaceContent=1&PopupWindow=1";
	
	var x,y;
	x = nCurrentX;
	y = nCurrentY;


	// IE
	if (document.all)
	{
		x = window.screenLeft + event.x;
		y = window.screenTop + event.y;
	}
	// Netscape 4
	else if (document.layers)
	{
		// These lines are for Netscape
		if (x == undefined)
			x = screen.availWidth/2;
	
		if (y == undefined)
			y = screen.availHeight/2;
	
		//x = window.screenX + event.x;
		//y = window.screenY + event.y;
	}
	// Netscape 6
	else if (document.getElementById)
	{
		// These lines are for Netscape
		if (x == undefined)
			x = screen.availWidth/2;
	
		if (y == undefined)
			y = screen.availHeight/2;
	
      	//x = window.pageXOffset + event.clientX;
      	//y = window.pageYOffset + event.clientY;
	}

	x = screen.availWidth - nWindowWidth - 20;
	y = 5;
	
	
	/*
	if ( (y+215) > screen.availHeight)
		y = y - 215;
	
	if ( (x+275) > screen.availWidth)
		x = x - 275;
	*/

	msgWindow = window.open(strURL, "browse_window", "width=" + nWidth + ",height=" + nHeight + ",left=" + x + ",top=" + y + ",screenx=" + x + ",screeny=" + y + ",fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	msgWindow.focus();

    //msgWindow.resizeTo(280, 340);

	//if ( (y+215) > screen.availHeight)
	//	y = y - 215;
	
	//if ( (x+275) > screen.availWidth)
	//	x = x - 275;
    
   	//msgWindow.moveTo(x,y);
	
	if (msgWindow.creator == null) 
		msgWindow.creator = self;
}




function BrowseSecurityPopup(nWidth, nHeight, strTargetFrameName, strTargetFormName, strTargetACNFieldName, strTargetTemplateFieldName)
{
	var nWindowWidth  = nWidth;
	var nWindowHeight = nHeight;
	
	// Build the URL
	var strURL = "/Utility/BrowseSecPopup.asp?TargetFrameName=" + escape(strTargetFrameName) + "&FrmName=" + escape(strTargetFormName) + "&ACN_InputName=" + escape(strTargetACNFieldName) + "&Template_InputName=" + escape(strTargetTemplateFieldName) + "&SQLStart=0&ReplaceContent=1&PopupWindow=1";
	
	
	var x,y;
	x = screen.availWidth - nWindowWidth - 20;
	y = 5;
	
	
	msgWindow = window.open(strURL, "security_window", "width=" + nWidth + ",height=" + nHeight + ",left=" + x + ",top=" + y + ",screenx=" + x + ",screeny=" + y + ",fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	msgWindow.focus();

	if (msgWindow.creator == null) 
		msgWindow.creator = self;
}




function GetByteLength(s) 
{
    var r = 0;
    for (var i = 0; i < s.length; i++) 
	{
        var c = s.charCodeAt(i);
        // Shift_JIS: 0x0 ~ 0x80, 0xa0  , 0xa1   ~ 0xdf  , 0xfd   ~ 0xff
        // Unicode  : 0x0 ~ 0x80, 0xf8f0, 0xff61 ~ 0xff9f, 0xf8f1 ~ 0xf8f3
        if ( (c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) 
		{
            r += 1;
        } 
		else 
		{
            r += 2;
        }
    }
    return r;
}




function GetCookie(name)
{
	if (document.cookie=="") 
	{
		return null;
	}
	
	var n=name+"=";
	var start=document.cookie.indexOf(n);
	if (start==-1) 
	{
		return null;
	}
	
	start += n.length;
	var sub=document.cookie.substring(start);
	var end=sub.indexOf(";");
	if (end==-1) 
	{
		return sub;
	}
	else 
	{
		return sub.substring(0,end);
	}
}


function IsValidIPAddressFormat(ipaddr) 
{
	var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	if (re.test(ipaddr)) 
	{
		var parts = ipaddr.split(".");
		if (parseInt(parseFloat(parts[0])) == 0) { return false; }
		for (var i=0; i<parts.length; i++) 
		{
			if (parseInt(parseFloat(parts[i])) > 255) { return false; }
		}
		return true;
	} 
	else 
	{
		return false;
	}
}

//function IsValidEmailAddressFormat(strEmail)
//{
//   return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
//}

function Validate_String(string, return_invalid_chars)
{
	valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	invalid_chars = '';

	if(string == null || string == '')
		return(true);

	//For every character on the string.   
	for(index = 0; index < string.length; index++)
	{
		char = string.substr(index, 1);                        

		//Is it a valid character?
		if(valid_chars.indexOf(char) == -1)
		{
			//If not, is it already on the list of invalid characters?
			if(invalid_chars.indexOf(char) == -1)
			{
				//If it's not, add it.
				if(invalid_chars == '')
					invalid_chars += char;
				else
					invalid_chars += ', ' + char;
			}
		}
	}                     

	//If the string does not contain invalid characters, the function will return true.
	//If it does, it will either return false or a list of the invalid characters used
	//in the string, depending on the value of the second parameter.
	if (return_invalid_chars == true && invalid_chars != '')
	{
		last_comma = invalid_chars.lastIndexOf(',');

		if(last_comma != -1)
			invalid_chars = invalid_chars.substr(0, $last_comma) + 
			' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);

		return(invalid_chars);
	}
	else
		return(invalid_chars == ''); 
}


function IsValidEmailAddressFormat(email_address)
{
	//Assumes that valid email addresses consist of user_name@domain.tld
	at = email_address.indexOf('@');
	dot = email_address.indexOf('.');

	//if(at == -1 || dot == -1 || dot <= at + 1 ||dot == 0 || dot == email_address.length - 1)
	//	return(false);

	if(at == -1 || dot == -1 || dot == 0 || dot == email_address.length - 1)
	{
		//alert("HERE");
		return(false);
	}

	user_name = email_address.substr(0, at);
	domain_name = email_address.substr(at + 1, email_address.length);                  

	if(Validate_String(user_name) === false || Validate_String(domain_name) === false)
		return(false);                     
		
	return(true);
}



//
// showObject - Show or Hide a page element.
//
function showObject(aDiv, bState)
{
	var el;

	if (g_ns4)
	{
		el = document.layers[aDiv];
		el.visibility = bState ? 'show' : 'hide';
	}
	else if (g_ie4)
	{
		el = document.all[aDiv];
		el.style.visibility = bState ? 'visible' : 'hidden';
	}
	
	else if (g_ie5 || g_ns6 || g_op5) // IE5+, NS6+, Mozilla/Gecko, and any W3C DOM compliant browser
	{
		el = document.getElementById(aDiv);
		el.style.visibility = bState ? 'visible' : 'hidden';
	}
}


function IsValidPassword(strPW1, strPW2, nMinLength, nMaxLength)
{
	var aInvalidCharacters = "<>/\\";
	
	var strMsg = "";
	var nLenPW1 = strPW1.length;
	var nLenPW2 = strPW2.length;
	if (nLenPW1 < nMinLength || nLenPW1 > nMaxLength)
		strMsg = strMsg + "Invalid password length.\nPassword must be between " + nMinLength + " and " + nMaxLength + " characters in length.\n";
	if (strPW1 != strPW2)
		strMsg = strMsg + "Passwords do not match\n";

	if (nLenPW1 > 0 && nLenPW2 > 0)
	{
		if (IsValidPasswordCharacters(strPW1) == false || IsValidPasswordCharacters(strPW2) == false)
			strMsg = strMsg + "Passwords contain invalid characters.  Illegal characters are as follows: " + BadPasswordCharacterList() + "\n";
	}
		
	return (strMsg);
}

var g_BadPasswordCharacters = "<>/\\\"&%$#@'?,";
function BadPasswordCharacterList()
{
	var strReturn = "";
	var theChar = "";
	var nLen = g_BadPasswordCharacters.length;
	
	for (var i = 0; i < nLen; i++) 
	{ 
		theChar = g_BadPasswordCharacters.substring(i, i+1);
		strReturn += " " + theChar;
	}
	return(strReturn);
}

function IsValidPasswordCharacters(strText) 
{
	var badchars = g_BadPasswordCharacters;
	var bValid = true;
	var CharToTest = "";
	for (var i = 0; i < strText.length; i++) 
	{ 
		CharToTest = strText.substring(i, i+1);
		if (g_BadPasswordCharacters.indexOf(CharToTest) != "-1") 
		{
			bValid = false;
		}
	} 
	
	return (bValid);
} 


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

// EOF
		

