/*

	HL2 2010 Redesign
	------------------

	@file 		universal-scripts.js
	@version 	1.0.0b
	@date 		2010-02-24 20:32:02 -0800 (Wed, 24 Feb 2010)
	@author 	Marissa Wells <hello@marissawells.com>

	Copyright (c) 2010 HL2 <http://www.hl2.com>

*/

// ***************************
// ***** Custom jQuery scripts
// ***** Used everywhere
// ***************************

// Compensate for Wordpress including prototype.js in the wp_head
jQuery.noConflict();

jQuery(document).ready(function() {

	// In-field labels
	jQuery("input#s").labelify();
	

	// Deal with IE's lack of support for :last-child
	jQuery("section#sub-nav li:last-child").css("border", "none");
	
	
	// Add classes to sub-LIs in nav - use for opacity changes
	jQuery("ul.sf-menu li li:nth-child(1)").addClass("first-step");
	jQuery("ul.sf-menu li li:nth-child(2)").addClass("second-step");
	jQuery("ul.sf-menu li li:nth-child(3)").addClass("third-step");
	jQuery("ul.sf-menu li li:nth-child(4)").addClass("fourth-step");
	jQuery("ul.sf-menu li li:nth-child(5)").addClass("fifth-step");
	
	
	// Get width of each primary LI in the global nav and set the sub UL to match
	jQuery("ul.sf-menu li.primary").each(function (i) {
		var theWidth = jQuery(this).width();
		jQuery("ul", this).css("width", theWidth + "px");
	});
		// Correct invalid width of "Our Approach" in Firefox
		if (jQuery.browser.mozilla) {
			var correctThis = jQuery("li#our-approach-nav ul").width();
			correctThis += 1;
			jQuery("li#our-approach-nav ul").css("width", correctThis + "px");
		}
	
	
	// Superfish
	jQuery("ul.sf-menu").superfish({
		speed:			'fast',
		delay:			50,
		autoArrows:		false,
		dropShadows:	false
	});
	
	
	// Highlight link when hovering over post thumbnails
	jQuery("#post-list li").mouseover(function(){
		jQuery("a", this).addClass("thumb-hover");
	}).mouseout(function(){
		jQuery("a", this).removeClass("thumb-hover");
	});
	
	
	// Open links with rel="external" in a new window
	jQuery("a[rel='external']").click(function(){
		window.open(this.href);
		return false;
	});	

});