// JavaScript Document
window.onload = function() {	
	arrows();
}

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('nav').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 = ' >>';
	//Do Not Edit Below Here
	var links = document.getElementById("nav").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;
			}
		}
	}
}

$(window).ready(function(){

	/* Fix for Chrome nav craziness */
	$("#nav li a.firstLevel").each(function(){
	  $(this).parent().css('height', '12px');
	});

	/* Fix News & Events/Blog boxes */
	$(".home_box_middle #icl_container ul:even").css('background-color','#e3edf8');

	/*
	if( $(".home_blog_box_middle li.icl_summary").size()>0 ){
		var mlink = $('li.icl_more a').attr("href").replace('5709289','5298963');
		$(".home_blog_box_middle li.icl_summary").append('<div style="text-align:right"><a href="'+mlink+'">Read More >></a></div>');
	}
	*/

	$("li.icl_summary").each(function(n){
	  $(this).css('padding','5px 10px');
	  if(n==0){
		$("div:eq(0) strong",this).addClass("home_news_title_first").parent().css('padding-bottom','5px');
	  }else{
		$("div:eq(0) strong",this).addClass("home_news_title").parent().css('padding-bottom','5px');
	  }
	});

	$(".home_box_middle #icl_container ul:eq(2)").css('background-color','#CCE1F7');

	/* Hide left nav elements we don't want */
	$("#leftNav a.firstLevel:not('#firstLevelOpen')").parent().remove();


	/* Add styles/backgrounds for left nav box, and interior landing boxes if they exist */
	$("#innerbox_left,#innerbox_middle,#innerbox_right,#innerbox_wide").wrapInner('<div class="innerbox_content"></div>');
	$(".left_box_yellow").wrapInner('<div class="left_box_content"></div>');

	$("#innerbox_left").prepend('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_left_top.gif"  alt="" />');
	$("#innerbox_middle").prepend('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_middle_top.gif"  alt="" />');
	$("#innerbox_right").prepend('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_right_top.gif"  alt="" />');

	$("#innerbox_left").append('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_left_bottom.gif"  alt="" />');
	$("#innerbox_middle").append('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_middle_bottom.gif"  alt="" />');
	$("#innerbox_right").append('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_right_bottom.gif"  alt="" />');

	$("#innerbox_wide").prepend('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/innerbox_wide_top.gif"  alt="" />');

	$(".left_box_yellow").prepend('<img src="/atf/cf/{8c61f1db-3fe6-435f-9b32-2d0d51a3c2ef}/left_box_yellow_top.gif"  alt="" />');

});