/****************************************************************************/
/***		Client-side JavaScript function library														***/
/***		Copyright Apache Solutions Ltd 2005																***/
/***		(unauthorised use of this code will result in prosecution by law)	***/
/****************************************************************************/

// define the rollover images.
if (document.images) {
	
	CMD_searchoff = new Image(52,22);
  CMD_searchoff.src = "../images/header/searchbut_a.gif";
  CMD_searchon = new Image(52,22);
  CMD_searchon.src = "../images/header/searchbut_b.gif";
	
	CMD_submitoff = new Image(52,18);
  CMD_submitoff.src = "../images/buttons/submita.gif";
  CMD_submiton = new Image(52,18);
  CMD_submiton.src = "../images/buttons/submitb.gif";

	homeoff = new Image(157,56);
  homeoff.src = "../images/header/home_a.gif";
	homeon = new Image(157,56);
  homeon.src = "../images/header/home_b.gif";
}

//
//	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();
}