/*  dynadiv.js -  author Eamon Byrne */

var browsertype = 0; // 0=ie   1=opera  2= firefox
var currentfont = "10pt"	// default
var prevnode=0;
var h, v;
var header="";
var footer="";
var block="";
var mousecheck = "if(checkmouseout(this,event)){this.style.visibility='hidden';};"
var horizmenu = ["horiz1", "horiz2", "horiz3", "horiz4"];
horizmenu[0] = new Array("horiz1");			  // 1st item is the horiz menu div
horizmenu[1] = new Array("horiz2");
horizmenu[2] = new Array("horiz3");
horizmenu[3] = new Array("horiz4");

// the  containing divs for the vertical menu blocks
var vertmenu =["vert1", "vert2", "vert3", "vert4"];
// div caption	  access with  captions[h][v]
var caption = ["cap1", "cap2", "cap3", "cap4"];
caption[0] = new Array(" home ","&nbsp; google", "&nbsp; tpg", "&nbsp; atp tennis");
caption[1] = new Array(" about us","&nbsp; w3c", "&nbsp; edit styles", " &nbsp;color chart", "&nbsp; web ref");
caption[2] = new Array(" services","&nbsp; web ref", "&nbsp; literals", "&nbsp; ulist");
caption[3] = new Array("contact ","&nbsp; execCom", "&nbsp; Powell");

// actions	   access with  action[h][v]
var action =  ["act1", "act2", "act3", "act4"];
action[0] = new Array( " onmouseover=\"unhide('vert1');\"",
				 "",
				 "",
				 "");

 action[1] = new Array(" onmouseover=\"unhide('vert2');\"",
				 "",
				 "",
				 "",
 				 "");

action[2] = new Array( " onmouseover=\"unhide('vert3');\"",
				 "",
				 "",
				 "");

 action[3] = new Array(" onmouseover=\"unhide('vert4');\"",
				 "",
				 "");

// targets
var target = ["targ1", "targ2", "targ3", "targ4"];
target[0] = new Array( 
				  "index.htm\" target=\"_top",
				  "",
                  "",
				  "#");

 target[1] = new Array(
				  "aboutus.htm\" target=\"_top",
				  "",
                  "",
				  "",
				  "");
 target[2] = new Array(
				  "services.htm\" target=\"_top", 
				  "",
                  "",
				  "");
				  
 target[3] = new Array("contacts.htm\" target=\"_top",
				  "",
				  "");

//divclass
var divclass = ["divclass1", "divclass2","divclass3", "divclass4"];

divclass[0] = new Array("toolmenu", "links", "links", "links");
divclass[1] = new Array("toolmenu", "links", "links", "links", "links");
divclass[2] = new Array("toolmenu", "links", "links", "links");
divclass[3] = new Array("toolmenu", "links", "links");

//aclass
var aclass = ["aclass1", "aclass2","aclass3", "aclass4"];

aclass[0] = new Array("class=\"toolLink\"", " ", " ", " ");
aclass[1] = new Array("class=\"toolLink\"", " ", " ", " ", " ");
aclass[2] = new Array("class=\"toolLink\"", " ", " ", " ");
aclass[3] = new Array("class=\"toolLink\"", " ", " ");

h=0; v=0;

 function showdivelements (hor,ver)
 {
	 h=hor;
	 v=ver;
	 document.write (horizmenu[h][v] +"<br>" );
	 document.write (caption[h][v] +"<br>" );
	 document.write (action[h][v] +"<br>" );
	 document.write (target[h][v] +"<br>" );
	 document.write (divclass[h][v] +"<br>" );
	 document.write (aclass[h][v] +"<br>" );
	 
 }

function buildsamplediv() 			
{
 for (h=0; h<horizmenu.length; h++)
	{
     for (v=0; v<horizmenu[h].length; v++)
	 {
		 // if v==1 build the header of the div containing the vertical menu divs
		 // if v==0 we're writing the div on the horizontal menu bar
		 if (v==0)
		 {
		  header =writemenuheader(h);
		  block += header;
		 }
         var divstring=
	       "<div id=\"" + 
            horizmenu[h][v] + "\"" +              

            " name=\"" + 
             horizmenu[h][v] + "\""  +           

            " class=\"" + 
            divclass[h][v] + "\""  +              

            "><a "  + 
            aclass[h][v] +                         

             " href=\""  + 
             target[h][v] + "\""  +               
                                                        

             action[h][v] +                        

              ">" 	+

               caption[h][v] +    

               "</a></div>" ;

		    document.write(divstring);
			block += divstring;
			// if this is the last vertical div for this h block, write the containing block's footer
			if (v==horizmenu[h].length -1)
				{
				 footer=writemenufooter(h);
				}
			}	  // end v loop
	}			   // end h loop
}

function writemenuheader(h)
	{
	var header="";
	header= "<div id=\"" + 	 vertmenu[h] + "\"" +   " class=\"links\"" +
	" onmouseout =\"" + mousecheck +" \"" + ">";
	document.write (header);
	return header;
	}
function writemenufooter(h)
	{
	var footer="</div>";
	document.write (footer);
	return footer;
	}


 function unhide (id)
 {
	var nodeObj = document.getElementById(id);
	nodeObj.style.visibility = 'visible';
 }

 function hide (id)
 {
	var nodeObj = document.getElementById(id);
	nodeObj.style.visibility = 'hidden';
	//alert (id);
 }

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

 function checkmouseout (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function swappics(flag,id)
{
  var nodeObj = document.getElementById(id);
			if (flag==0)
			{
				nodeObj.style.zIndex = 10;
				nodeObj.style.visibility = 'visible';
			}
			    else 
				{
					nodeObj.style.zIndex=0;
					nodeObj.style.visibility = 'hidden';
				}
}

function detectbrowser()
{
	var useragent = navigator.userAgent;
	if (useragent.indexOf ("Firefox") > 0)
		browsertype=0;
	    else if (useragent.indexOf ("Opera") > 0)
			      browsertype=1;
		          else browsertype=0;
        readcookie();				  // to get correct value of currentfont
}

function readcookie()
				{	
					var fontsize = 0;
					var passed=document.cookie;		  // eg   "cf=13"
					if (passed)
					{
					  fontsize = parseInt(passed.substr (3,4)) + browsertype;
					  currentfont = fontsize + "pt";		// eg  "13pt"
					}
					else currentfont = 10 + browsertype + "pt";
				}

function showlinks(id)
	{
		var styleob = 	document.getElementById('content');
		if (document.getElementById)							
		{
			if (prevnode !=0)											// = 0 when site first loads
				prevnode.style.visibility = "hidden";
			var nodeObj = document.getElementById(id);
			prevnode = nodeObj;									   // from now on prevnode is an pbject
			nodeObj.style.visibility = 'visible';
		}
	}	

	function hidelinks()
	{
		var styleob = 	document.getElementById('content');
		if (prevnode)
		{
			prevnode.style.visibility = "hidden";
			prevnode=0;
		}
	}
