window.onload = function() {
	//arrows();
	fixFlash();
}

sfHover = function() {
	// Support the standard nav without a class of nav.
	var el = document.getElementById("nav");
	if(!/\bnav\b/.test(el.className) && el.tagName == "UL")
		setHover(el);
	// Find all unordered lists.
	var ieNavs = document.getElementsByTagName('ul');
	for(i=0; i<ieNavs.length; i++) {
		var ul = ieNavs[i];
		// If they have a class of nav add the menu hover.
		if(/\bnav\b/.test(ul.className))
			setHover(ul);
	}
}

function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	if (navigator.appVersion.substr(22,3)!="5.0") {
		// IE script to cover <select> elements with <iframe>s
		for (j=0; j<ieULs.length; j++) {
			var ieMat=document.createElement('iframe');
			if(document.location.protocol == "https:")
				ieMat.src="https://www.kintera.org/site/n.gif";
			else if(window.opera != "undefined")
				ieMat.src="";
			else
				ieMat.src="javascript:false";
			ieMat.scrolling="no";
			ieMat.frameBorder="0";
			ieMat.style.width=ieULs[j].offsetWidth+"px";
			ieMat.style.height=ieULs[j].offsetHeight+"px";
			ieMat.style.zIndex="-1";
			ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
			ieULs[j].style.zIndex="101";
		}

		// IE script to change class on mouseover
		var ieLIs = nav.getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			// Add a sfhover class to the li.
			ieLIs[i].onmouseover=function() {
				if(!/\bsfhover\b/.test(this.className))
					this.className+=" sfhover";
			}
			ieLIs[i].onmouseout=function() {
				if(!this.contains(event.toElement))
					this.className= "";
			}
		}
	} else {
		// IE 5.0 doesn't support iframes so hide the select statements on hover and show on mouse out.
		// IE script to change class on mouseover
		var ieLIs = document.getElementById('primaryNav').getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			ieLIs[i].onmouseover=function() {this.className+=" sfhover";hideSelects();}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');showSelects()}
		}
	}
}

// If IE 5.0 hide and show the select statements.

function hideSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className+=" hide";
}

function showSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className=oSelects[i].className.replace(" hide","");
}

// Run this only for IE.
if (navigator.appName == 'Microsoft Internet Explorer') {
	if (window.attachEvent) window.attachEvent('onload', sfHover);
}

function arrows () {
	//Define HTML for arrow here
	var arrowCode = '<img src="/atf/cf/{A1758E1C-C5FF-4DC3-89ED-DC2343EF76A3}/arrow_yellow.gif" border="0" style="margin-left:5px;">';

	//Do Not Edit Below Here
	var links = document.getElementById("primaryNav").getElementsByTagName("a");
	for (i=0;i<links.length; i++) {
		if (links[i].className.indexOf("firstLevel") < 0) {
			if(links[i].nextSibling!=null && links[i].nextSibling.nodeName=="UL" && links[i].innerHTML.substring(0,4).toLowerCase()!="<img"){
				links[i].innerHTML += arrowCode;
			}
		}
	}	
}

function fixFlash() {
	/* fix for 'click to activate this control' in ie for flash */
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}	
}

$(document).ready(function(){
	$("#featuredLinkButtons a").click(function(){
	    var div = $(this).attr("rel");
	    $("#featuredLinks div.features").hide();
	    $("#"+div).show();

        if(div=="links1"){
			$("#links1 .featuredText").eq(0).show();
            $("#featuredLinkButtons img").eq(0).attr("src","/atf/cf/%7BB8A229E6-1CDC-41B7-A615-2D5911950E45%7D/bg_featured_links_on.gif");
            $("#featuredLinkButtons img").eq(1).attr("src","/atf/cf/%7BB8A229E6-1CDC-41B7-A615-2D5911950E45%7D/bg_featured_links2.gif");
        }else{
			$("#links2 .featuredText").eq(0).show();
            $("#featuredLinkButtons img").eq(0).attr("src","/atf/cf/%7BB8A229E6-1CDC-41B7-A615-2D5911950E45%7D/bg_featured_links.gif");
            $("#featuredLinkButtons img").eq(1).attr("src","/atf/cf/%7BB8A229E6-1CDC-41B7-A615-2D5911950E45%7D/bg_featured_links2_on.gif");
        }
	});
	
	$(".linkLocations a").hover(function(){
		var rel = $(this).attr("rel");
		$(".featuredText").hide();
		$("#"+rel).show();
		},
	function(){
		// hover off function
	});
	
	$(".tabLinkText a").click(function(){
		var rel = $(this).attr("rel");
		var section = $(this).attr("section");
		var new_html = $("#"+rel).html();
		$("#"+section).html(new_html);
		
		var image = $(this).attr("rel")+"_img";
		var new_img = $("#"+image).html();
		var img_section = $(this).attr("section")+"_img";
		$("#"+img_section).html(new_img);
		
		var title = $(this).attr("rel")+"_title";
		var new_title = $("#"+title).html();
		var title_section = $(this).attr("section")+"_title";
		$("#"+title_section).html(new_title);
	});
	
	$(".tabSummaryText").parent().prev().css("border","0");
});

function hideItems() {
	$("#leftNav .first").parent().hide();	
}