$(document).ready(function() {
	
	/* *** PNG Fix *** */
	$(document).pngFix();
	
	/* *** Enter the Cufon *** */
	Cufon.replace('#messages h1, .message small, .subscribe h3, .story h2, #page h1, #more h4, #message-hub small, small#id, #message-list h4, #message-list ul small, .pagination, .right .news h4, .feature #column-left h2');
	
	/* *** Logo *** */
	$("body:not('#splash') #head h1").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { top: "96px" }, 200);
	},
	function(){
		$(this).animate( { top: "93px" }, 200);
	});
	
	/* *** Signup Input *** */
	$("input.search").val('Search Defence Matters');
	$("input.search").focus(function(){
		if ( $(this).val() == "Search Defence Matters")
        $(this).val('');
	});
	$("input.search").blur(function(){
		if ( $(this).val() == "")
		$(this).val('Search Defence Matters');
	});
	
	/* *** Animate Messages w/Kwiks *** */
	$('.row').kwicks({  
        max : 582,  
        spacing : 10  
    });
    
     /* *** Fade Messages *** */
    $(".box").hover(function(){
    	$(this).addClass("active");
		$(".box:not('.active') .message").stop(true, true);
    	$(".box:not('.active') .message").animate( { opacity: 0.6 }, 600);
	},
	function(){
		$(".box .message").animate( { opacity: 1.0 }, 900);
		$(this).removeClass("active");
	});
	
	/* *** Subscribe RSS *** */
	$(".subscribe a.news").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { marginLeft: "3px" }, 200);
	},
	function(){
		$(this).animate( { marginLeft: "0px" }, 200);
	});
	
	/* *** Message List Hover *** */
	$("#message-list ul li a").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { left: "7px" }, 150);
	},
	function(){
		$(this).animate( { left: "0px" }, 100);
	});
	
	/* *** Message List Hover *** */
	$("#message-list h4 a").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { right: "20px" }, 150);
	},
	function(){
		$(this).animate( { right: "25px" }, 100);
	});
	
	/* *** Story Title *** */
	$(".story h2 a, #more h4 a").animate( { opacity: 0.8 }, 50 )
	$(".story h2 a, #more h4 a").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { opacity: 1.0 }, 50);
    	$(this).parent().css( { 'border-bottom' : '1px solid #bdbdbd' } )
	},
	function(){
		$(this).animate( { opacity: 0.8 }, 50);
		$(this).parent().css( { 'border-bottom' : '1px solid #dfdfdf' } )
	});
	
	/* *** Story Image *** */
	$(".story img, #more img").hover(function(){
		$(this).stop(true, true);
    	$(this).animate( { opacity: 0.8 }, 200);
	},
	function(){
		$(this).animate( { opacity: 1.0 }, 200);
	});
	
	// YouTube video selection on "Careers" page
	
	// Apply hover on tabs
	$("ul.careers li").hover(function() {
		$(this).addClass("hover");
		
	}, function() {
		$(this).removeClass("hover");
	});
	
	// Apply colour change when tabs are clicked (remove colour from current selection)
	$("ul.careers li a").click(function() {
		$("ul.careers li.selected").removeClass("selected");
		$(this).parents("li").addClass("selected");
		
		// Load correct video - work out last character of video ID
		var linkID = $(this).attr("ID");
		numChars = linkID.length-1;
		linkID = linkID.substr(numChars);
		
		$("div.show_video").removeClass("show_video").addClass("hide_video");
		$("#YouTubeVideo"+linkID).removeClass("hide_video").addClass("show_video");
	});
			
});