function flashThoseTags(aTag, aSWF) {
	tagArray = document.getElementsByTagName(aTag);
	
	// Loop backwards through array of tags. *see footnote
	for (i=tagArray.length-1; i>=0; i--) {
		var parameters = "?";
		theTag = tagArray[i];
		theColor = "";
		theWidth = theTag.parentNode.scrollWidth;
		if (document.defaultView) {
			theColor = document.defaultView.getComputedStyle(theTag, null).getPropertyValue("color").replace(/[a-z()]/gi,"");
			splitColor = theColor.split(',');
			theColor = DecToHex(splitColor[0],splitColor[1],splitColor[2]);
		}
		if (theTag.currentStyle) {
			theColor = theTag.currentStyle.color.replace("#","");
		}
		parameters += "mainColor=0x"+theColor;
		parameters += "&theText="+theTag.innerHTML;
		replaceTag = document.createElement("div");
		replaceTag.innerHTML = writeFlash(aSWF+parameters, 35, theWidth, "transparent", "");
		theTag.parentNode.replaceChild(replaceTag,theTag);
	}
}

function flashThatMenu(parentObject, aSWF) {
	
	count = 0;
	theParentObject = document.getElementById(parentObject);
	
	for (i=0;i<theParentObject.childNodes.length; i++) {
		if (theParentObject.childNodes[i].className == "active")
			theActiveObject = theParentObject.childNodes[i];	
	}
	
	if (typeof theActiveObject  == 'undefined') {
		theActiveObject = theParentObject.childNodes[1];
	}
	
	var parameters = "?";
	
	
	if (document.defaultView) {
		theColor = document.defaultView.getComputedStyle(theParentObject, null).getPropertyValue("background-color").replace(/[a-z()]/gi,"");
		splitColor = theColor.split(',');
		theColor = DecToHex(splitColor[0],splitColor[1],splitColor[2]);
		
		theFontColor = document.defaultView.getComputedStyle(theActiveObject.firstChild.firstChild, null).getPropertyValue("color").replace(/[a-z()]/gi,"");
		splitColor = theFontColor.split(',');
		theFontColor = DecToHex(splitColor[0],splitColor[1],splitColor[2]);
	}
	if (theParentObject.currentStyle) {
		theColor = theParentObject.currentStyle.backgroundColor.replace("#","").toUpperCase();
	
		theFontColor = theActiveObject.firstChild.firstChild.currentStyle.color.replace("#","");		
	}

	parameters += "mainColor=0x"+theColor;
	parameters += "&activeColor=0x"+theFontColor;
	
	tagArray = theParentObject.getElementsByTagName("LI");
	// Loop trough 
	for (i=0; i < tagArray.length; i++) {
		
		if (tagArray[i].parentNode.id != "leftNav" && tagArray[i].parentNode.parentNode.className != "active") {
			//do nothing
		
		}
		else {
		
		
		parameters += "&";
		parameters += "item" + count + "=";
		parameters += tagArray[i].firstChild.firstChild.innerHTML + "|";
		parameters += escape(tagArray[i].firstChild.href) + "|";
		if (tagArray[i].className == "active")
			parameters += "1|";
		else
			parameters += "0|";
		if (tagArray[i].parentNode.id == "leftNav")
			parameters += "0|";
		else
			parameters += "1|";
		count++;
		
		
		}
	}
	parameters += "&count="+count;
	replaceTag = document.createElement("div");
	replaceTag.id = "flashNav";
	replaceTag.innerHTML = writeFlash(aSWF+parameters,1, 182, "transparent", "");
	theParentObject.parentNode.replaceChild(replaceTag,theParentObject);
	
	
}

function setFlashHeight(aID, aHeight) {
	
	//alert('test');
	
	flashContainer = document.getElementById("flashNav");
	flashObject = flashContainer.getElementsByTagName('object')[0];
	flashObject.height = aHeight;
	
	if (flashContainer.getElementsByTagName('embed').length > 0) {
		flashEmbed = flashObject.getElementsByTagName('embed')[0]; 
		flashEmbed.height = aHeight;	
	}
	
	//liElement.style.visibility = "visible";
}



function pausecomp(millis)
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
} 


function writeFlash(StrFileName, intHeight, intWidth, strWmode, strArgs){
	
	returnString = "";
	
    returnString += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
    returnString += " codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'";
    returnString += " width='" + intWidth + "' height='" + intHeight + "'>";
    returnString += "<param name='menu' value='false'>";
    returnString += "<param name='wmode' value='" + strWmode + "'>";
    returnString += "<param name='salign' value='tl'>";
    returnString += "<param name='flashVars' value='" + strArgs + "'>";
    returnString += "<param name='movie' value='" + StrFileName + "'>";
    returnString += "<param name='quality' value='high'>";
    returnString += "<embed src='" + StrFileName + "' flashVars='" + strArgs + "' salign='tl' menu='false' wmode='" + strWmode + "' quality='high'";
    returnString += " pluginspage='http://www.macromedia.com/go/getflashplayer'";
    returnString += " type='application/x-shockwave-flash' width='" + intWidth + "' height='" + intHeight + "'></embed></object>";
	
	return returnString;
}


/* Script by Jim Stiles 01.12.2001 jdstiles.com
   http://www.jdstiles.com
*/
function GiveHex(Dec)
{
   if(Dec == 10)
      Value = "A";
   else
   if(Dec == 11)
      Value = "B";
   else
   if(Dec == 12)
      Value = "C";
   else
   if(Dec == 13)
      Value = "D";
   else
   if(Dec == 14)
      Value = "E";
   else
   if(Dec == 15)
      Value = "F";
   else
      Value = "" + Dec;

   return Value;
}


function DecToHex(aRed, aGreen, aBlue)
{
   Red = aRed
   Green = aGreen
   Blue = aBlue

   a = GiveHex(Math.floor(Red / 16));
   b = GiveHex(Red % 16);
   c = GiveHex(Math.floor(Green / 16));
   d = GiveHex(Green % 16);
   e = GiveHex(Math.floor(Blue / 16));
   f = GiveHex(Blue % 16);

   z = a + b + c + d + e + f;

   return z;
}

function initJifr() {
		//pausecomp(7000);
		if (hasReqestedVersion) {  // if we've detected an acceptable version call the jifr
		
		document.getElementById("header").innerHTML = writeFlash("/flash/header.swf?mainColor=0x0790c7&secondColor=0x99CDE2", 226, 983, "transparent", "");
		flashThoseTags('h1', "/flash/heading.swf");
		//flashThatMenu("leftNav", "/flash/menu.swf");
	
	}
}

//just a tester to see if waiting before we did the replacement would so anything.  the answer is no.
function pausecomp(millis)
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
}

function initMaster() {
	initLightbox();
	initJifr();
}
window.onload=function(){
	initJifr();
}
