Initialise();
function Initialise() {
	CheckFrameset();
	if(document.all) {
		attachEvent("onload", FixedSidePanelRightMargin);
		attachEvent("onunload", OnContentChange);
	}
}

// if have accessed content page directly instead of via frameset, load in frameset (but not for 'localhost')
function CheckFrameset() {
	if(top.location.hostname == "localhost") return;
	
	if(top.location.pathname && (top.location.pathname != "/default.asp") && (top.location.pathname != "/"))
		top.location = "/default.asp?content=" + location.pathname;
}

// fired when content changes
function OnContentChange() {
}

// To workaround IE6 (+ other?) rendering bugs on window resize, convert side panel right margin from dynamic 
//	expression to fixed size once window has loaded
function FixedSidePanelRightMargin() {
	if(typeof sidePanel != "undefined") {
		var iSidePanelRightMargin = sidePanel.style.marginRight;
		sidePanel.style.removeExpression("marginRight");
		sidePanel.style.marginRight = iSidePanelRightMargin;
	}
}


// makes specified email address the "mailto" href for the specified A element
//	- use to create spam proof e-mail address:	EmailLink("myLink", "b"+"@"+"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 : "";
	emailLink.href = "mailto:" + sEmailAddress + sSubject;
	if(emailLink.innerHTML == "") emailLink.innerHTML = sEmailAddress;
}
// shortcut to EmailLink: only have to provide e-mail username instead of full address
//	- will assume e-mail address in form username @ cerneygardens.com
function ChgEmailLink(sLinkId, sEmailUsername, sSubject) {
	if(typeof sEmailUsername != "string") sEmailUsername = "enquiries";		// default to enquiries@
	EmailLink(sLinkId, sEmailUsername +"@"+"cerneygardens.com", sSubject);
}

function LoadFlash(sXmlFile1, sXmlFile2) {
	//window.status = "content.js LoadFlash('"+ sXmlFile1 +"','"+ sXmlFile2 +"')";
	if(document.all)
		if(top.document.readyState == "complete")
			top.LoadFlash(sXmlFile1, sXmlFile2);
		else
			top.attachEvent("onload", function() { top.LoadFlash(sXmlFile1, sXmlFile2) } );
}
