/*
This is for the January, 2011 upgrade to XHTML doctype, created 17jan2011
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
*/
// Variable used to turn on and off execution tracing with window.alerts
TRACE = false;	// set false for production, turns on trace displays
//TRACE = true;	// set false for production, turns on trace displays

// email variables used to make email links:
var emailMP = "MP";
var emailMPO = "MPO";
var theamp = "&#64;";
var thedot = "&#46;";
var MPeaddress = "mp"  + theamp + "middlepath" + thedot + "com" + thedot + "au";
var MPOeaddress = "fergus" + theamp + "middlepathonline" + thedot + "com";
// Basic js functions used throughout site for picture framing and page scrolling
function scrollwindowup() {
	scrollBy (0,-25);
}
function scrollwindowdown() {
	scrollBy (0,1);
}
function returntotopofpage()	{	// not needed - left for legacy
	clearInterval(scrollup);
	scrollTo(0,0);
}

function picframe(image, caption) {
	if (caption) document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td align="center">');
	document.write('<table border="3" bordercolor="#0066cc" bordercolordark="#003366" bordercolorlight="#0099ee" bgcolor="#0000ff"><tr><td><table border="3" bordercolor="#eeeeee" bordercolordark="#cccccc" bordercolorlight="#ffffff"><tr><td>' + image + '</td></tr></table></td></tr></table>' );
	if (caption) document.write('</td></tr><tr><td align="center" class="caption">' + caption + '</td></tr></table>' );
}

function picframePRE() {
	document.write('<table border="3" bordercolor="#0066cc" bordercolordark="#003366" bordercolorlight="#0099ee" bgcolor="#0000ff"><tr><td><table border="3" bordercolor="#eeeeee" bordercolordark="#cccccc" bordercolorlight="#ffffff"><tr><td>');
}
function picframePOST() { 
	document.write('</td></tr></table></td></tr></table>' );
}
function picframegilt(image, alignment) {
	document.write('<table cellpadding="0" cellspacing="0" border="0" align="' + alignment + '">' );
	document.write('<tr><td width="29" height="29" background="' + menubase + 'img/fr_tlcnr.gif"><img src="' + menubase + 'img/spacer.gif" width="29" height="29"></td>	<td height="29" background="' + menubase + 'img/fr_top.gif"></td>	<td width="29" height="29" background="' + menubase + 'img/fr_trcnr.gif"><img src="' + menubase + 'img/spacer.gif" width="29" height="29"></td></tr>' );
	document.write('<tr><td width="29" background="' + menubase + 'img/fr_lft.gif"></td><td>' );
	document.write(image);
	document.write('</td><td width="29"  background="' + menubase + 'img/fr_rgt.gif"></td></tr>' );
	document.write('<tr><td width="29" height="29"  background="' + menubase + 'img/fr_blcnr.gif"><img src="' + menubase + 'img/spacer.gif" width="29" height="29"></td><td height="29" background="' + menubase + 'img/fr_btm.gif"></td><td width="29" height="29" background="' + menubase + 'img/fr_brcnr.gif"><img src="' + menubase + 'img/spacer.gif" width="29" height="29"></td></tr>' );
	document.write('</table>' );
}

function email_link(text,subject,body)	{// insert email link
	document.write ( '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#109;&#112;&#64;&#109;&#105;&#100;&#100;&#108;&#101;&#112;&#97;&#116;&#104;&#46;&#99;&#111;&#109;&#46;&#97;&#117;' );
	document.write ( '?subject=' + subject + '&body=' + body + '">' + text + '</a>' ); 
}

function email_link_white()	{// insert email link
	document.write ( '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#109;&#112;&#64;&#109;&#105;&#100;&#100;&#108;&#101;&#112;&#97;&#116;&#104;&#46;&#99;&#111;&#109;&#46;&#97;&#117;' );
	document.write ( '?subject=Website contact&body=Hello - I am looking at your website and " class="white">' + MPeaddress + '</a>' ); 
}
//  insert workshop details in table once button clicked on workshop pages
function filldetails_old()	{
	document.all.datecell.innerHTML	= dates_vb[0] + "<br>" + dates_vb[1] + "<br>" + dates_vb[2];
	document.all.requirements.innerHTML	= requirements['vb'];	
	document.all.costcell.innerHTML	= "AUD$" + workshop_costs['vb'] + ":00";
}
// routines to return window size
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}


	
function hideDiv( divid) { // hide the div
		if ( document.all ) eval( "document.all." + divid + ".style.display = 'none'"); //IS IE 4 or 5 (or 6 beta) 
		if ( document.layers ) document.layers[divid].display = 'none'; //IS NETSCAPE 4 or below 
		if ( document.getElementById && !document.all ) document.getElementById(divid).style.display = 'none'; //everything else
	}	// END function hideDiv
		
function showDiv( divid) { // unhide/show the div
		if (document.all)  eval( "document.all." + divid + ".style.display = 'block'");  //IS IE 4 or 5 (or 6 beta) 
		if (document.layers) document.layers[divid].display = 'block';  //IS NETSCAPE 4 or below 
		if (document.getElementById &&!document.all) 	document.getElementById(divid).style.display = 'block';  //everything else
	} 	// END function showDiv
	

function  set_Scroll_Cell_Heights () {	//  MUST BE CALLED after page load to return valid values
//  sets scrolling heights of sidebars using transparent gif to force cell heights to height of document content
//  measures content height using element height of cell 	<td id="content_cell" valign="top"> at bottom of file Aa_pagetop.php 
//	weakness may be the erratic result returned by function getElementHeight for different browsers..........
	content_height = getElementHeight('content_cell')
	// set scrolling heights for side bars
	content_height =  getDocHeight() - 850;
	scrolling_height =  content_height;
	// now set scrolling cell fill height for left hand scroll column
	scrolling_height = content_height ;	//  remove height consumed by left menu
	document.getElementById('left_scroll_cell').innerHTML = '<img src="http://middlepath.com.au/img/spacer.gif" width="120" height="' + scrolling_height + '" border="0">';

	// now set scrolling cell fill height for right hand scroll column
	scrolling_height =  content_height;
// share buttons have been replaced	if (ShareButtonsShowing) scrolling_height =  content_height - 300;
	document.getElementById('right_scroll_cell').innerHTML = '<img src="http://middlepath.com.au/img/spacer.gif" width="50" height="' + scrolling_height + '" border="0">';
	return;
}

function getElementHeight(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	xPos = elem.offsetHeight;
	return xPos; 
}

/*
This section to pop up image via <div> with cursor at top left on mouseover of image (or whatever ) call is ShowContent ('div name');
Copyright 2006,2007 Bontrager Connection, LLC
 http://bontragerconnection.com/ and http://willmaster.com/
Version: July 28, 2007
*/
var cX = 0; var cY = 0; var rX = 0; var rY = 0;

function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}

function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
		}
	else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
		}
	else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
		}
	if(document.all) {
		cX += rX; 
		cY += rY;
		}
	d.style.left = (cX+10) + "px";
	d.style.top = (cY+10) + "px";
}

function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	dd.style.display = "block";
}

function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	if(dd.style.display == "none") { dd.style.display = "block"; }
	else { dd.style.display = "none"; }
}


function convert (amount)    { //  pops up a fieba currency conversion window for AUD$amount wasin anu pages
	PopupWindow = window.open ('', 'fieba', 'toolbar=0,location=0,resizable=1,height=220,width=350')
	PopupWindow.focus()
	PopupWindow.location.href = "http://64.225.125.88:8080/fieba/preset.jsp?FI_from=USD" + "&FI_to=AUD&FI_inputAmount=" + amount
	return true;
}

function write_elink ( recipient, linkclass, linktitle ,  esubject, ebody  ) {	
/*function to write email link with 
recipient MUST = "MP" for middlepath address OR MPO for Middle Path Online addressee
<a .... class=class
title - is text displayed for link
subject = subject for email
body = email body
*/
	document.write ( '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;');
	if (recipient == emailMP ) document.write ( MPeaddress );
	if (recipient == emailMPO ) document.write ( MPOeaddress );
	
	
	document.write ( '?subject=' + esubject + '&body=' + ebody + '" class="' + linkclass + '">' + linktitle + '</a>' ); 
}

