$(function() {
	function showFindCourses(){
		$("#findPeople").hide();
		$("#searchSite").hide();
		var pos = $("#toolbarBreak1").offset();  
		var widthFindBox = $("#findCourses").width();
		$("#findCourses").css( {"left": (pos.left - widthFindBox) + "px", "top": (pos.top + 15) + "px" } );
		$("#findCourses").show();
	};
	function hideFindCourses(){$("#findCourses").hide();};
	$("#findCourseLink").hover(function() {
	    //if ($('#findCourses:visible').length == 0 ) showFindCourses();
		$("#findPeople").hide();
		$("#searchSite").hide();
		return false;
	});
	$("#findCourseLink").click(function() {
	    if ($('#findCourses:visible').length == 1 ) {
	    	hideFindCourses();
	    	document.location = "http://www.northshore.edu/search/courses";
	    } else {
	    	showFindCourses();
	    }
		return false;
	});
	$("#closeFindCourses").click(
	  function () {
		hideFindCourses();
	  }
	);
	$("#findCourses").hide();




	function showFindPeople(){
		$("#findCourses").hide();
		$("#searchSite").hide();
		var pos = $("#toolbarBreak2").offset();  
		var widthFindBox = $("#findPeople").width();
		$("#findPeople").css( {"left": (pos.left - widthFindBox) + "px", "top": (pos.top + 15) + "px" } );
		$("#findPeople").show();
	};
	function hideFindPeople(){$("#findPeople").hide();};
	$("#findPeopleLink").hover(function() {
		//if ($('#findPeople:visible').length == 0 ) showFindPeople();
		$("#findCourses").hide();
		$("#searchSite").hide();
		return false;
	});
	$("#findPeopleLink").click(function() {
	    if ($('#findPeople:visible').length == 1 ) {
	    	hideFindPeople();
	    	document.location = "/search/directory";
	    } else {
	    	showFindPeople();
	    }
		return false;
	});
	$("#closeFindPeople").click(
	  function () {
		hideFindPeople();
	  }
	);
	$("#findPeople").hide();
	function focusDirectorySearchField(){
		$("#findPeople").addClass("on-top");
		$("#directorySearchField").focus();
	};

	
	function showSearchSite(){
		$("#findCourses").hide();
		$("#findPeople").hide();
		var pos = $("#toolbarBreak3").offset();  
		var widthFindBox = $("#searchSite").width();
		$("#searchSite").css( {"left": (pos.left - widthFindBox) + "px", "top": (pos.top + 15) + "px" } );
		$("#searchSite").show();
	};
	function hideSearchSite(){$("#searchSite").hide();};
	$("#searchSiteLink").hover(function() {
		//if ($('#searchSite:visible').length == 0 ) showSearchSite();
		$("#findCourses").hide();
		$("#findPeople").hide();
		return false;
	});
	$("#searchSiteLink").click(function() {
	    if ($('#searchSite:visible').length == 1 ) {
	    	hideSearchSite();
	    	document.location = "/search";
	    } else {
	    	showSearchSite();
	    }
		return false;
	});
	$("#closeSearchSite").click(
	  function () {
		hideSearchSite();
	  }
	);
	$("#searchSite").hide();
	function focusSearchField(){
		$("#searchSite").addClass("on-top");
		$("#searchField").focus();
	};

	$("#atozLink").hover(function() {
		$("#findCourses").hide();
		$("#searchSite").hide();
		$("#findPeople").hide();
		return false;
	});
	
	
	
	function callback(){};

});


function zIndexWorkaround() {
	// If the browser is IE,
	//if(isIE()) {
		/*
		** For each div with class menu (i.e.,
		** the thing we want to be on top),
		*/
		$("div.ui-dialog").parents().each(function() {
			var p = $(this);
			var pos = p.css("position");
			 
			// If it's positioned,
			if(pos == "relative" ||
			pos == "absolute" ||
			pos == "fixed")
			{
				/*
				** Add the "on-top" class name when the
				** mouse is hovering over it,
				*/
				p.mouseover(function() {
					$(this).addClass("on-top");
				});
				// And remove it when the mouse leaves.
				p.mouseout(function() {
					$(this).removeClass("on-top");
				});
			}
		});
	//}
}

$(document).ready(function() {
	/*@cc_on
	  @if (@_jscript)
		zIndexWorkaround();
	  @end
	@*/
	
});
