function clearBox(f) {
	if(f.value==f.defaultValue) {
		f.value = '';	
	}
}

function restoreBox(f) {
	if(f.value=='') {
		f.value = f.defaultValue;	
	}
}

function showVideoOverlay(video, chapter) {
	var size = getScreenSize();
	$('popup_background').style.width=size[0]+'px';
	$('popup_background').style.height=size[1]+'px';
	Element.setOpacity('popup_background', 0.9);	
	$('popup_content').style.left=(((size[0])/2)-312)+'px';

	if(chapter) {
		videourl = '/images/media/chapters/'+video+'_'+chapter+'.flv';	
	}
	else {
		videourl = '/images/media/videos_'+video+'.flv';	
	}

	$('popup_content').innerHTML = '<div id="close" onclick="hideOverlay();">&nbsp;</div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="624" height="400"><param name="movie" value="/images/player.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="flashvars" value="lvid='+videourl+'" /><embed src="/images/player.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="624" height="400" wmode="transparent" allowfullscreen="true"  flashvars="lvid='+videourl+'"></embed></object>';

	$('popup_background').style.display = 'block';
	$('popup_content').style.display = 'block';

	$('popup_background').onclick = hideOverlay;
	return false;
}

function hideOverlay() {
	$('popup_background').style.display = 'none';
	$('popup_content').innerHTML = '&nbsp;';
	$('popup_content').style.display = 'none';
}

function getScreenSize() {

	if(self.innerWidth) {
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientWidth) {
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if(document.body) {
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}	
	
	var tmp = Array();
	tmp[0] = frameWidth;
	tmp[1] = frameHeight;
	return tmp;
}

function s(id) {
	document.getElementById(id).style.display = 'block';	
}

function h(id) {
	document.getElementById(id).style.display = 'none';	
}

/* Validate Form */
function Validate() {

	/* Items that require a text input */
	var myVars = new Array("name",
												 "email",
												 "telephone",
												 "address",
												 "postcode",
												 "expertise"
												 );
	
	for(i=0;i<myVars.length;i++){
		var id = myVars[i];
		if(document.getElementById(id).value == ""){
			document.getElementById(id).style.borderColor = "#f86060";
			document.getElementById(id).style.backgroundColor = "#ffeeee";
			
			var errors = 'yes';
		}
		else {
			document.getElementById(id).style.borderColor = "#999999";
			document.getElementById(id).style.backgroundColor = "#ffffff";
		}
	}
	
	if(errors == 'yes'){
		alert("Your form submission failed.\n\n Please correct the errors highlighted in red.\n");
		self.scrollTo(0, 0);
		return false;
	}
	else {
		return true;
	}
}