function navOver(item)
{
	// tweak item string to match image file names
	var re = / /;
	item = item.replace(re,'-');
	item = item.toLowerCase();

	document.images.navPic.src = '/images/' + [item] + '_s.jpg';
}

function navOff()
{
	document.images.navPic.src = '/images/generic_s.jpg';
}

function chooseSearch(searchtype,keywords)
{
	if(keywords == '')
	{
		alert('Please enter your search keywords');
		document.forms.popSearch.keywords.focus();
	}
	else
	{
		if(searchtype == 'techlib')
		{
			document.forms.tlsearchPop.keywords.value = keywords;
			document.forms.tlsearchPop.submit();
		}
		else
		{
			document.forms.sitesearch.query_string.value = keywords;
			document.forms.sitesearch.submit();
		}
	}
}

function showSearch()
{
	document.getElementById('searchbox').style.visibility = 'visible';
}
function hideSearch()
{
	document.getElementById('searchbox').style.visibility = 'hidden';
}
function doPreload()
{
	// preload navigation mouseover images
	
	var the_images = new Array('/images/nav-over.gif','/images/accomm_s.jpg',
	'/images/barrier_s.jpg','/images/seating_s.jpg',
	'/images/fencing_s.jpg','/images/staging_s.jpg',
	'/images/flooring_s.jpg','/images/roadway_s.jpg',
	'/images/turnstile_s.jpg','/images/acoustic_s.jpg');
	preloadImages(the_images);
}

function preloadImages(the_images_array) 
{

	for(loop = 0; loop < the_images_array.length; loop++)
	{
   		var an_image = new Image();
		an_image.src = the_images_array[loop];
	}
}

// 	Map locator DHTML functions
//	###########################################################
// 	showDetails('id'); should be called by the event handler 
//	(passing through the id of the <div> we want to display)
//
//	for non-getElementById browsers the function performs a simple internal href
//	so <div> visibilities should be set to visible
//

function hideDetails(area) 
{
		// all the id's for the <div>'s whose visibility we want to toggle
		// n.b. if any of these point to a missing <div> showDetails will not work
		//		
		
		if(area == "world") // (world locator)
		{
			var the_details = new Array('default','America','Hong_Kong','Malaysia','Singapore','Azerbaijan',
			'Czech_Republic','Denmark','France','Latvia','Netherlands','Poland','Portugal','Slovakia','Egypt',
			'Qatar','Saudi_Arabia_Baroom','Saudi_Arabia_Dabal','Saudi_Arabia_Dabal2','Saudi_Arabia_Dabal3',
			'Saudi_Arabia_Dabal4','Saudi_Arabia_Dabal5','UAE','UAE2','UAE3');
		}
		else // (uk locator)
		{
			var the_details = new Array('default','Aberdeen','Evanton','Inverness','Glasgow','Dundee',
			'Grangemouth','Edinburgh','Cumbernauld','Isle_of_Man','Newcastle','Hull',
			'Leeds','Lincoln','Preston','Elland','Sheffield','Liverpool','Haydock','Manchester',
			'Derby','Stoke_on_Trent','Shrewsbury','Nottingham','Dosthill','Dosthill2','Birmingham',
			'Coventry','Norwich','Ipswich','Cambridge','Northampton','Oxford','Cheltenham','Cardiff',
			'Swindon','Bristol','Reading','London_North','West_Thurrock','Brighton',
			'Maidstone','Maldon','Maldon2','Lingfield','Southampton','Exeter','Swindon','Plymouth',
			'Birmingham2','Bristol2','Bristol3','Glasgow2','Lingfield2',
			'London2','London3','London4','London5','London6','Nottingham2','Reading2','Southampton2',
			'Jersey','Jersey2','Jersey3','Guernsey','Dublin','Cork','Gateshead');
		}
		
		// loop hides content
		//
		for(loop = 0; loop < the_details.length; loop++)
		{
			document.getElementById(the_details[loop]).style.visibility = 'hidden';
		}
}

function showDetails(area,name)
{
	if(document.getElementById)
	{
		hideDetails(area);	// first all <div>'s are hidden	   
		document.getElementById(name).style.visibility = 'visible';	// display <div> 
	}
	else
	{
		// in case the current url is already at an internal link,
		// split it by # and use the first object of the subsequent array
		// as the base url
		
		var theUrl = document.location.href.split("#");
		document.location.href = theUrl[0] + "#" + (name);
	}
}

//-->

// open map window, pass id of <div>, width and height

function showMap(name,w,h)
{
	h = parseInt(h) + 23; // to cater for close window button
	name = name.toLowerCase();
	mapwin=window.open("http://www.sgb.co.uk/maps/" + (name) + ".php","mapWin","width="+(w)+",height="+(h)+",resizable=no");
	mapwin.focus();
}

// contact us & helpdesk forms both use this

function checkInputValidity (form) {
    var errors = new String();
        errors = "";
    if (form.Inquiry.value == "") {
        errors = errors + "Please provide your inquiry details\n\n";
    }
	if (form.Name.value == "") {
        errors = errors + "Please provide your name\n\n";
    }
	if (form.Postcode.value == "") {
        errors = errors + "Please provide your postcode\n\n";
    }
    if (form.Email.value == "" || form.Email.value.indexOf('@', 0) == -1) {
        errors = errors + "Please provide a valid email address\n\n";
    }
	if (errors != "") {
        alert(errors);
        return false;
    }
	else
	{
		(form).submit();
	}
}

// netcollecta form uses this (register your email)

function checkCollecta (form) {
    var errors = new String();
        errors = "";
	if(form.Field7.value != "" && form.Title.value == "Other") {
		form.Field1.value = form.Field7.value;
	} else {
		form.Field1.value = form.Title.value
	}
    if (form.Field1.value == "") {
        errors = errors + "Please provide your title\n\n";
    }
	 if (form.Field2.value == "") {
        errors = errors + "Please provide your surname\n\n";
    }
	 if (form.Field3.value == "") {
        errors = errors + "Please provide your forename\n\n";
    }
	 if (form.Field4.value == "") {
        errors = errors + "Please provide your company name\n\n";
    }
	if (form.Field6.value == "" || form.Field6.value.indexOf('@', 0) == -1) {
        errors = errors + "Please provide a valid email address\n\n";
    }
     if (errors != "") {
        alert(errors);
        return false;
    }
	else
	{
		return true;
		(form).submit();
	}
}

//-->