// JavaScript Document

$(document).ready(function(){
	globalScripts.init();			   
});


globalScripts = {
	
	init: function() {

	/* nav */ 
	
	// fixed for IE
	$("#header .sub-menu ul li:last-child").addClass("specialPaddingBottom");
	$("#header .sub-menu li:first-child").addClass("specialPaddingTop");
	
	$("#header .menu li").hover(
		function(){
			$(this).find("ul").show();
			$(this).find("a").addClass("active");
			
		},
		function(){
			$(this).find("ul").hide();
			$(this).find("a").removeClass("active");
			if ( $(this).parent().hasClass("sub-menu") ) {
				$(this).find("ul").show();
			}
		}		
	);


	//fix for empty paragraphs
	$("p").each(function(){
		if($(this).html() == "&nbsp;"){
			$(this).hide();
		}					 
	});
	


	/* twitter */
	
		//twitter
		$(".tweet").tweet({
		  join_text: "",
		  username: "gchallenges",
		  avatar_size: 24,
		  count:3,	  
		  loading_text: "loading tweets..."
		},showTweets());	
	

		function showTweets() {
			$(".tweet_first").livequery(function(){ 
				
				$(this).show();
				var currentTweet = 1;
				var totalTweets = $(".tweet_list li").length;
				
				$("#twitterNext").click(function(){

					currentTweet++;

					if (currentTweet > totalTweets) {
						currentTweet = 1;	
					}
					$(".tweet_list li").hide();
					$(".tweet_list li").eq(currentTweet-1).show();
					
				});
		
		
			});
		}



		//blind
		$(".blind > a").toggle(
		function(){
			$(this).parent().find("div").fadeIn();	
			if (! $(this).parent().hasClass("faq")) {
				$(this).html("- Less");
			}
		},
		function(){
			$(this).parent().find("div").fadeOut();		
			if (! $(this).parent().hasClass("faq")) {
				$(this).html("+ More");
			}
		});



		/* tabbed box */
		
		$("#sbFeatureBox .tabLink").click(function(){
			$("#sbFeatureBox li div.tabContent").hide();	
			$("#sbFeatureBox .tabLink").removeClass("active");
			$(this).parent().find("div.tabContent").show();	
			$(this).addClass("active");
		});
		

		
		// hides the 2 other tabs
		$("#sbEvents").hide(); 
		$("#sbPrograms").hide();
		
		
		
	
	}
}


		

//google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19516208-2']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


