// Header Navigation
$(function(){
	$("#header ul.nav li").hover(function(){    
		$("ul:first",this).show();
		$("a:first",this).addClass("hover");
	}, function(){    
		$("ul:first",this).hide(); 
		$("a:first",this).removeClass("hover"); 
	});
});

// Home Page Carousel
$(function(){
	$("#carousel").featureCarousel({
		largeFeatureWidth: 460,
		largeFeatureHeight: 300,
		smallFeatureWidth: 353,
		smallFeatureHeight: 230,
		topPadding: 0,
		sidePadding: 70,
		autoPlay: 0,
		trackerSummation: false,
		movedToCenter: function(){
			$("#carousel-container .shadow").fadeIn("fast");
		},
		leavingCenter: function(){
			$("#carousel-container .shadow").hide();
			$("#carousel .tracker-individual-container .tracker-individual-blip:eq(0)").html("Physicians");
			$("#carousel .tracker-individual-container .tracker-individual-blip:eq(1)").html("CIO / IT");
			$("#carousel .tracker-individual-container .tracker-individual-blip:eq(2)").html("HIM / Finance");
			$("#carousel .tracker-individual-container .tracker-individual-blip:eq(3)").html("Practice Management");
		}
	});
});

// Random Quotation
$(function(){
$(".quoteBlocks .quoteBlock").hide();
var divs = $(".quoteBlocks .quoteBlock").get().sort(function(){ 
	return Math.round(Math.random())-0.5; //so we get the right +/- combo
	}).slice(0,1);
$(divs).show();
});

// Twitter Feed
$(function(){
	
	$.getJSON('http://twitter.com/status/user_timeline/salarinc.json?count=5&callback=?', function(data){
		$.each(data, function(index, item){
			$('#secondary .twitter .tweets').append('<div class="each-tweet">' + item.text.linkify() + '</div>');
		});	
		$("#secondary .twitter .tweets").cycle({
			timeout: 0,
			fx: "scrollVert",
			prev: "#secondary .twitter .prev",
			next: "#secondary .twitter .next",
			rev: 1
		});
	});		
	String.prototype.linkify = function() {
		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {			var tweetLink = m.link(m);						return tweetLink;
		});
	};
});

// Footer Height
$(function(){
	var $footer = 0;
	$("#footer ul li").each(function(){
	   var $height = $(this).height();
	   if($height > $footer)
			$footer = $height;
	});
	$("#footer ul li").css({height: $footer});
	$("#footer ul li ul li").css({height: "auto"});
});

//Countdown

$(document).ready(function(){
	var newYear = new Date(); 
	var newTime = new Date(); 
	
	newYear = new Date(newYear.getFullYear() + 1, 10, 1); 
	$('#defaultCountdown').countdown({until: newYear, format: 'YODHMS'}); 
	
});


