

/* Loads Flash Intro */
function writeFlashIntro(){
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="1100" HEIGHT="588">');
		document.write('<param name="movie" value="intro.swf">');
		document.write('<param name="quality" value="high">');
		document.write('<param name="scale" value="noscale">');
		document.write('<param name="bgcolor" value="#999966">');
		document.write('<embed src="intro.swf" quality="high" bgcolor="#999966" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1100" height="588" WMODE="transparent">');
		document.write('<param name="wmode" value="transparent">');
		document.write('</embed>');
		document.write('</object>');
}

/* Loads Flash Styles Navigator */
function writeFlashStyleNav(){
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="280" height="530" id="display" align="middle">');
		document.write('<param name="movie" value="display2.swf">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="quality" value="high">');
		document.write('<param name="scale" value="noscale">');
		document.write('<param name="bgcolor" value="#ffffff">');
		document.write('<embed src="display2.swf" quality="high" name="display" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" WMODE="transparent" width="280" height="530"/>');
		document.write('<param name="wmode" value="transparent">');
		document.write('</embed>');
		document.write('</object>');
}

/* FOR HANDLING DROP-DOWN MENUS WITH IE */

/*
 * Function to fix IE bug where <select> elements go over dropdowns
 * @param elem
 *     the element hovered over (link)
 * @param state
 *     the state of the hover (true for hover, false for unhover)
 */

function dropdownFix(elem, state) {
	ul = elem.parentNode.getElementsByTagName('ul')[0];
	if(ul != null)
	{
		navElem = document.getElementById('nav_top');
		iframe = document.getElementById('iefix');
		if (state) {
			iframe.style.width = ul.offsetWidth; // width of the ul
			iframe.style.height = ul.offsetHeight; // height of the ul
			iframe.style.left = navElem.offsetLeft + elem.parentNode.offsetLeft - 1; // position of the #nav div + position of the li
			iframe.style.top = ul.offsetTop; // position of the ul from the top
			iframe.style.display = "block";
		}
		else {
			iframe.style.display = "none";
		}
	}
}

startList = function() {
 if (document.all && document.getElementById) {
	var navRoot = document.getElementById('nav_top');
	walkNodes(navRoot);
  }
}

//This function recursively walks through all of the sub nodes of the provided
//node and applies the necessary style functions to the LI tags for the submenu system.
function walkNodes(node) {
	if (node == null) return;
		
	if (node.nodeName == "LI") {
		node.onmouseover = function() {
			this.className += " over";
			//dropdownFix(this.firstChild, true);
  		}
  		node.onmouseout = function() {
  			this.className = this.className.replace(" over", "");
			//dropdownFix(this.firstChild, false);
   		}
   	}
	
	for (var i = 0; i < node.childNodes.length; i++) {
		walkNodes(node.childNodes[i]);	
	}
}



/* FOR HANDLING THE FADING OF CONTENT WHEN A MENU IS DISPLAYED
=============================================================*/

function showCover() {
	var cover = document.getElementById('cover');
	var style_sel = document.getElementById('style_selector');
	var style_selSTA = document.getElementById('style_selectorSTATIC');
	cover.style.display = "block";
	style_selSTA.style.display = "block";
	style_sel.style.display = "none";
	//opacity('cover', 0, 50, 200);
}

function unCover() {
	var cover = document.getElementById('cover');
	var style_sel = document.getElementById('style_selector');
	var style_selSTA = document.getElementById('style_selectorSTATIC');
	cover.style.display = "none";
	style_selSTA.style.display = "none";
	style_sel.style.display = "block";
	//opacity('cover',50, 0, 200);
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}




/* FOR HANDLING THE CUSTOM SCROLLBARS
=============================================================*/

var scrolling = false;

scroller = function() {
    //collect the variables
	var knob = document.getElementById("scroller");
	var content = document.getElementById("textFrame_content");
    scroller.docH = content.offsetHeight;
    scroller.contH = document.getElementById("textFrame").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollContainer").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    //scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
	scroller.scrollH = 20;
    knob.style.height = Math.round(scroller.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(knob,null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    knob.onDrag = function (x,y) {
      var scrollY = parseInt(knob.style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      content.style.top = docY + "px";
    }
	
	//add scroll-down function
	document.getElementById("scrollDownArrow").onmousedown = function () {
		scrolling = true;
		doScrollDown();
	}
	
	document.getElementById("scrollDownArrow").onmouseup = function () {
		scrolling = false;	
	}
	
	document.getElementById("scrollUpArrow").onmousedown = function () {
		scrolling = true;
		doScrollUp();
	}
	
	document.getElementById("scrollUpArrow").onmouseup = function () {
		scrolling = false;	
	}
}

function doScrollDown() {
	var knob = document.getElementById("scroller");
	var content = document.getElementById("textFrame_content");
	var scrollY = parseInt(knob.style.top) + 1;
	var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
	if (scrolling == true && parseInt(knob.style.top) < scroller.scrollDist) {
		content.style.top = docY + "px";
		knob.style.top = scrollY + "px";
		setTimeout("doScrollDown()",50);
	}
}

function doScrollUp() {
	var knob = document.getElementById("scroller");
	var content = document.getElementById("textFrame_content");
	var scrollY = parseInt(knob.style.top) - 1;
	var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
	if (scrolling == true && parseInt(knob.style.top) > 0) {
		content.style.top = docY + "px";
		knob.style.top = scrollY + "px";
		setTimeout("doScrollUp()",50);
	}
}


// ONLOAD CALL FOR ALL STARTUP FUNCTIONS
//window.onload = startList,preloadImages,scroller.init;
window.onload = function() {
	startList();
	scroller();
}