/****************************************************************************/
/***		Client-side JavaScript function library														***/
/***		Copyright Apache Solutions Ltd 2004																***/
/***		(unauthorised use of this code will result in prosecution by law)	***/
/****************************************************************************/


// capture mouse clicks.
/*
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=HandleMouseClick;
*/

//
// Displays a pop up copyright message if the right mouse button is used:
//
function HandleMouseClick(e) {
	var message="All content is copyright 2004 <%=site_name%>, all rights reserved.";
	if (document.all) {
		if (event.button==2 || event.button==3) {
			alert(message);
			return false;
		}
	}
	else if (document.layers) {
		if (e.which == 3) {
			alert(message);
			return false;
		}
	}
}

//
//	Returns true if the given variable is blank:
//
function IsBlank(value) {
	// cast to string.
	var str = "" + value;
	return ((str == "") || (str == " ") || (str == "undefined") || (str == "null") || (str == null));
}

//
//	Returns true if browser is Internet Explorer:
//
function IsIE() {
	return (window.navigator.userAgent.indexOf("MSIE") >= 1);
}

//
//	Returns version number of Internet Explorer browser:
//
function IEVersion() {
	var ua = window.navigator.userAgent;
	if (ua.indexOf("MSIE 4.0") >=1 ) return 4;
	if (ua.indexOf("MSIE 5.0") >=1 ) return 5;
	if (ua.indexOf("MSIE 5.5") >=1 ) return 5.5;
	if (ua.indexOf("MSIE 6.0") >=1 ) return 6;
}

//
//	Returns true if Internet Explorer browser version 4 or above is detected:
//
function IsIE4Plus() {
	if (IsIE() && IEVersion() >= 4) {
		return true;
	}
	return false;
}

//
// Sets the roll-in image:
//
//	N.B the 'on_name' param is optional - it overrides the default value of 'on' for the active image object.
//
function RollIn(img_name, on_name) {
	if (document.images) {
		var the_on_name = (IsBlank(on_name) ? 'on.src':on_name+'.src');
		document[img_name].src=eval(img_name + the_on_name);             
	}
	return true;
}
//
// Sets the roll-out image:
//
function RollOut(img_name) {
	if (document.images) {
		document[img_name].src=eval(img_name + "off.src");          
	}
	return true;
}

//
// Sets the on click image:
//
function RollClick(img_name) {
	if (document.images) {
		document[img_name].src=eval(img_name + "click.src");          
	}
	return true;
}

//
// Sets the roll-in form image:
//
function RollInFormImage(img_name) {
	if (IsIE4Plus()){
		document.all[img_name].src=eval(img_name + "on.src");
	}            
}

//
// Sets the roll-out form image:
//
function RollOutFormImage(img_name) {
	if (IsIE4Plus()){
		document.all[img_name].src=eval(img_name + "off.src");
	}    
}

//
// Sets the on click form image:
//
function RollClickFormImage(img_name) {
	if (IsIE4Plus()){
		document.all[img_name].src=eval(img_name + "click.src");
	}    
}
//
//	Opens a popup window.
//
function OpenPopupWindow(url, width, height) {
	var popupwindow = window.open(url, 'popupwindow', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height);
	popupwindow.focus();
}

