// JavaScript Document
// Anthony Eggert - FT11 Interactive //
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" alt=\"'+alt+'\" id="imagePage">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
//-->

// SELECT BOX NAVIGATION  //
// - http://www.quirksmode.org/js/select.html //

function go()
{
	box = document.forms[0].navi;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

//*****************************\\ ONLOAD FUNCTIONS //*****************************//

// JAVASCRIPT FIR
// http://www.quirksmode.org/dom/fir.html
function jfir()
{
	var W3CDOM = (document.createElement && document.getElementsByTagName);
	if (!W3CDOM) return;
	var test = new Image();
	var tmp = new Date();
	var suffix = tmp.getTime();
	test.src = 'assets/img/fir_test.gif?'+suffix;
	test.onload = imageReplacement;
}

function imageReplacement()
// define replaced tags here //
{
	replaceThem(document.getElementsByTagName('h3'));
}

function replaceThem(x)
{
	var replace = document.createElement('img');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id)
		{
			var y = replace.cloneNode(true);
			y.src = 'assets/img/' + x[i].id + '.gif';
			y.alt = x[i].firstChild.nodeValue;
			x[i].replaceChild(y,x[i].firstChild);
		}
	}
}

// EXTERNAL LINKS
// loads links in new windows when designated by the rel="ext" attribute

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") == "ext")
            anchor.target = "_blank";
    }
}

// POPUP LINKS
// loads links in new windows when designated by the rel="pop" attribute
// rel example: rel="pop|600|400|1|0" = 600 width, 400 height, resizable: yes, scrollbars: no
function popupWin(link, attribs)
{
    var popupWin = null;
    popupWin = window.open(link, 'winPopup', attribs);
}

function popupWindows()
{
    if (!document.getElementsByTagName)
    {
        return ;
    }
    var scrW = screen.availWidth;
    var scrH = screen.availHeight;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++)
    {
        var anchor = anchors[i];
        var linkDest = anchor.getAttribute("href");
        var relIndex = anchor.getAttribute("rel");
        var relSplit = relIndex.split("|");
        var windowAttributes = "";
        if (relSplit[0] == "pop")
        {
            if (relSplit[1] > scrW)
            {
                pW = scrW - 10;
            }
            else
            {
                pW = relSplit[1];
            }
            if (relSplit[2] > scrH)
            {
                pH = scrH - 40;
            }
            else
            {
                pH = relSplit[2];
            }
            scrX = (scrW - pW - 10) * .5;
            scrY = (scrH - pH - 30) * .5;
            var windowAttributes = "width=" + pW + ",height=" + pH + ",left=" +
                scrX + ",top=" + scrY + ",screenX=" + scrX + ",screenY=" + scrY;
            windowAttributes += ",location=" + relSplit[4] + ",resizable=" +
                relSplit[3] + ",scrollbars=" + relSplit[4];
            anchor.setAttribute("href", "javascript:popupWin('" + linkDest +
                "','" + windowAttributes + "')");
        }
    }
}
// ABIDE
// ties all unloads together
function abide()
{
   	jfir();
	externalLinks();
    popupWindows();
}

// EXECUTE ONLOAD FUNCTIONS
window.onload = abide;
