var theQuote;
var quoteOpacity;
var quoteArray = Array();
var x=0;
	
var fadeTime = 500; //length of fade out/fade in in milliseconds
var displayTime = 10000; //time to display quote, in milliseconds

//array of quotes to be displayed, in order
quoteArray[3] = "80% of companies without developed and tested business continuity plans are out of business within two years of a major disaster";
quoteArray[1] = "A network attack occurs every two seconds";
quoteArray[2] = "85% of companies do not have sufficient network security";
quoteArray[0] = "An updated and regularly tested network security policy is the core of every sound network security plan";


//function to set the text of the quote
function setQuoteText(newText) {
    theQuote.innerHTML='<b id=\"oq\">&#8220;</b>'+newText+'<b id=\"cq\">&#8221;</b>';
}

//fades out quote, changes text after a wait, fades in after another wait
function changeQuote() {
    quoteOpacity.toggle();
		
    setTimeout('setQuoteText(quoteArray[x])', fadeTime);

    setTimeout('quoteOpacity.toggle()', fadeTime * 2);

    if(++x==quoteArray.length) x=0;
}

//set the quote element, opacity element, initial quote text, time of rotation
function initQuote() {

    theQuote = document.getElementById('quote');
    
    quoteOpacity = new fx.Opacity('quote',{duration:fadeTime});
    
    //setQuoteText(quoteArray[0]);
    
    setInterval('changeQuote()', displayTime);
}

//goes through nav list, gives the class 'over' to hovered items, to make the dropdowns work in IE
function startList() {
    if (document.all&&document.getElementById) {
	
	navRoot = document.getElementById("navlist");
	
	for (i=0; i<navRoot.childNodes.length; i++) {
	    
	    node = navRoot.childNodes[i];
	    
	    if (node.nodeName=="LI") {
		
		node.onmouseover=function() {
		    this.className+=" over";
		}
    		
		node.onmouseout=function() {
		    this.className=this.className.replace(" over", "");
		}
	    }
	}
    }
}

//open links in new window without tons of crap
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") == "external") {
	    anchor.target = "_blank";
	}
    }
}


//adds the functions to the onload event
function addLoadEvent(func) {
    var oldonload = window.onload;

    if(typeof window.onload != 'function') {
	window.onload = func;
    } else {
	window.onload = function() {
	    oldonload();
	    func();
	}
    }
}

addLoadEvent(startList);
addLoadEvent(externalLinks);
addLoadEvent(initQuote);

