// JavaScript Document
var slider = false;
$(document).ready(function() {

	// header navigation
	$("#nav > li").each(function(i){
		if(i == 5){
			$(this).addClass("last_child");
			$(this).find("ul:last-child").addClass("last_ul");
		}else if(i > 5){
			$(this).addClass('hide');	
		}
	});
	/*$("#nav li:last-child").addClass("last_child");
	$("#nav li:last-child ul:last-child").addClass("last_ul");*/
	//$("#nav li").animate({"left": "+=50px"}, 1000, {});
	$("#logo").animate({"top": "0"}, {duration: 1000, easing: "easeOutCirc"});
	setTimeout('$("#navleft").animate({"top": "0"}, {duration: 800, easing: "easeOutBack"});', 400);
	setTimeout('$("#navright").animate({"top": "0"}, {duration: 800, easing: "easeOutBack"});', 800);
	setTimeout('$("#nav").animate({"top": "0"}, {duration: 1000, easing: "easeOutCirc", complete: navreset});', 1200);
	
	sfHover();
	// controls slider in the footer
	$('#footer_slide_btn').click(function() {
		
		if(slider) {
			$(this).removeClass('quick_links');
			$("#footer_slider_wrapper").animate({"top": "0", "height": "35"}, {duration: 600, easing: "easeOutCirc"});
			slider = false	
		} else {
			$(this).addClass('quick_links');
			$("#footer_slider_wrapper").animate({"top": "-230", "height": "265"}, {duration: 700, easing: "easeOutCirc"});
			slider = true;
		}
		
		return false;
		
	});
	
	// add to home gallery rotator
	
	
	$('#gallery_container').cycle({
		fx:     'fade',
		speed:  'fast',
		timeout: 8000,
		prev:   '#btn_prev', 
    	next:   '#btn_next', 
	   	pager:  '#gallery_nav'
		//slideExpr: 'img'
	});
	
});
// this is the set the wrapper of #nav to visible after intro animation
function navreset() {
	$('#glbnav').css("overflow","visible");
	}
// for ie browsers 6, 7// to add a class on roll over to <li>
function sfHover() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

//copied over from old site to be used with media popup
function openNewWindow(theURL, winName, winWidth, winHeight){
	var width;
	var height;
	var leftdist;
	var topdist;
	width = screen.width;
	height = screen.height;
	leftdist = Math.round((width - winWidth) / 2);
	topdist = Math.round((height - winHeight) / 2);
	window.open(theURL, winName,'width='+winWidth+',height='+winHeight+',top='+topdist+',left='+leftdist+',resizable=yes,resize=0,menubar=0,location=0,scrollbars=1')
	}
