$(function() {
	$("body").addClass("jsEnabled");
	
	// Adding hover in IE for non-anchor elements
	$(".hoverEnabled").hover(
		function() {
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
	
	//Open PDFs in a different window
	$('a').each(function(){
		if( $(this).attr('href') != "" ) {
			var href = $(this).attr('href');
			if(href.indexOf('.pdf') != -1){
				$(this).click(function(){
					window.open(this.href);
					return false;
				});
			}
		} else {
			return false;
		}
	});
	
    //Opens external links in new window
	 $('a[rel=external]').click(function(e){ 
		 open(this.href); 
		 e.preventDefault(); 
	 });  
	
	//Question and Answer Section 
	var questionHeaders = $("#questions h3");
	
	questionHeaders.addClass("closed");
	questionHeaders.toggle(
		function () {
			$(this)
				.removeClass("closed")
				.addClass("opened")
				.next("div").slideDown();
		},
		function () {
			$(this)
				.removeClass("opened")
				.addClass("closed")
				.next("div").slideUp();
		}
	);
	
	//Twitter Setup
	$("#twitterBird").hover(function(){
		$("#twitterInner").show();
	}, function(){
		$("#twitterInner").hide();
	});
	
	$("#twitterInner").getTwitter({
		userName: "hrserviceteam",
		numTweets: 1,
		loaderText: "Loading tweets..."
	});
	
	//Glossary Tool Code
	$(".glossaryPhrase").cluetip({
		positionBy: 'mouse',
		hoverIntent: {    
			sensitivity:  4,
			interval:     80,
			timeout:      30
		},
		dropShadow: false
	});
	
	/* Items below are used for progressive enhancement */
	
	//Add a class to last item of a list for styling	
	$(".listItem:last").addClass("last-child");
	
	//Add zebra-striping to tables
	if ( !$("table").hasClass("noStripe") ) {
		$("table tr:odd").addClass("odd");
	}
	
	//Automatically selects focused field text and adds class for styling
	$('input[type="text"]').focus(function(){
		$(this).select().addClass("focused");
	});
	$('input[type="text"]').blur(function(){
		$(this).removeClass("focused");
	});
	
}); 

