if ($j.browser.msie && ($j.browser.version == "6.0")) {
}
else {
	Cufon.replace('.donate a', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('#nav.cms a', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('.accordion h3', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('.tabs li>a', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('h3', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('x.more a', { 
		fontFamily: 'Trajan',
		hover: true
	});
	Cufon.replace('.quote', { 
		fontFamily: 'Trajan',
		hover: true
	});
}

$j(document).ready(function() {
	
	$j(".accordion").accordion({
		autoHeight: false
	});
	
	$j("#_dyn_main").prependTo(".mainwrap");
	$j("#title").prependTo(".mainwrap");
	$j("#main ._files").appendTo("#_dyn_main");
	$j("._status").prependTo("#_dyn_main");
	
	
	
	//$j("._status").prependTo("#detail.job");
	$j("#detail").parents("#main").children().children().children("._text").hide();
	//$j(".heading").parent("p").addClass("removeMargin");
	
	// slideshow
	$j("#slideshow").cycle();
	
	// header
	$j("#_site-functions .font-larger").append(" | ");
	
	// nav
	$j("#nav>li:first-child").addClass("first");
	$j("#nav>li:last-child").addClass("last");
	
	if($j("#nav>li").length == 9) {
		$j("#nav>li").css("margin","0 17px");
		$j("#nav>li:first-child").css("margin-left","23px");
	} 
	else if($j("#nav>li").length == 8) {
		$j("#nav>li").css("margin","0 28px");
		$j("#nav>li:first-child").css("margin-left","23px");
	} 
	else {
		$j("#nav>li").css("margin","0 37px");
		$j("#nav>li:first-child").css("margin-left","23px");
	}
	
	// home
	$j("a.youtube").prettyPhoto({
		theme: 'facebook'
	});
	
	// board listing
	$j(".teamlist li:odd").css("background-color","#fcf7e7");
	
	// resources
	$j("#_lithoContent_40").appendTo("#main");
	
	// donor
	$j("#p_donor-recognition #_dyn_main").appendTo(".mainwrap");
	$j(".logos li").each(function(){
		var imgUrl = $j(this).children("img").attr("src");
		$j(this).css("background","url('"+imgUrl+"') 50% no-repeat");
		$j(this).children("img").remove();
	});
	
	// jobs
	//if($j("._status").length == 0) {
		$j(".apply").siblings("#form").hide();
	//}
	$j(".apply").click(function(e){
		e.preventDefault();
		if($j(".apply").siblings("#form").hasClass("revealed") == false) {
			$j(".apply").siblings("#form").addClass("revealed");
			$j(".apply").siblings("#form").show();
		} else {
			$j(".apply").siblings("#form").removeClass("revealed");
			$j(".apply").siblings("#form").hide();
		}
	});
	
	// sidebar
	$j("#sidebar ._featurebox").wrap('<div class="featureBoxWrap"></div>');
	
	// sticky footer
	$j(function(){
		positionFooter(); 
		function positionFooter(){
			if ( ($j(document.body).height()+$j("#footer-wrap").height()) < $j(window).height()) {
				$j("#footer-wrap").css({
					position: "absolute",
					top:($j(window).scrollTop()+$j(window).height()-$j("#footer-wrap").height())+"px"
				})
			}
		}
	 
		$j(window)
			.scroll(positionFooter)
			.resize(positionFooter)
	});

	// print
	$j('#_site-functions a.print').click(function(e) {
			e.preventDefault();
			window.print();
			return false;
	});
	
	// Reset Font Size
		var originalFontSize = $j('body').css('font-size');
		$j(".resetFont").click(function(){
			$j('body').css('font-size', originalFontSize);
		});
	
	var minZoom = -2;
	var maxZoom = 2;
	var curZoom = 0;
	
	// Increase Font Size
	$j("#_site-functions a.font-larger").click(function(e){
		e.preventDefault();
		if (curZoom >= maxZoom)
			return false;
			
		var currentFontSize = $j('body').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.2;
		$j('body').css('font-size', newFontSize);
		$j(".events .desc").css('font-size', newFontSize);
		$j("p").css('font-size', newFontSize);
		curZoom++;
		//return false;
	});
	
	// Decrease Font Size
	$j("#_site-functions a.font-smaller").click(function(e){
		e.preventDefault();
		if (curZoom <= minZoom)
			return false;
		var currentFontSize = $j('body').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.8;
		$j('body').css('font-size', newFontSize);
		$j(".events .desc").css('font-size', newFontSize);
		$j("p").css('font-size', newFontSize);
		//return false;
	});

	if ($j.browser.msie) {
		if($j.browser.version=="7.0") {
			$j("#navbar").css("z-index","0");
			$j("a.modal").fancybox();
		} else {
			$j("#navbar").css("z-index","0");
			// # Modal Window
			$j("a.modal").prettyPhoto({
				keyboard_shortcuts: false,
				modal : true,
				default_width: 400
				//scrolling: 'no',
				//autoScale: 'true'
			});
		}
	}
	else {
		// # Modal Window
		$j("a.modal").prettyPhoto({
			keyboard_shortcuts: false,
			modal : true,
			default_width: 400
			//scrolling: 'no',
			//autoScale: 'true'
		});
	}
	

});
