// General ACM functions developed by estona.com

// Go to href
function go(url){
	document.location.href=url;
}

// Open link in a new window
function nW(thisLink){
	window.open(thisLink.href);
	return false;
}

// Call me web form submission

function callMe(){
	
	value = document.getElementById('name').value
	if (value==null||value==''){
		alert("Please enter your name so we know who to ask for when we call - thanks.");
		document.getElementById('name').focus();
		return;
	}

	value = document.getElementById('tel').value
	if (value==null||value==''){
		alert("Please give us the phone number you'd like us to call you on. If you are outside the UK don't forget your country code! Thanks.");
		document.getElementById('tel').focus();
		return;
	}

	document.forms.frm_callme.submit();
}

// HTML obfuscater
function deScram(scrambled){

	var Scramblei, Scrambley='';
	
	Scramblex=scrambled;

	if (Scramblex=='Preset1'){
		Scramblex="The code for Preset1 goes here"
	}
	
	for (Scramblei=0; Scramblei < Scramblex.length;Scramblei+=2){
		Scrambley += unescape('%' + Scramblex.substr(Scramblei,2));
	}

	document.write(Scrambley);
}

// Search form checks

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validate_search(thisform){
	with (thisform){					
		if (srctxt.value==null||srctxt.value==""){
			alert("Please enter some text for the search and try again.");
			srctxt.focus();
			return false;
		}

		if (srctxt.value.length<4){
			alert("Sorry, but your search term needs to be at least 4 characters long.");
			srctxt.focus();
			return false;
		}

		return true;
	}
}

function searchThisSite(){
	if(validate_search(document.forms.frm_src)){document.forms.frm_src.submit()}
}