function swapIn(objTD,objColor) {
	objTD.style.backgroundColor = objColor;
}
function swapOut(objTD,objColor) {
	objTD.style.backgroundColor = objColor;
}
function ValidateSearchForm()
{
	formobj=document.searchform;
	if (formobj.name.value == "") {
		if (formobj.location.value == "") {
			if (formobj.postcode.value == "") {
				if (formobj.certid.value == "") {
					alert("Please enter something in at least one of the search fields.");
					formobj.name.focus();
					return false;
				}
				else if (formobj.certid.value.length < 7 ) {
					alert("Please enter in the correct ELPXXXX format");
					formobj.certid.focus();
					return false;
				}
			}
		}
	}
}
function ValidateMailForm()
{
	var strcINVALID_EMAIL_CHARACTERS="[^A-Za-z0-9._@\x2D]"
	formobj=document.mailform;
	if (formobj.sender.value == "") {
		alert("Please enter your name.");
		formobj.sender.focus();
		return false;
	}
	if (formobj.replyaddress.value == "")
		{
			alert("Please enter an email address");
			formobj.replyaddress.focus();
			return false;
		}
	else
		{
			strValue=new String(formobj.replyaddress.value)
			if(strValue.search(new RegExp(strcINVALID_EMAIL_CHARACTERS))!=-1)
				{
					alert("The Email address must only contain only the following: Letters (A..Z), Numbers (0..9), Apostrophe ('), Full stop (.), AT (@), Underscore (_) and Dash (-). Spaces are not allowed.")
					formobj.replyaddress.focus();
					return false;
				}
				
			if (strValue.indexOf("@") == -1) {
				alert("The Email address must contain the @ character to be valid.")
				formobj.replyaddress.focus();
				return false;
			}
			if (strValue.indexOf("@") != strValue.lastIndexOf("@")) {
				alert("The Email address must contain only one @ character to be valid.")
				formobj.replyaddress.focus();
				return false;
			}
	}
	if (formobj.subject.value == "") {
		alert("Please enter a subject.");
		formobj.subject.focus();
		return false;
	}
	if (formobj.body.value == "") {
		alert("Please enter your message.");
		formobj.body.focus();
		return false;
	}
}
function ValidateUploadLocal()
{
	formobj=document.file_upload;
	if (formobj.File1.value == "") {
		alert("Please enter a file name");
		formobj.File1.focus();
		return false;
	}
	if (formobj.des.value == "") {
		alert("Please enter a file description");
		formobj.des.focus();
		return false;
	}
	if (formobj.consumer.value == "") {
		alert("Indicate if this should this be available to Consumers");
		formobj.consumer.focus();
		return false;
	}
	if (formobj.contractor.value == "") {
		alert("Indicate if this should this be available to Contractors");
		formobj.contractor.focus();
		return false;
	}
	if (formobj.specifier.value == "") {
		alert("Indicate if this should this be available to Specifiers");
		formobj.specifier.focus();
		return false;
	}
	return ProgressBar();
}
function ProgressBar() {
	var ProgressURL
	ProgressURL = 'upload_progress.asp?UploadID=<%=UploadID%>'
	var v = window.open(ProgressURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=700,height=350,top=50,left=50')
	return true;
}
function ValidateEditLocal()
{
	formobj=document.file_upload;
	if (formobj.url.value == "") {
		alert("Please enter a file name");
		formobj.url.focus();
		return false;
	}
	if (formobj.des.value == "") {
		alert("Please enter a file description");
		formobj.des.focus();
		return false;
	}
	if (formobj.consumer.value == "") {
		alert("Indicate if this should this be available to Consumers");
		formobj.consumer.focus();
		return false;
	}
	if (formobj.contractor.value == "") {
		alert("Indicate if this should this be available to Contractors");
		formobj.contractor.focus();
		return false;
	}
	if (formobj.specifier.value == "") {
		alert("Indicate if this should this be available to Specifiers");
		formobj.specifier.focus();
		return false;
	}
}
function confirmdelete(processurl){
	if (confirm("Click OK to delete the record, click CANCEL to keep the record")==false){
		return false;
	} else {
		location.href=processurl;
		return true;
	}
}
function resize(w,h) {
	window.resizeTo(w+8, h-20);
}
function openDir(form) {
	window.location =(form.dir.options[form.dir.selectedIndex].value);
}
function ValidateNewsForm()
	{
        formobj=document.searchnews;
	    if (formobj.search.value == "") {
	      alert("In order for us to process this enquiry, you must enter something");
	      formobj.search.focus();
	      formobj.search.blur();
	      formobj.search.select();
	      return false;
	    }
	}
function ValidateSendMail(){
	formobj=document.SendMailForm;
	if (formobj.txtEmailReply.value == "") {
		alert("The Email Address cannot be blank");
		formobj.txtEmailReply.focus();
		formobj.txtEmailReply.blur();
		formobj.txtEmailReply.select();
		return false;
	}
	if (formobj.txtEmailSubject.value == "") {
		alert("The Subject cannot be blank");
		formobj.txtEmailSubject.focus();
		return false;
	}
	if (formobj.txtEmailBody.value == ""){
		alert("The 'Body' of the email cannot be blank");
		formobj.txtEmailBody.focus();
		return false;
	}
}
function menu_goto()
{
	var SelectedItem;
	var gotourl;
	SelectedItem = document.getElementById("newurl").selectedIndex;
	gotourl = document.getElementById("newurl").options[SelectedItem ].value;
	document.location = gotourl;
}
function menu_search()
{
	var SelectedItem;
	if (document.getElementById("searchstring").value == ""){
		alert("The search string cannot be blank, please enter a value to search for");
		document.getElementById("searchstring").focus();
		return false;
	} else {
		SearchItem = document.getElementById("searchstring").value;
		document.location = "/common/search.aspx?SearchString=" + SearchItem;
		return true;
	}
}
function populate_search(searchstring)
{
    document.getElementById("searchstring").value = searchstring;
}
