$(document).ready(function(){

	/* menu hover */
	var config = {    
    	over: menuOver, // function = onMouseOver callback (REQUIRED) 
    	sensitivity: 15,   
    	timeout: 400, // number = milliseconds delay before onMouseOut
    	out: menuOut // function = onMouseOut callback (REQUIRED)    
	};
	
	function menuOver() {
		$(this).find("ul.sub-menu").slideDown(350); //Drop down the subnav on click
		$(this).addClass("subhover"); //On hover over, add class "subhover"
	}
	
	function menuOut() {	//On Hover Out
		$(this).removeClass("subhover"); //On hover out, remove class "subhover"
		$(this).find("ul.sub-menu").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
	}

	$("ul.sub-menu").parent().hoverIntent(config);
	$("#menu-main li:first > a").click(function(){return false;});
	
	/* top thumbnail slideshow */
	var myList = $('#post-thumbs').hoverscroll();
	myList[0].startMoving(0, 5);
	
	$('#post-thumbs li.item').hover(function() {
		$(this).children('.slide-title').fadeIn('fast');
	},function() {
		$(this).children('.slide-title').fadeOut('fast');
	});
	
	/* clear mailing list default text value on click */
	document.getElementById('mailing-list-input').defaultValue = "Mailing List";
	document.getElementById('mailing-list-input').value = "Mailing List";
	$('#mailing-list-input').focus(function() {
		if (this.value == this.defaultValue) {
			this.value="";
		}
	}).blur(function() {
		if (!this.value.length) {
			this.value = this.defaultValue;
		}
	});
	
	/* skin archives drop down menu */
	$(".widget_archive select option:first").html('Archive');
	$(function(){
        $(".widget_archive select").uniform();
    });
	
	links=document.getElementsByTagName("a");
	for(var i=0; i<links.length; i++) {
		links[i].target="_top";
	}
	
	$("#menu-item-2996 a, #menu-item-2995 a").attr('target','_blank');
});

/* anchors menu as page scrolls down */
function sticky_relocate() {
	var window_top = $(window).scrollTop();
  	var div_top = $('#sticky-anchor').offset().top;
  	if (window_top > div_top)
    	$('#menu-wrap, #sticky-anchor').addClass('stick')
  	else
    	$('#menu-wrap, #sticky-anchor').removeClass('stick');
}
$(function() {
	$(window).scroll(sticky_relocate);
  	sticky_relocate();
});

