//This is the master JavaScript file for Matthew S. Harris Business pages.
// Copyright (c) 2011 by Matthew S. Harris


/* Make an element visible or invisible -- used to toggle fly-out/popup elements on mouse over/out */
function showIt(mname) { document.getElementById(mname).style.display = "inline"; }
function hideIt(mname) { document.getElementById(mname).style.display = "none"; }
//------

/* toggle visibility of the section, plus change an associated graphic -- used for popup elements displayed by clicking */
function showToggleG(xsection, xgraphic) {
	if (document.getElementById(xsection).style.display=="none") { //expand
		document.getElementById(xsection).style.display="inline"; 
		document.getElementById(xgraphic).src="../images/arrowdn.gif"}
	else { //collapse
		document.getElementById(xsection).style.display="none"; 
		document.getElementById(xgraphic).src="../images/arrowrt.gif"}
}//------

/* toggle visibility of an element on mouse over/out -- used specifically for the book list */
function bk_show(sbook) {
	document.getElementById(sbook).style.display = "inline";
	document.getElementById(sbook + "_cell").style.background="#CCCCCC";}
function bk_hide(sbook) {
	document.getElementById(sbook).style.display = "none";
	document.getElementById(sbook + "_cell").style.background="";}
//------

/* Preload images for pages with image whose source changes on mouse over/out */
function preloadImages() {
  var d=document; 
  if(d.images){ 
    if(!d.pli_p) d.pli_p=new Array();
    var i,j=d.pli_p.length,a=preloadImages.arguments; 
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.pli_p[j]=new Image; d.pli_p[j++].src=a[i];}}}
/* exchange a graphic on mouse over/out */
function swapImgRestore() { var i,x,a=document.swi_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; }
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.swi_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.swi_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}
function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;}

