/*
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 emailINFO = "info";
var theamp = "&#64;";
var thedot = "&#46;";
var eaddress = "info"  + theamp + "eartharomas" + thedot + "com" + thedot + "au";

function insert_paypal_business_field() {
	document.write ('<input type="hidden" name="business" value="info@eartharomas.com.au">');	
}	// ENDOF insert_paypal_business_field() 

function picframe(image, alignment) {
	document.write('<table cellpadding="0" cellspacing="0" border="0" align="' + alignment + '"><tr>');
	if (alignment == 'right') document.write ('<td width=20><img src="img/spacer.gif" width="20" height="2" alt=""></td>');
	document.write('<td><table cellpadding="0" cellspacing="0" border="0"');
	document.write('<tr><td width="29" height="29"><img src="img/fr_tlcnr.gif" width="29" height="29" alt=""></td><td height="29" background="img/fr_top.gif"></td><td width="29" height="29"><img src="img/fr_trcnr.gif" width="29" height="29" alt=""></td></tr>');
	document.write('<tr><td width="29" background="img/fr_lft.gif"></td><td>');
	document.write( image );
	document.write('</td><td width="29" background="img/fr_rgt.gif"></td></tr>');
	document.write('<tr><td width="29" height="29" ><img src="img/fr_blcnr.gif" width="29" height="29" alt=""></td><td height="29" background="img/fr_btm.gif"></td><td width="29" height="29"><img src="img/fr_brcnr.gif" width="29" height="29" alt=""></td></tr>');
	document.write('</table></td>');
	if (alignment == 'left') document.write ('<td width=20><img src="img/spacer.gif" width="20" height="2" alt=""></td>');
	document.write('</tr></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>' ); 
}
//  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  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() - 500;
	scrolling_height =  content_height;
	// now set scrolling cell fill height for left hand scroll column
	scrolling_height = content_height  - PromoBoxHeight ;	//  remove height consumed by promo boxes
	document.getElementById('left_scroll_cell').innerHTML = '<img src="http://middlepath.com.au/img/spacer.gif" width="150" 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>' ); 
}

