
/*
	Utils.js (c) 2001 by Locke Enterprises - All rights reserved.
	Purpose:  Export m¥ utility routines.
	Created: 10/10/2001 - Nathan
	Modification History:
		· 11/26/2002 - Nathan - added the focusOn() and focusOff() for use with input boxes
		· mm/dd/yyyy - [name] - [comment]
*/


//
//	Changes the font style of the specified object.
//
function changeFont( theObject, theClass ) {

	if( theClass==1 ) {
		theObject.style.color = theObject.style.color=="#F00000" ? "#00F000" : "#F00000";
	} else if( theClass==2 ) {
		theObject.style.color = theObject.style.color=="#F00000" ? "#00F000" : "#F00000";
	} else {
		theObject.style.color = theObject.style.color=="#F00000" ? "#00F000" : "#F00000";
	}

} // changeFont()


//
//	Pops up a new window that is plain from content at the specified location.
//
function openNewNormalWindow( url ) {

	/*
	try {
		if(MM_popup_window1 != null && !MM_popup_window1.closed) MM_popup_window1.close();
	} catch( E ) {
		// nothing -- just ignore any error
	}*/
	try {
		//MM_popup_window1 = window.open( url, "MM_popup_window1", "titlebar=no,resizable=yes,status=no,toolbar=no,location=no,menu=no,scrollbars=yes,height=450,width=540,alwaysRaised=yes");
		MM_popup_window1 = window.open( url, "MM_popup_window1", "");
		MM_popup_window1.focus();
	} catch( E ) {
		if( confirm("Popup error. Click OK to redirect main window to the followinf URL:\n"+url+"\nOr click Cancel to abort.") ) {
			window.location = url;
		}
	}

} // openNewNormalWindow()


//
//	Pops up a new window that is plain from content at the specified location.
//
function openNewPlainWindow( url ) {

	try {
		if(MM_popup_window2 != null && !MM_popup_window2.closed) MM_popup_window2.close();
	} catch( E ) {
		// nothing -- just ignore any error
	}
	try {
		MM_popup_window2 = window.open( url, "MM_popup_window2", "titlebar=no,resizable=yes,status=no,toolbar=no,location=no,menu=no,scrollbars=yes,height=450,width=540,alwaysRaised=yes");
	} catch( E ) {
		if( confirm("Popup error. Click OK to redirect main window to the followinf URL:\n"+url+"\nOr click Cancel to abort.") ) {
			window.location = url;
		}
	}

} // openNewPlainWindow()

//
//	Pops up a new window that is plain from content at the specified location.
//
function openBigWindow( url ) {

	MM_popup_window3 = window.open( url, "MM_popup_window3", "titlebar=no,resizable=yes,status=no,toolbar=no,location=no,menu=no,scrollbars=yes" );
	MM_popup_window3.moveTo( 0, 0 );
	MM_popup_window3.resizeTo( screen.availWidth, screen.availHeight );

} // openBigWindow()


//
//	Crappy function from the public domain.
//
function openAnyWindow(url, name) {

	var l = openAnyWindow.arguments.length;
	var w = "";
	var h = "";
	var features = "";

	for (i=2; i<l; i++) {
		var param = openAnyWindow.arguments[i];
		if ( (parseInt(param) == 0) || (isNaN(parseInt(param))) ) {
			features += param + ',';
		} else {
			(w == "") ? w = "width=" + param + "," : h = "height=" + param;
		}
	}

	features += w + h;
	var code = "popupWin = window.open(url, name";
	if( l > 2 )
		code += ", '" + features;
	code += "');\n"
	//code += name+".focus();";
	eval(code);

} // openAnyWindow()


//
//	Erases the default text in an input box.
//	Note: should be used with code like: onFocus="focusOn(this,'email address')" onBlur="focusOff(this,'email address')"
//
function focusOn( theElement, theString ) {

	if( theElement.value == theString ) {
		theElement.value = "";
	}

}


//
//	Puts default text into an input box when its empty.
//
function focusOff( theElement, theString ) {

	if( theElement.value == "" ) {
		theElement.value = theString;
	}

}


// ****************************
// Block backspace onKeyDown************
// ***************************
/*
function onKeyDown() {
	if(
		(event.altKey) ||
		((event.keyCode == 8) && (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")) ||
		((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82)) ) || (event.keyCode == 116)
	) {
		event.keyCode = 0;
		event.returnValue = false;
	}
}
*/

