function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}

function submit_search() {
	document.forms["searchform"].submit();
}

function clear_searchbox() {
	getObj("search_string").value = ""
}

function enews_signup() {
	var newwin=window.open("enews-signup.asp","Enews_Signup", "width=400,height=300,locationbar=0,menubar=0,personalbar=0,status=1,scrollbars=1,resizable=1")
}

function calculate_total() {
	var filtertotal = getObj("filter_subtotal").value;
	var connectiontotal = getObj("connection_cost").value;
	//
	var nettotal = parseFloat(filtertotal) + parseFloat(connectiontotal);
	//
	getObj("total_cost").value = ""
	getObj("total_cost").value = nettotal.toFixed(2);
}

function set_filterprice() {
	var nofilters = document.forms['broadband_signup'].extra_filters.value;
	//
	//alert(nofilters)
	if (nofilters == '') {
		nofilters = 0
	}
	//
	var filtertotal = (nofilters * 4)
	//alert(nofilters + "------" + filtertotal)
	getObj("filter_subtotal").value = filtertotal.toFixed(2);
	//
	var total = calculate_total();
	//
}

function preload_image(imagename) {
	objImage = new Image();     
	objImage.src='graphics/' + imagename + "_on.jpg";
	//alert('graphics/' + imagename + "_on.jpg")
}

function changebox_bgcol(boxid, newcolour) {
	getObj(boxid).style.backgroundColor = newcolour;
}


function buttonOn(buttonID, image) {
	getObj("rollover_" + buttonID).src = "graphics/" + image + "_on.jpg";
}

function buttonOut(buttonID, image) {
	getObj("rollover_" + buttonID).src = "graphics/" + image + "_off.jpg";
}

function viewnews() {
	document.forms['view_newssection'].submit();
}

function viewmappage(pageid, pagename){
	document.location.href = pagename + '?pageid=' + pageid
}
function viewpage(pageid){
	var newwin=window.open("?pageid=" + pageid,"contact", "width=770,height=700,locationbar=0,menubar=0,personalbar=0,status=1,scrollbars=1,resizable=1")
}
function refreshjump(pageid){
	//
	var uniqueid = Math.round(Math.random() * 200000) + 1
	document.location="harrier-1-admin-pages.asp?ran=" + escape(uniqueid)
}

function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function checkEmail(email) {
	email = email.toLowerCase(); 
	if (email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) {
		return true;
	} else {
		return false;
	}
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function addbookmark(bookmarkurl, bookmarktitle) {
        window.external.AddFavorite(bookmarkurl, bookmarktitle);
}

function printPage() {
	//getObj("printHolder").style.display = "inline";
	//
	var printable_content = getObj("content_midcol").innerHTML;
	//
	if (printable_content == "") {
		var printable_content = "";
	}
	//
	logo = "<br>&nbsp;&nbsp;<img src=\"Graphics/logoheader_newtel.gif\" alt=\"Newtel Solutions Homepage\" width=\"195\" height=\"49\" border=\"0\"><Br>";
	//
	body2 = "<table width=\"500px\">";
	body2 += "<tr>";
	body2 += "<td valign=\"top\">" + printable_content + "</td></tr>";
	body2 += "<tr><td valign=\"top\"></td>";
	body2 += "</tr>";
	body2 += "</table>";
	// 
	getObj("printHolder").innerHTML = logo;
	getObj("printHolder").innerHTML += "<br><br>";
	getObj("printHolder").innerHTML += body2;
	//
	body3 = logo;
	body3 += "<BR><BR>";
	body3 += body2;
	//
	//var newwin=window.open("printpage.asp?con=" + body3,"Printing", "width=770,height=700,locationbar=0,menubar=0,personalbar=0,status=1,scrollbars=1,resizable=1")
	//
	print();
	getObj("printHolder").style.display = "none";
	getObj("site_holder").style.display = "inline";	
	//
}

function printResetPage() {
	// this reset the page by making the master div visible and emptying the printholder then hidig it
	getObj("printHolder").innerHTML = "";
	getObj("printHolder").style.display = "none";
	getObj("site_holder").style.display = "inline";	
	alert("test")
}



function show_selectedprice(prefix, price) {
	
	document.forms['broadband_signup'].connection_cost.value = price.toFixed(2);
	//selected_connectiontype
	//alert(cost)
	var total = calculate_total();
}

function checkEmail(email)
{
	email = email.toLowerCase(); 
	//rics super cool e-mail validor
	if (email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/)) {
		return true;
	} else {
		return false;
	}
}

//	Form Validation Code

function validatechangeofaddress() {
	valid = 1;
	message = "You have not completed all the required fields, please check:\n";
	formName = document.forms["coa_form"];
	
	//alert(formName.elements['signup_firstname'].value)
	
	if (checkEmail(formName.elements["email_address"].value) == false) {
		valid = 0;
		message += "Your Email Address\n";
		getObj("email_address").style.border = "#000000 solid 1px";
	} else {
		getObj("email_address").style.border = "#e5e7e7 solid 1px";
	}

	if (formName.elements['name'].value == "") {
		valid = 0;
		message += "Your Name\n";
		getObj("name").style.border = "#000000 solid 1px";
	} else {
		getObj("name").style.border = "#e5e7e7 solid 1px";
	}

	if (formName.elements["user_name"].value == "") {
		valid = 0;
		message += "Your User Name\n";
		getObj("user_name").style.border = "#000000 solid 1px";
	} else {
		getObj("user_name").style.border = "#e5e7e7 solid 1px";
	}
	
	if (formName.elements["present_phone"].value == "") {
		valid = 0;
		message += "Your Present Telephone Number\n";
		getObj("present_phone").style.border = "#000000 solid 1px";
	} else {
		getObj("present_phone").style.border = "#e5e7e7 solid 1px";
	}

	if (formName.elements["new_address"].value == "") {
		valid = 0;
		message += "Your New Address\n";
		getObj("new_address").style.border = "#000000 solid 1px";
	} else {
		getObj("new_address").style.border = "#e5e7e7 solid 1px";
	}
	
	if (formName.elements["new_postcode"].value == "") {
		valid = 0;
		message += "Your New Postcode\n";
		getObj("new_postcode").style.border = "#000000 solid 1px";
	} else {
		getObj("new_postcode").style.border = "#e5e7e7 solid 1px";
	}
	
	if (valid == 0) {
		alert(message);
	} else {
		formName.submit();
	}
}