// JavaScript Document
function showDiv(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementsByTagName("div"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="showhideclass") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
			if(obj == "valueson")
			{
				var valuesondivname = document.getElementById('values');
				valuesondivname.style.background = "url(images/home-values-on.gif) no-repeat";
				var vacanciesondivname = document.getElementById('vacancies');
				vacanciesondivname.style.background = "url(images/home-latestvacancies.gif) no-repeat";
				var newsondivname = document.getElementById('news');
				newsondivname.style.background = "url(images/home-latestnews.gif) no-repeat";
			}
			if(obj == "vacancieson")
			{
				var valuesondivname = document.getElementById('values');
				valuesondivname.style.background = "url(images/home-values.gif) no-repeat";
				var vacanciesondivname = document.getElementById('vacancies');
				vacanciesondivname.style.background = "url(images/home-latestvacancies-on.gif) no-repeat";
				var newsondivname = document.getElementById('news');
				newsondivname.style.background = "url(images/home-latestnews.gif) no-repeat";
			}
			if(obj == "newson")
			{
				var valuesondivname = document.getElementById('values');
				valuesondivname.style.background = "url(images/home-values.gif) no-repeat";
				var vacanciesondivname = document.getElementById('vacancies');
				vacanciesondivname.style.background = "url(images/home-latestvacancies.gif) no-repeat";
				var newsondivname = document.getElementById('news');
				newsondivname.style.background = "url(images/home-latestnews-on.gif) no-repeat";
			}
			
		}else{
			el.style.display = "none";
		}
	}
}

function showDivSub(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementsByTagName("div"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="helpclass") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function clearName(){
  	document.frmCVUPLOAD.upload_name.value = '';
}

function clearEmail(){
  document.frmCVUPLOAD.upload_email.value = '';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function KW_updateItems(d,o,fn) { //v2.6 By Paul Davis www.kaosweaver.com
  var i,s,l=MM_findObj(d),b,z=o.options[o.selectedIndex].value;
  l.length=0;l.options[0]=new Option('All Job types','0');b=(z!='nill')?eval(z+'_items'):0;
  for(i=0;i<b.length;i++){s=b[i].split("|");l.options[i]=new Option(s[1],s[0]);}
  l.selectedIndex=0;if (!fn) return;eval(fn)
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function evaswap(obj, val){
  obj.src = val;
}

function submitform(trgForm, validator) 
{
	if ( validator != '' )
	{
		eval( "if (" + validator + "('" + trgForm + "')) { document.getElementById('" + trgForm + "').submit(); }" );
	}
	else
	{
		document.getElementById(trgForm).submit();
	}

}

function getForm(form)
{
	if (form.split)
		return document.getElementById(form);
	else
		return form;
}

function check_upload(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.upload_name.value == ''){
		alert("Please enter your name...");
		form.upload_name.focus();
		return false;
	}
	if (form.upload_email.value == '' || form.upload_email.value.match(illegalChars) || !(emailFilter.test(form.upload_email.value))){
		alert("Please enter a valid email address...");
		form.upload_email.focus();
		return false;
	}
	if (form.upload_cv.value == ''){
		alert("Please attach your CV...");
		form.upload_cv.focus();
		return false;
	}
	
	return true;
}

function check_apply(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	if (form.email.value == '' || form.email.value.match(illegalChars) || !(emailFilter.test(form.email.value))){
		alert("Please enter a valid email address...");
		form.email.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	
	if (form.comments.value == ''){
		alert("Please enter your comments...");
		form.comments.focus();
		return false;
	}
	
	return true;
}

function check_contact(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	if (form.email.value == '' || form.email.value.match(illegalChars) || !(emailFilter.test(form.email.value))){
		alert("Please enter a valid email address...");
		form.email.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	
	if (form.comments.value == ''){
		alert("Please enter your comments...");
		form.comments.focus();
		return false;
	}
	
	if (form.enquirytype.value == ''){
		alert("Please select an enquiry type...");
		form.enquirytype.focus();
		return false;
	}
	
	return true;
}

function check_nocv(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	if (form.email.value == '' || form.email.value.match(illegalChars) || !(emailFilter.test(form.email.value))){
		alert("Please enter a valid email address...");
		form.email.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	
	if (form.location.value == ''){
		alert("Please enter a location...");
		form.location.focus();
		return false;
	}
	
	if (form.comments.value == ''){
		alert("Please enter your comments...");
		form.comments.focus();
		return false;
	}
	
	return true;
}


function check_refer(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	if (form.email.value == '' || form.email.value.match(illegalChars) || !(emailFilter.test(form.email.value))){
		alert("Please enter a valid email address...");
		form.email.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	if (form.howheard.value == ''){
		alert("Please select how you heard about us...");
		form.howheard.focus();
		return false;
	}
	
	if (form.candidatename.value == ''){
		alert("Please enter your candidates name...");
		form.candidatename.focus();
		return false;
	}
	if (form.candidateconsent.value == ''){
		alert("Please select if your candidate has give their consent...");
		form.candidateconsent.focus();
		return false;
	}
	if (form.candidateemail.value == '' || form.candidateemail.value.match(illegalChars) || !(emailFilter.test(form.candidateemail.value))){
		alert("Please enter a valid candidate email address...");
		form.candidateemail.focus();
		return false;
	}
	var stripped = form.candidatetelephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.candidatetelephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your candidates telephone number is incomplete or contains invalid characters...");
		form.candidatetelephone.focus();
		return false;
	}
	if (form.agreeterms.checked != true){
		alert("Please read and accept our terms & conditions");
		form.agreeterms.focus();
		return false;
	}
	return true;
}

function check_cadvice(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	if (form.email.value == '' || form.email.value.match(illegalChars) || !(emailFilter.test(form.email.value))){
		alert("Please enter a valid email address...");
		form.email.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	
	if (form.comments.value == ''){
		alert("Please enter your comments...");
		form.comments.focus();
		return false;
	}
	
	return true;
}

function check_vacancy(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;
	
	if (form.pv_jobtype.value == ''){
		alert("Please select a job type...");
		form.pv_jobtype.focus();
		return false;
	}
	if (form.pv_location.value == ''){
		alert("Please select a location...");
		form.pv_location.focus();
		return false;
	}
	if (form.pv_salary.value == ''){
		alert("Please select a salary...");
		form.pv_salary.focus();
		return false;
	}
	
	if (form.pv_name.value == ''){
		alert("Please enter your name...");
		form.pv_name.focus();
		return false;
	}
	var stripped = form.pv_telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.pv_telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.pv_telephone.focus();
		return false;
	}
	if (form.pv_email.value == '' || form.pv_email.value.match(illegalChars) || !(emailFilter.test(form.pv_email.value))){
		alert("Please enter a valid email address...");
		form.pv_email.focus();
		return false;
	}
	return true;
}

function check_callback(checkForm) 
{
	var form = getForm(checkForm);
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	var justNumbers = /^[0-9]*$/;
	var re = /\s/;									
	if (form.name.value == ''){
		alert("Please enter your name...");
		form.name.focus();
		return false;
	}
	var stripped = form.telephone.value.replace(/[\(\)\.\-\ ]/g, '');
	if (form.telephone.value == '' || isNaN(parseInt(stripped)) || !(justNumbers.test(stripped))) {
		alert("Your telephone number is incomplete or contains invalid characters...");
		form.telephone.focus();
		return false;
	}
	
	return true;
}

function check_login(form) {					
	if (form.username.value == ''){
		alert("Please enter your username...");
		form.username.focus();
		return false;
	}
	if (form.password.value == ''){
		alert("Please enter your password...");
		form.password.focus();
		return false;
	}
}