/* ----------------------------------------------------------------------------------- 

	<PROJECTNAME>
	Scripts

----------------------------------------------------------------------------------- */

$(function() {

	/* ---------------------------------------
	Prettifying Menu
	--------------------------------------- */
	$("#HouseMenuNav li ul li#HouseMenuNavCurrentItem").parent("ul").parent("li").addClass("CurrentItem");
	
/* ---------------------------------------
	Prettifying SubMenu
	--------------------------------------- */
	$("#subMenu ul").parent("li").addClass("hasChild");
	$("#subMenu ul li#subMenuCurrentItem").parent("ul").addClass("showSub");
	
	/* ---------------------------------------
	Adding Logout Link to "Admin" Menu
	--------------------------------------- */
	$("a[title='Portal Administration']").next("ul").append('<li id="HouseMenuNavLogOut"><a href="/Logoff.aspx">Log Out</a></li>');
	
	/* ---------------------------------------
	Menu Dropdown Animation
	--------------------------------------- */
	$(".mainMenu ul li").each(function () {
		
		// Hide the menu by default
		$(this).children("ul").hide();
		
		// Hover, animate down
		$(this).hover(function() {
			// Slide down to normal height
			$(this).children("ul").slideToggle('fast');

		// Hover out, animate up
		}, function() {
			$(this).children("ul").hide();
		});
		
	});
	
	/* ---------------------------------------
	InnerShadows
	- Similar to DropShadows but less Z-Index headaches and show/hide logic
	--------------------------------------- */
	$(".innerShadow").wrapInner("<div class='shadowPng'></div>");
	
	/* ---------------------------------------
	Arrow Class
	--------------------------------------- */
	$("a.arrow").hover(function() {
		$(this).stop().animate({
			"backgroundPosition": "5px"
		}, 200);
	}, function() {
		$(this).stop().animate({
			"backgroundPosition": "0"
		}, 200);
	});

	/* ---------------------------------------
	Homepage News Feed
	--------------------------------------- */
	// Why doesn't DNN6 have wrapping elements around each feed item?
	i=0;
	$(".ModDNNNewsFeedsC h4").each(function(i) {
		// Create a new wrapping element
		$(this).before("<div class='DNN_News_ItemLink DNN_News_ItemLink_"+i+"'></div>");
		
		// Stick the date and the title in to this new wrapping element
		$(this).next("h6").appendTo(".DNN_News_ItemLink_"+i).addClass("DNN_News_ItemDate");
		$(this).appendTo(".DNN_News_ItemLink_"+i);
		
		// Increment
		i++
	});
	$("#dnn_mediaReleases .moduleContent").show();
	
	// Date Transforming
	$('.DNN_News_ItemDate').each(function(){
		var olddate = $(this).text()
		var newdate = olddate.substr(8,4)+olddate.substr(4,3)+", "+olddate.substr(11,5);
		$(this).html(newdate); 
	});
	
	/* ---------------------------------------
	Searches
	--------------------------------------- */
	$(".ModSearchResultsC table").not(".PagingTable").find("td span:nth-child(4)").addClass("searchDescription");
	$(".ModSearchResultsC table").not(".PagingTable").find("td span:nth-child(6)").addClass("searchTime");
	
	/* ---------------------------------------
	Publications Menu
	--------------------------------------- */
	$("#dnn_mediaPublications").hover(function() {
		$(this).toggleClass("hover");
	});
	$("#dnn_mediaPublications").click(function() {
		$(this).toggleClass("active");
		
		// Check if active
		if ($(this).hasClass("active")) {
			$(".mediaPublicationsOverlay").show().animate({
				"height": "502px"
				
			}, 350);
			
		// If not active
		} else {
			$(".mediaPublicationsOverlay").fadeOut('fast', function() {
				$(this).css("height","0px");
			});
		}
	});
	
	/* ---------------------------------------
	Generic Equal-Height script
	--------------------------------------- */
	$(".eqhContainer").each(function() {
		var height = 0;
		$(this).children(".eqh").each(function() {
			if ($(this).height() >= height) {
				height = $(this).height();
			}
		});
		$(this).children(".eqheight").css("min-height",height);
	});
	
	/* ------ Take Body top margin out ?------- */
	$("body").css("marginTop","0");

// End $func	
});
