window.addEvent('load', function(){
	//loadSwifr();
	//sfHover();
	//$("outer-container").setStyle("height", $(document.body).getScrollSize().y)
	$("main-menu").getElements("li").each(
		
		function (e) {
			
			e.addEvent("mouseover", function (me) {
				//alert(e.getParent().getParent().tagName)
				if (e.getParent().getParent().tagName.toLowerCase() != "div") {
					//alert(e.getParent().getHTML() )
					e.getParent().getParent().getChildren()[0].addClass("active");
					}
					e.addClass("sfhover");
				});
				
			e.addEvent("mouseout", function (me) {
				//alert(e.getParent().getParent().tagName)
				if (e.getParent().getParent().tagName.toLowerCase() != "div") {
					//alert(e.getParent().getHTML() )
					e.getParent().getParent().getChildren()[0].removeClass("active");
					}
					e.removeClass("sfhover");
				});
			}
		
		);
	
	
	glossaries = $$("span.glossary");
	exclude = "[h1],[h2],[h3],[h4],[h5],[a],[input]";
	glossaries.each(
		function (sp) {
			//alert(exclude.indexOf(sp.getParent().tagName.toLowerCase()))
			
			if (exclude.indexOf("[" + sp.getParent().tagName.toLowerCase() + "]") == -1) {
			
				sp.addEvent("mouseover", function () {
					definition = new Element("div", {"class":"definition"}).setHTML("<strong>" + sp.getText() + "</strong><p>" + sp.getProperty("title") + "</p>").setOpacity(0).injectAfter(sp);
				
					var fx = new Fx.Styles(definition, {
														duration: 100, wait: true, 
														onComplete : function () {
															//alert($("bubble-login").getStyle("opacity"))
															}
														});
					definition.addEvent("mouseout", function () {
						//definition.getParent().triggerEvent("mouseout");
						});
					fx.options.transition = Fx.Transitions.Sine.easeIn;
					dposition = definition.getCoordinates();
					spposition = sp.getCoordinates();
					
					definition.setStyles({
						'opacity': 0,
						'display' : 'block',
						'top' : spposition.top - (dposition.height+5),
						'left' : spposition.left - ((dposition.width - spposition.width)/2)
						})
					
					if (definition.getCoordinates().left < 0) {
						definition.setStyles({
							"left": spposition.left
							});
						}
					
					this.s = {
						'opacity' : 1
						};
					sp.setProperty("title", "");
					fx.start(this.s);	
					return false;
						
					});
				
				
				
				sp.addEvent("mouseout", function () {
					
					var definition = $$("div.definition")[0];
					// alert(definition);
					var fx = new Fx.Styles(definition, {
														duration: 100, wait: true, 
														onComplete : function () {
															//alert(definition);
															sp.setProperty("title", definition.getElement("p").innerHTML);
															definition.remove();
															}
														});
						
					fx.options.transition = Fx.Transitions.Sine.easeIn;
					
					
					this.s = {
						'opacity' : 0
						};
				
					fx.start(this.s);	
					return false;
					});
				}
			else {
				sp.removeClass("glossary")
				}
					
			}
		);
	
	
	if ($("center")) {
		tables = $$("table.style");
		
		tables.each(
			function (e) {
				var rows = e.getElements("tr");
				
				for (var i = 0; i < rows.length; ++i) {
					rows[i].addClass(
						rows[i].getElements("th").length > 0 ? "head" : (i % 2 == 0 ? "odd" : "even")
						
						);
					}
				}
			);
		}
	
	
	// Scroll through pagination
	/*
	pagination = $("pagination");
	results = $("results").getElements("li");
	pages = pagination.getElement("ul").getElements("li");
	
	recordsPerPage = pagination.getElement("ul").className.replace("_", "");
	
	visiblePageLinks = 22;
	
	pages.each(
		function (e) {
			var aTag = e.getElement("a");
			var thisPage = parseFloat(aTag.getText());
			if (thisPage > visiblePageLinks) {
				e.setStyle("display", "none");
				}
			//alert(aTag[0])
			e.getElement("a").addEvent("click", function (event) {
				
				event.stop();
				event.stopPropagation(); 
				//displayResults(thisPage, recordsPerPage);
				});
					
			
			}
		);
	//alert(recordsPerPage)
	for (r=recordsPerPage; r < results.length; ++r) {
		results[r].setStyle("display","none");
		}
	
	function displayResults(p, r) {
		var start = p == 1 ? 0 : (p*recordsPerPage)+1;
		var end = start + recordsPerPage;
		
		for (r=0; r < results.length; ++r) {
			if (results[r]) {
				results[r].setStyle("display", (r >= start && r <= end) ? "block" : "none" );
				}
			}
	
		}
	displayResults(1, recordsPerPage)
	*/
	
	
	//////////////////////////////////////////////////////////////////
	// Position the footer at the bottom of the page dynamically /////
	//////////////////////////////////////////////////////////////////
	positionFooter();
	
	}); 

function positionFooter() {
	if ($("bottom-bar")) {
		$("bottom-bar").style.top = (window.getScrollHeight()) + "px"
		$("bottom-bar").style.display = "block";
		}
	//setTimeout("positionFooter()", 500);
		
	}	
	
	
function loadSwifr () {
	if(typeof sIFR == "function"){
		
		sIFR.replaceElement("#home-page", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#004770", sWmode:"opaque"}));
		
		sIFR.replaceElement("#center #home-features li h2", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#9CAC3B", sWmode:"opaque"}));
		
		sIFR.replaceElement("#center-content h1", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#9CAC3B", sWmode:"opaque"}));
		sIFR.replaceElement("#center-content h2", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#004770", sWmode:"opaque"}));
		
		sIFR.replaceElement("#associated-documents h2", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#004770", sWmode:"opaque"}));
		
		sIFR.replaceElement("#search-results h1", named({sFlashSrc: "/flash/sifr-optima-medium.swf", sColor: "#9CAC3B", sWmode:"opaque"}));
		
		};
	}
