$(document).ready(function(){
	$('a[@rel$="external"]').click(function(){
		this.target = "_blank";
	});
	/* Slide Panel */
	$(".btnSlide").click(function(){
		$(".panel ul li").css("position", "static"); //patch for IE
		$("#panel").slideToggle("slow", function () {
			$(".panel ul li").css("position", "relative"); //patch for IE
		});
		$(this).toggleClass("active");
		return false;
	});
	
	/* Drop Down Menu*/
	/*
	$('.panel ul li').hover(
        function() {
            $(this).find('ul:first').slideDown('slow');
        },
        function() {            
            $(this).find('ul:first').slideUp('fast'); 
        }
    );
    */
	$('.panel ul li').hover(
        function() {
            $(this).find('ul:first').animate({opacity: 1.0}, 50).fadeIn('slow');
        },
        function() {
			$(this).find('ul:first').animate({opacity: 1.0}, 3000).fadeOut('slow'); 
        }
    );	    
    $('.panel li:has(ul)').find('a:first').append(' &raquo;');
	
	/* Image Gallery */
	$.each( $(".thumbs a img"), function(){
		$(this).after("<em>" + $(this).attr("alt") + "</em>");
    });
	
	$(".gallery1 h4").append('<em></em>');
	$(".gallery1 .thumbs a").click(function(){
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$(".gallery1 .largeImg").attr({ src: largePath, alt: largeAlt });
		$(".gallery1 h4 em").html(" (" + largeAlt + ")"); return false;
	});

	$(".gallery2 h4").append('<em></em>');
	$(".gallery2 .thumbs a").click(function(){
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$(".gallery2 .largeImg").attr({ src: largePath, alt: largeAlt });	
		$(".gallery2 h4 em").html(" (" + largeAlt + ")"); return false;
	});
	
	$(".gallery3 h4").append('<em></em>');
	$(".gallery3 .thumbs a").click(function(){
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$(".gallery3 .largeImg").attr({ src: largePath, alt: largeAlt });	
		$(".gallery3 h4 em").html(" (" + largeAlt + ")"); return false;
	});

	/* News */
	//hide message_body after the first one
	$(".messageList .messageBody:gt(3)").hide();
	
	//hide message li after the 5th
	$(".messageList li:gt(4)").hide();
	
	//toggle message_body
	$(".messageHead").click(function(){
		$(this).next(".messageBody").slideToggle(500)
		return false;
	});

	//collapse all messages
	$(".collpaseAllMessage").click(function(){
		$(".messageBody").slideUp(500)
		return false;
	});

	//show all messages
	$(".showAllMessage").click(function(){
		$(this).hide()
		$(".showRecentOnly").show()
		$(".messageList li:gt(4)").slideDown()
		return false;
	});

	//show recent messages only
	$(".showRecentOnly").click(function(){
		$(this).hide()
		$(".showAllMessage").show()
		$(".messageList li:gt(4)").slideUp()
		return false;
	}); 
});