// JavaScript Document
// Anthony Eggert - FT11 Interactive //
<!--
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+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
//-->
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
// 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");
        if (!relIndex) break;
        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();
}

function addClass(element, classN) {
	var classes = element.className.split(" ");
	var newClasses = '';
	
	for (var i = 0; i < classes.length; i++) {
		if (classN == classes[i]) {
			return;
		}
		newClasses += classes[i] + " ";
	}
	newClasses += classN + " ";
	element.className = newClasses;
}

function removeClass(element, classN) {
	var classes = element.className.split(" ");
	var newClasses = '';
	
	for (var i = 0; i < classes.length; i++) {
		if (classN == classes[i]) {
			continue;
		}
		
		newClasses += classes[i] + " ";
	}
	element.className = newClasses;
}

function hasClass(element, classN) {
	var classes = element.className.split(" ");
	for (var i = 0; i < classes.length; i++) {
		if (classN == classes[i]) {
			return true;
		}
	}
	return false;
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

function PopupPic(sPicURL, title) {
	newWindow = window.open('', "",  "HEIGHT=200,WIDTH=200,scrollbars=no");
	newWindow.document.open();
	newWindow.document.write("<HTML><HEAD><TITLE>" + title + "</TITLE><script language='javascript'>var arrTemp=self.location.href.split(\"?\");");
	newWindow.document.write("var picUrl = (arrTemp.length>0)?arrTemp[1]:\"\";var NS = (navigator.appName==\"Netscape\")?true:false;");
	newWindow.document.write("function FitPic() { iWidth = (window.innerWidth)?window.innerWidth - 5:document.body.clientWidth; iHeight = (window.innerHeight)?window.innerHeight:document.body.clientHeight;");
	newWindow.document.write("iWidth = document.images[0].width - iWidth; iHeight = document.images[0].height - iHeight; window.resizeBy(iWidth, iHeight); self.focus();};");
	newWindow.document.write("</script></HEAD><BODY onclick='window.close()' bgcolor='#000000' onload='FitPic();' style='margin:0;padding:0;overflow: hidden;'><script language='javascript'>");
	newWindow.document.write("document.write(\"<img src='" + sPicURL + "' border=0>\");</script></BODY></HTML>");
	newWindow.document.close();
	newWindow.focus();
} 

// EXECUTE ONLOAD FUNCTIONS
window.onload = abide;
