<!--
//Bespoke functions
function targetblank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}
function showmenu(id) {
	if (id != "menu3") { hidemenu("menu3"); }
	if (id != "menu4") { hidemenu("menu4"); }
	if (id != "menu5") { hidemenu("menu5"); }
	if (id != "menu6") { hidemenu("menu6"); }
	if (id != "menu8") { hidemenu("menu8"); }
	
	if (document.getElementById(id).style.visibility=="visible") {
		eval("clearTimeout(menutimerout"+id+")"); /* clear the existing timeout */
	} else {
		document.getElementById(id).style.visibility="visible";
	}
}
function hidemenutimer(id) {
	eval("menutimerout"+id+"=setTimeout(\"hidemenu('"+id+"')\",500)"); /* give it a fraction of a sec to move between menu and items */
}
function hidemenu(id) {
	document.getElementById(id).style.visibility="hidden";
}

function copyrightDate(){
	wriYr = new Date
	var doYr = wriYr.getFullYear()
	document.write(doYr)
}
function togglejobdetail(id) {
	if (typeof(activejobid) != 'undefined') {
		lastactivejobid=activejobid;
	} else {
		lastactivejobid="";
	}
	activejobid=id;

	activejobdescobj=document.getElementById(activejobid+"_desc");

	if (lastactivejobid == "") { // never clicked a job before
		togglejobdetailon(activejobid);
	} else {
		if (activejobid == lastactivejobid) { //toggling the same one
			if (activejobdescobj.style.display == "none") {
				togglejobdetailon(activejobid);
			} else {
				togglejobdetailoff(activejobid);
			}
		} else {															//its a new job
			togglejobdetailoff(lastactivejobid); 
			togglejobdetailon(activejobid);
		}
	}
}
function togglejobdetailon(id) {
	obj=document.getElementById(id);
	objdesc=document.getElementById(id+"_desc");
	objtic=document.getElementById("t"+id);

	objdesc.style.display="block";
	obj.style.borderTop="1px solid #333333";
	obj.style.borderLeft="1px solid #333333";
	obj.style.borderRight="1px solid #333333";
	obj.style.backgroundColor="#808080";
	obj.style.color="white";
	obj.className="divcondet divcondetactive";
	objtic.style.visibility="hidden";
}
function togglejobdetailoff(id) {
	obj=document.getElementById(id);
	objdesc=document.getElementById(id+"_desc");
	objtic=document.getElementById("t"+id);

	objdesc.style.display="none";
	obj.style.borderTop="none";
	obj.style.borderLeft="none";
	obj.style.borderRight="none";
	obj.style.backgroundColor="white";
	obj.style.color="#333333";
	obj.className="divcondet";
	objtic.style.visibility="visible";
}

function checksearch() {
	//check fields for invalid characters
	if (!(checksearchfield("keywords"))) {
		alert ("The following characters are invalid and may not be used: < > ` \"");
		return(false)
	}
}
function checksearchfield(fieldname) {
	fieldnamevalue=document.getElementById(fieldname).value;

	if ((fieldnamevalue.search('Search by Keywords') != -1)) { // nothing entered
		document.getElementById(fieldname).value="";
		return(true)
	}
	if (!(checkformfield(fieldnamevalue))) {
		return false
	} else {
		return true
	}
}
function checkcontact() {
	if ((!(checkformfield(document.getElementById("name").value)))
	|| (!(checkformfield(document.getElementById("email").value)))
	|| (!(checkformfield(document.getElementById("phone").value)))
	|| (!(checkformfield(document.getElementById("comments").value)))) {
		alert ("The following characters are invalid and may not be used: < > ` \"");
		return(false)
	}
	if ((document.getElementById("name").value == "")
	|| ((document.getElementById("email").value == "")
	&& (document.getElementById("phone").value == ""))) {
		alert ("Please complete you name and either your email or phone details");
		return false;
	}
	if ((!(document.getElementById("byphone").checked))
	&& (!(document.getElementById("byemail").checked))) {
		alert ("Please choose whether you would prefer to be contacted by phone or email");
		return false;
	}
}
function checkregapp() {
	if ((!(checkformfield(document.getElementById("name").value)))
	|| (!(checkformfield(document.getElementById("addr1").value)))
	|| (!(checkformfield(document.getElementById("addr2").value)))
	|| (!(checkformfield(document.getElementById("town").value)))
	|| (!(checkformfield(document.getElementById("county").value)))
	|| (!(checkformfield(document.getElementById("pcode").value)))
	|| (!(checkformfield(document.getElementById("phone").value)))
	|| (!(checkformfield(document.getElementById("email").value)))
	|| (!(checkformfield(document.getElementById("birth").value)))
	|| (!(checkformfield(document.getElementById("emplo").value)))
	|| (!(checkformfield(document.getElementById("title").value)))
	|| (!(checkformfield(document.getElementById("vacref").value)))
	|| (!(checkformfield(document.getElementById("vactit").value)))
	|| (!(checkformfield(document.getElementById("addinfo").value)))) {
		alert ("The following characters are invalid and may not be used: < > ` \"");
		return(false)
	}
	if ((document.getElementById("name").value == "")
	|| ((document.getElementById("email").value == "")
	&& (document.getElementById("phone").value == ""))) {
		alert ("Please complete you name and either your email or phone details");
		return false;
	}
}

function checkregemp() {
	if ((!(checkformfield(document.getElementById("title").value)))
	|| (!(checkformfield(document.getElementById("name").value)))
	|| (!(checkformfield(document.getElementById("position").value)))
	|| (!(checkformfield(document.getElementById("company").value)))
	|| (!(checkformfield(document.getElementById("address").value)))
	|| (!(checkformfield(document.getElementById("pcode").value)))
	|| (!(checkformfield(document.getElementById("phone").value)))
	|| (!(checkformfield(document.getElementById("email").value)))
	|| (!(checkformfield(document.getElementById("fax").value)))
	|| (!(checkformfield(document.getElementById("vactit").value)))
	|| (!(checkformfield(document.getElementById("vacdesc").value)))) {
		alert ("The following characters are invalid and may not be used: < > ` \"");
		return(false)
	}
	if ((document.getElementById("name").value == "")
	|| ((document.getElementById("email").value == "")
	&& (document.getElementById("phone").value == ""))) {
		alert ("Please complete you name and either your email or phone details");
		return false;
	}
}
function checkviews () {
	if ((document.getElementById("name").value == "")
	&& (document.getElementById("email").value == "")
	&& (document.getElementById("like").value == "")
	&& (document.getElementById("dislike").value == "")
	&& (document.getElementById("improve").value == "")) {
		alert ("Please complete at least one of the fields before submitting");
		return false;
	}
}
function clearkeywords() {
	document.getElementById("keywords").value='';       
}
function checkformfield(fieldname) {
	if ((fieldname.search('<') != -1)
	|| (fieldname.search('>') != -1)
	|| (fieldname.search('`') != -1)
	|| (fieldname.search('"') != -1)) {
		return(false)
	} else {
		return(true)
	}
}

function fillmailids () {
	for (i=0;i<document.links.length;i++) {
		if ((document.links[i].id.search('a1_') != -1)
		|| (document.links[i].id.search('a3_') != -1)
		|| (document.links[i].id.search('contactid') != -1)
		|| (document.links[i].id.search('adc') != -1)
		|| (document.links[i].id.search('ainf') != -1)
		|| (document.links[i].id.search('acvu') != -1)
		|| (document.links[i].id.search('aimgsideemail') != -1)) {
			buildeaddress(document.links[i].id,document.links[i].title);
		}
	}
}
function buildeaddress (id,title) {
	parsemail_array=id.split("_");
	parsemailtype=parsemail_array[0];
	parsemailjobref=parsemail_array[1];
	alias="";
	bodyline="";
	
	switch (parsemailtype) {
		case "a1":
			title_array=title.split("Apply for ");
			titlelong=title_array[1];
			subjline="Application for job ref: " + parsemailjobref.toUpperCase() + " - " + titlelong;
			bodyline="Please attach your CV with any relevant details, including current and expected salary. Thanks, we will be in contact shortly.";
			who = "jobs";
			whereat = "leedrecruitment.co.uk";
			eaddress = who + "@" + whereat;
		break
		case "a3":
			title_array=title.split("Email details for ");
			titlelong=title_array[1];
			subjline=escape(titlelong + " position available");
			bodyline=escape("I saw a job on the Leed Recruitment website (ref")+":"+escape(" "+parsemailjobref.toUpperCase()+") and thought it might be of interest to you http")+":"+escape("//www.leedrecruitment.co.uk/vacancies.php")+"?"+escape("keywords="+parsemailjobref);
			eaddress = "";
		break
		case "aimgsideemail":
			part2="";
			pageurl=document.location+" ";
			part1array=pageurl.split("http:");
			part1=part1array[1];
			part2array=part1.split('?');
			part1=escape(part2array[0]);
			if ((typeof(part2array[1])) != "undefined") {
				part2="?"+escape(part2array[1]);
			}
			subjline=escape("Leed Recruitment website page");
			bodyline=escape("I saw this page on the Leed Recruitment website and thought it might be of interest to you - http")+":"+part1+part2;
			eaddress = "";
		break
		case "contactid":
			subjline=escape("CV attached from Contact Us page");
			bodyline=escape("Please attach your CV with any relevant details. Thanks, we will be in contact shortly.");
			who = "jobs";
			whereat = "leedrecruitment.co.uk";
			eaddress = who + "@" + whereat;
			if (id == "contactid_1") {
				alias = eaddress;
			}
		break
		case "acvu":
			subjline=escape("CV update");
			who = "cvupdate";
			whereat = "leedrecruitment.co.uk";
			eaddress = who + "@" + whereat;
			alias = eaddress;
		break		
		case "ainf":
			subjline=escape("Information request");
			who = "info";
			whereat = "leedrecruitment.co.uk";
			eaddress = who + "@" + whereat;
			alias = eaddress;
		break		
		case "adc":
			subjline=escape("Data enquiry");
			who = "datacontroller";
			whereat = "leedrecruitment.co.uk";
			eaddress = who + "@" + whereat;
			alias = eaddress;
		break		
	}

	elink = "mailto:" +
		eaddress +
		"?subject=" + subjline +
		"&body=" + bodyline;

	node1 = document.getElementById(id);
	node1.setAttribute("href",elink);

	if (alias != "") {
		node2 = document.createTextNode(alias);
		node1.appendChild(node2);
	}
}
function inserttopbarmovie () {
	htmltexttoinsert="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='469' height='55' id='objtopbarpulse' title='Call Leed Recruitment on 01473 289000'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='images/topbarpulse2.swf' /><param name='menu' value='false' /><param name='loop' value='true' /><param name='quality' value='best' /><param name='bgcolor' value='#cccccc' /><embed src='images/topbarpulse2.swf' loop='true' quality='best' bgcolor='#cccccc' width='469' height='55' name='objtopbarpulse' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";

document.getElementById('divobjtopbarpulse').innerHTML=htmltexttoinsert;
}
function showval() {
	alert(document.getElementById("divobjtopbarpulse").innerHTML);
}
function insertouttheremovie () {
	htmltexttoinsert="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='125' height='140' id='objhomeoutthere' title='Leed...putting you out there'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='images/homeoutthere.swf' /><param name='play' value='false' /><param name='loop' value='false' /><param name='quality' value='best' /><param name='bgcolor' value='#ffffff' /><embed src='images/homeoutthere.swf' play='false' loop='false' quality='best' bgcolor='#ffffff' width='125' height='140' name='objhomeoutthere' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"

document.getElementById('divobjhomeoutthere').innerHTML=htmltexttoinsert;
}
