//---- basic site-wide javascripts - Astor Services ---------------------------

function onOff(id, onoff) {
	if (el = document.getElementById(id)) {
		if (null==onoff) onoff = el.style.display=='none';
		el.style.display = (onoff ? '' : 'none');
	}	
		//-- when we add or remove content via js we need to re-adjust the height of content elements, therefor:
		setFooter();
}

function sH(id, showhide) {
	if (el = document.getElementById(id)) {
		if (null==showhide) showhide = el.style.visibility=='hidden'; 			
		el.style.visibility = (showhide ? '' : 'hidden');
	}
}

var whatsit = "@";
  secondbit = whatsit;
  anotherbit = "."+"or"+"g";
  male2 = "ma"+"ilt"+"o:";

//---- script for positioning footer at the very bottom ------------------
//------ courtesy A List Apart: http://www.alistapart.com/articles/footers/
//-------->> see init_default.js for window.onload init function:
//window.onload = init;
//function init() {
//			setFooter();
//		}
//-------->> or copy this and add it to init function list in the alternate js file: setFooter();
		function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setFooter() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentHeight = document.getElementById('page').offsetHeight;
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					if (windowHeight - (contentHeight + footerHeight) >= 0) {
						//footerElement.style.position='relative';
						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
						if (document.getElementById('sidebar-images')) {
		  				document.getElementById('sidebar-images').style.height = (windowHeight - 270) + 'px';
		  				}
					}
					else {
						footerElement.style.top = '0px';
						//footerElement.style.position='static';
						if (document.getElementById('sidebar-images')) {
		  				document.getElementById('sidebar-images').style.height = (contentHeight - 150) + 'px';
		  				}
					}
				}
		  	//document.getElementById('sidebar-images').style.height = (windowHeight - 270) + 'px';
		  	//document.getElementById('sidebar-images').style.height = (contentHeight - 100) + 'px';
			}
		}
		window.onresize = function() {
			setFooter();
}

//-- script for opening selected links in new windows in an XHTML compliant manner:
//-- Reference: http://www.sitepoint.com/article/standards-compliant-world/
//-- Reference: http://www.rossboardman.com/how-to/how-to-replace-target_blank-for-xhtml-strict
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors .length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
			}
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "pdf") {
			anchor.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (PDF file opens in a new window)" : "PDF file opens in a new window";
			anchor.className = (anchor.className != '') ? anchor.className+' pdf' : 'pdf';
		}
	}
}
//-------->> see init_default.js for window.onload init function:
//window.onload = init;
//function init() {
//			externalLinks();
//		}
//-------->> or copy this and add it to init function list in the alternate js file: externalLinks();
