$(document).ready(function(){
	$("#home-featured").css("background","#fff url(/images/icons/spinner.gif) no-repeat 320px 50%");
	// Show images on featured area
	$("#featured-scrollable .items a").click(function() {
		var original_href = $(this).attr("href");
		var the_split_href = original_href.split("?img=");
		the_href = the_split_href[0];
		the_title = $(this).attr("title");
		the_img = the_split_href[1];
		$("#featured-viewer").fadeOut("slow", function(){
		$("#featured-viewer img").load(function(){
			$("#featured-viewer").fadeIn("slow");
			$("#featured-viewer a").attr("href",the_href).attr("title","link to " + the_title);
			$("#featured-viewer h3").html('<a href="' + the_href + '">' + the_title + '</a>');
		}).attr({src : the_img, title : "link to " + the_title, alt : the_title});

		});
		theTimer.reset(5000);
		return false;
	});
	// Tab functionality for featured area on home page
	$("ul#home-tabs li a").click(function() {
		current_thumb = $(this);
		theid = $(this).attr("href");
		$("ul#home-tabs li a").removeClass();
		$(this).addClass("active");
		if (theid == "#home-watson-wire"){
			$("#home-featured:visible").hide()
			$("#home-watson-wire:hidden").show();
		}else{
			$("#home-watson-wire:visible").hide()
			$("#home-featured:hidden").show();
		}
		return false;
	});
	$("#featured-scrollable").scrollable({size:4});
	theTimer = $.timer(5000, function (timer) {
		var scrollable_length = $("#featured-scrollable .items a").length ;
		var i = 1;
		var next_scrollable = 0;
		for (i=1;i<=scrollable_length;i++){
			if ( $("#featured-scrollable .items a:nth-child(" + i + ")").hasClass("active") ) {
				if ( i == scrollable_length ) {
					next_scrollable = 1;
				}else{
					next_scrollable = i + 1
				}
			}
		}
		$("#featured-scrollable .items a:nth-child(" + next_scrollable + ")").click();
	});

	// Dropdown menu behaviors for IE
	$("#main-nav ul li").hover(function(){
		$(this).addClass("iehover");
	},function(){
		$(this).removeClass("iehover");
	});
	$('li#nav-share a').click( function() { 
		$('li#nav-share form:hidden').show("fast",function(){
			$("#Sender_Name")[0].focus();
		});
		return false;
	});
	/*$('li#nav-wire a').click( function() { 
		$('li#nav-wire form:hidden').show("fast",function(){
			$("#First_Name_Sidebar")[0].focus();
		});
		return false;
	});*/
		$('li#nav-contact a.contact-content').click( function() { 
		$('li#nav-contact #nav-contact-info').show("fast");
		return false;
	});
	
	$("label.overlabel").overlabel();
});