// Basic js functions used throughout site for picture framing and page scrolling
TRACE = false;	// set false for production, turns on trace displays

function picframe2(image) {
	if (caption) document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td align="center">');
	document.write('<table border="3" bordercolor="#999900" bordercolordark="#996600" bordercolorlight="#CCCC00" bgcolor="#ff9900"><tr><td><table border="3" bordercolor="#FFFF00" bordercolordark="#FFCC00" bordercolorlight="#FFFF00"><tr><td>' + image + '</td></tr></table></td></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>' ); 
}
// 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 to toggle (hide<> show a div by clicking on a link
  the anchor  looks like <a id="view_pano" href="javascript:toggle_div('view_pano','pano_div');"> where 'pano_div' is the id of the div to hide/show
  the text for cell should indicate what will happen when it is clicked
*/
function toggle_div(anchor_id, div_id) {
	var the_div = document.getElementById(div_id);
	var the_anchor = document.getElementById(anchor_id);
	if(the_div.style.display == "block") {
		the_div.style.display = "none";
		the_anchor.innerHTML = "click to view";
  	}
	else {
		the_div.style.display = "block";
		the_anchor.innerHTML = "click to hide";
	}
} 

/*
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"; }
}




