$(document).ready(function(){

//----------------------------------------//
// SEARCH BOX FUNCTIONALITY...
// - Expand/Collapse
// - Input Field Blank on Focus
//----------------------------------------//

	//Set the default width
	$("#search").css("width", "76px");
    //Hide our input field
	$("#searchInputBox").hide();
	// Expand/Collapse    
	$("#search label").toggle(
		
		function () {
			//expand
			$("#search").animate({width: "327px", easing: "easein" });
			//fade in the input field
			$(this).prev().fadeIn("slow");
			
    	},
		function () {
			//collapse
			$("#search").animate({width: "76px", easing: "easein" });			
			//fade out the input field
			$(this).prev().fadeOut("fast");
			//document.getElementById("ctl00_btnSearch").click();
		}
	);
	
    // INPUT FIELD BLANK ON FOCUS
    // set the default text
	//$('input#search_keywords').val($('input#search_keywords').attr('title'));
	
	//clear it out on focus
	$('input#searchInput').focus(function(){
		var value = $(this).attr('value');
		var title = $(this).attr('title');
		if (value == title) {
			$(this).val("");	
		};
		
	});
	// if it's blank then reset back the title attribute
	$('input#searchInput').blur(function(){

		if(!$(this).val().length){
			$('input#searchInput').val($('input#searchInput').attr('title'));
		}
	});

//-------------------------------------//

//------------------------------------//
// Primary Navigation
//------------------------------------//
    //Initialize Primary Nav
    $('ul.nav').superfish();
    
    //fix the top nav
    $('.vertical ul li').eq(1).addClass("topBorder");
	//take the margin off of the last list-item
	//$("ul.navist li:last-child").addClass("last");
	
//------------------------------------//




//------------------------------------//
// Featured Events Cycle
//------------------------------------//

	$('#featuredEventsBox').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 6000, 
		pager:  '#feNav',
		pause: 1
	});
	
//------------------------------------//

//------------------------------------//
// Logo Fixage
//------------------------------------//

$("#logoHolder-Left div:last-child").addClass("last");
$("#logoHolder-Right div:last-child").addClass("last");


//------------------------------------//


//------------------------------------//
// Level 2 Section List
//------------------------------------//

	//take the margin off of the last list-item on each row
	$("ul.level2List li:nth-child(2n)").addClass("last");

//------------------------------------//


//------------------------------------//
// Icons for various Links
//------------------------------------//

	var iconPath = "/images/icons/";
	$("a[@href*=mailto]").append('<img class="linkIcon" src="' + iconPath + 'iconEmail.gif" alt="Send Email" width="16" />');
	$("a.pdf").append('<img class="linkIcon" src="' + iconPath + 'iconPDF.gif" alt="PDF Download" height="16" width="16" />');
	$("a.externalLink").append('<img class="linkIcon" src="' + iconPath + 'iconLink.gif" alt="External Url" height="16" width="16" />');
	//$("a[@href$=.zip]").append('<img class="linkIcon" src="' + iconPath 'iconZip.gif" alt="ZIP File Download" height="16" width="16" />');
	//$("a[@href$=.doc]").append('<img class="linkIcon" src="' + iconPath 'iconDOC.gif" alt="Word Document Download" height="16" width="16" />');
	//$("a[@href$=.ppt]").append('<img class="linkIcon" src="' + iconPath 'iconPPT.gif" alt="PowerPoint Download" height="16" width="16" />');
	//$("a[@href$=.xls]").append('<img class="linkIcon" src="' + iconPath 'iconXLS.gif" alt="Excel Download" height="16" width="16" />');
	
//------------------------------------//


//------------------------------------//
// Tabs Initialization
//------------------------------------//
    $('#tabBox-1 > ul').tabs();
    $('#tabBox-2 > ul').tabs();
    $('#tabBox-3 > ul').tabs();
    //$('#tabBox-4 > ul').tabs();
    //$('#tabBox-5 > ul').tabs();
//------------------------------------//
    
//------------------------------------//
// Show/Hide Functionality
//------------------------------------//
    // Hide all div's with the class "shBox"
	$('.shBox').hide();
	
	// Create show/hide functionality
	// Desc: Basically, this attaches a toggle onClick event to each
	// 'a' tag that has the class 'showHide'
	// The 'a' tag's HREF attribute value is the ID of the
	// element to be shown/hidden.
	$('a.showHide').toggle(
		function(){
		    if ($(this).hasClass("shTitle")){
		        $(this).addClass("shTitleOpen")
		    }
		    // Fade in the element
			$($(this).attr('href')).fadeIn("slow")
		},
		function(){
		    if ($(this).hasClass("shTitle")){
		        $(this).removeClass("shTitleOpen")
		    }
			// Fade out the element
			$($(this).attr('href')).fadeOut("fast")
		}
	);
//------------------------------------//

//------------------------------------//
// Calendar Event Hover (clueTip)
//------------------------------------//
    $('td.CalendarSelectedDay, td.CalendarTodayDayStyle ').cluetip({
		width: 223,
		local: true, 
		sticky: true,
		mouseOutClose: true,
		dropShadow: true,
		dropShadowSteps: 2,
		topOffset: 0,
		leftOffset: -30,
		closeText: ''		
	});
//------------------------------------//
    

//------------------------------------//
// Job's Page Utilities
//------------------------------------//
    //The RadDatePicker popup button is acting up so I'm fixing it manually
    $(".radPopupImage_Default").parent().css("vertical-align", "top")

//------------------------------------//



//grab the hash
var target = location.hash && $(location.hash)[0];
//if there's a hash set on the HREF, show the appropriate div and then scroll to it on the page
if(target){
$(target).show();
$.scrollTo( target,1000);
}
});


