//**************JQUERY SCRIPTS************


$(document).ready(function() {
	
	$(".hide").css("display", "none");
	
// Menu behavior
	var pageID = $('body').attr("id");
	var minus_page = pageID.replace (/_page/g, "");
	var IDstring = "#" + minus_page;
	//initially hide all subitems except on front page
	if (pageID != "front_page") {
		$('.subitem').hide();
	}
	
	//always show subitem for current page
	$(IDstring).parent(".item").find(".subitem").show();
	
	//show subitem on hover, disappear on hover-off unless this page or front page
	$("li.item").hover(
      function () {
        $(this).find('.subitem').show();
      }, 
      function () {
      	if ((!($(this).children("a").attr("id") == minus_page)) && (!(pageID == "front_page"))) {
        $(this).find(".subitem").hide();
      	}
      }
    );

	
// Recent boxes heights
	$(".front_block").equalHeights();
	
//Add arrow to drop elements
	$(".drop").append('<img src="/images/drop_arrow.png" alt="" />');
	
//expand drop elements and change arrow on click
	$(".drop").click(function() {
		$(this).children("img").toggle();
		$(this).parent("div").children("div").slideToggle("slow");
	});
	

});


//External links open in new window
$(document).ready(function(){
	$("a[href^='http']").attr('target','_blank');
});

//chatpop link opens new window
$(document).ready(function() {
    $('#chat_button a ').click( function() {
        window.open('http://www.trekandromeda.com/chatpop.html','','width=837, height=637');
        return false;
    });
});



//************OTHER SCRIPTS**************