/*
 *Miscellaneous JS functions
 *
 *written by M Monks 22/9/2001
*/

//sets the index of a select box dependant on a particular value
function populateSelect(select,valueToSet){
	if (valueToSet != ""){
		for (var i=0; i<select.options.length; i++){
			if (select.options[i].value == valueToSet){
				select.selectedIndex = i;
			}
		}
	}
}

//checks an array of checkboxes, or an individual checkbox
//depending on an array of values or a single value
function populateCheckboxes(checkbox, valuesToSet){
	if (checkbox[0]){
		for (var j=0; j<checkbox.length; j++){
			for (var i=0; i<valuesToSet.length; i++){
				if (checkbox[j].value == valuesToSet[i]){
					checkbox[j].checked=true;
				}
			}
		}
	}else{
		if (valuesToSet == "on"){
			checkbox.checked=true;
		}
	}
}

//opens a popup window closing it first if its already open
function popUpWindow(url, features){
	if (!isIEMac()){
		closePopUpWindow();
	}
	window.openedWin = window.open(url,"popup",features);
}

//closes a popup window
function closePopUpWindow(){
	if (window.openedWin && window.openedWin.close){
		window.openedWin.close();
	}
}

//checks whether IE on Mac is being used
function isIEMac(){
	//if (navigator.platform.indexOf("Mac")!=-1 && navigator.appVersion.indexOf("MSIE")!=-1){
	//	return true;
	//}
	//return false;
	return navigator.platform.indexOf("Mac")!=-1 && navigator.appVersion.indexOf("MSIE")!=-1;
}

// Checks if brand is ILL - added by T Grey
function isILL() {
	return brand == 'fl' || brand == 'fls' || brand == 'fli' || brand == 'il' || brand == 'cl' || brand == 'vl';
}
