function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		area_map_SouthEast_over = newImage("/images/map/south-east.gif");
		area_map_NorthernIreland_over = newImage("/images/map/northern-ireland.gif");
		area_map_Wessex_over = newImage("/images/map/wessex.gif");
		area_map_NorthWest_over = newImage("/images/map/north-west.gif");
		area_map_Yorkshire_over = newImage("/images/map/yorkshire.gif");
		area_map_WestMidlands_over = newImage("/images/map/west-midland.gif");
		area_map_Wales_over = newImage("/images/map/wales.gif");
		area_map_EastMidlands_over = newImage("/images/map/east-midland.gif");
		area_map_EastAnglia_over = newImage("/images/map/east-anglia.gif");
		area_map_Thames_Solent_over = newImage("/images/map/thames.gif");
		area_map_Devon_Cornwall_over = newImage("/images/map/devon.gif");
		preloadFlag = true;
	}
}

function qsrch_disciplinecontrol_onchange(me)
{
	qsrch_update_sectors();
}

function qsrch_update_sectors(initial)
{
	var disddl = document.getElementById('qs_specialisation');
	var disid = parseInt(disddl.options[disddl.selectedIndex].value,10);
	
	var stddl = document.getElementById('qs_sector');
	
	var selectedvalue = "0";	
	if (initial) {
		if (document.getElementById('qs_sector_selectedvalue').value != '') {
			selectedvalue = document.getElementById('qs_sector_selectedvalue').value
		}
	} else {
		if (stddl.selectedIndex > -1) {
			selectedvalue = stddl.options[stddl.selectedIndex].value
		}
	}
	
	stddl.options.length = 1;
	stddl.options[0].selected = true;
	
	var newopts = SectorOptionsPerDiscipline['disciplineid_' + disid];
	for (var i=0; i<newopts.length; i++) {
		var newopt = document.createElement('option');
		newopt.text = newopts[i][0];
		newopt.value = newopts[i][1];
		if (newopt.value == selectedvalue) newopt.selected = true;
		
		stddl.options[stddl.options.length] = newopt;
	}
}

function ValidateSiteSearchForm() 
{
    if (CheckBlank(document.sitesearch.keywords,'Keywords')==false) return false;
}

function SectorTipManager()
{
	var me = this;
	var timerid = null;
	
	this.show = function () {
		if (timerid!=null) {
			clearTimeout(timerid);
			timerid = null;
		}
		
		document.getElementById('qs_multiplesectortip_div').style.left = (getLeft(document.getElementById('qs_sector'))+200) + "px";
		document.getElementById('qs_multiplesectortip_div').style.top = getTop(document.getElementById('qs_sector')) + "px";
		
		document.getElementById('qs_multiplesectortip_div').style.display = 'block';
	};
	
	this.hide = function () {
		if (timerid == null) {
			timerid = setTimeout(function () { document.getElementById('qs_multiplesectortip_div').style.display = 'none' }, 1000);
		}
	};
}

var qsrch_stm = new SectorTipManager();