window.defaultStatus = "";
CheckFrameset();

// script executed once page loaded
window.onload = function OnLoad() {
	// check first H1 heading on page - if has wrapped to more than one line, reduce letter spacing
	var aH1s = document.getElementsByTagName("H1");
	if(aH1s[0] && (aH1s[0].offsetHeight > 60)) aH1s[0].style.letterSpacing = '0.1em';
}

// if content page accessed directly, load in site frameset instead
function CheckFrameset() {
	if((top.location == document.location) && (top.location.href.indexOf("dbg=")==-1))
		top.location = "index.asp?ContentURL=" + encodeURI(document.location.pathname);
}

window.onerror = function(sMsg,sUrl,sLine) { window.status = "Err: "+sMsg; return true; }

function Ptr(sId) { if(!window[sId]) window[sId] = document.getElementById(sId); return window[sId]; }

// Submit specified form, after dynamically adding "submitVerified" field with value "verified"
//	This prevents automated Spam Bots that don't understand Javascript from submitting form
function VerifiedSubmit(form) { 
	var inpVerify = document.createElement("input");
	inpVerify.type = "hidden";
	inpVerify.name = "submitVerified";
	inpVerify.value = "verified";
	form.appendChild(inpVerify);
	form.submit(); 
}

function EmailThisPage() {
	document.location = "emailPage.asp?pageURL="+ encodeURI(document.location) +"&pageTitle="+ document.title;
	return false;
}

// makes specified email address the "mailto" href for the specified A element
//	- use to create spam proof e-mail address:	EmailLink("myLink", "b[A]chg.com")
//	- if element's innerHTML is empty, is also replaced with specified e-mail address
function EmailLink(sLinkId, sEmailAddress, sSubject) {
	var emailLink = document.getElementById(sLinkId);
	sSubject = (typeof sSubject == "string")? "?subject=" + sSubject : "";
	sEmailAddress = sEmailAddress.replace("[AT]", "@");
	emailLink.href = "mailto:" + sEmailAddress + sSubject;
	if(emailLink.innerHTML == "")
		emailLink.innerHTML = sEmailAddress;
	else
		emailLink.innerHTML = emailLink.innerHTML.replace("[AT]", "@");
}

