// JavaScript Document
jQuery(document).ready(function(){
	checkBg();
	jQuery(window).resize(checkBg);
	jQuery("#header .navigation li a:not(:first)").after("<span class='seperator'>&nbsp;&nbsp;&nbsp;\\&nbsp;&nbsp;&nbsp;</span>");
	jQuery("#footer .navigation li a:not(:first)").after("<span class='seperator'>&nbsp;&nbsp;&nbsp;\\&nbsp;&nbsp;&nbsp;</span>");
	
	jQuery("#latest_tweets ul li:last").css("borderBottom", "0px none");

	/*var howmany_nav = $(".navigation li").size();
	for (var i=0; i <= howmany_nav; i++) {
		$("#navigation li").delay(parseInt(i*500).fadeIn("slow");
	}*/
	
	jQuery("#header .navigation li").each(function(i){
		jQuery(this).delay(parseInt(250+(i*250))).fadeIn("slow");		  
	});
	
	jQuery('#sidebar li h2 ').each(function(){
		var me = jQuery(this)
			, t = me.text().split(' ');
		var last = t.pop();
		me.html( t.join(' ')+' <strong>'+last+'</strong>' );
	});
		
    jQuery('#rotator .ngg-widget').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed: 2000,
		timeout: 5000,
		pause: 1
	});

});
	
function checkBg () {
	//first we'll make sure the document height is at least the browser height:
	if(jQuery(document).height() < jQuery(window).height()) {
		jQuery("#inner_wrapper_2").height((window).height());
	}
	
	//now we'll do some checking... 
	//if the browser height is less than 1300px, we'll only show the top half of the bottom bg.
	if(jQuery(document).height() < 1300) {
		jQuery("#inner_wrapper").css("backgroundPosition", "50% 350px");
	//otherwise, keep the bottom part flush with the bottom of the document.
	} else {
		jQuery("#inner_wrapper").css("backgroundPosition", "50% bottom");
	}
	
	//now, through some feindish trickery of javascript and jquery, we're going to make sure that the 
	// remaining (without the default 1300px) document height is always a multiple of 300.
	if (jQuery(document).height() > 1300) {
		var current_height = parseInt(jQuery("#inner_wrapper_2").height() - 1470);
		var target_height = 300 * Math.ceil(current_height/300);
		jQuery("#inner_wrapper_2").height(parseInt(target_height + 1470));
	}
}
