// When the page is ready
$(document).ready(function(){	

	$(window).unload( function () {
		$.cookie("test", "true", {path: "/"});
	});

	$("#header_nav ul ul").show();
	$("#header_nav ul ul").hide();	
	
	$("#header_nav ul li").hoverIntent({
		sensitivity: 7,
		interval: 25,
		over:
			function(){
				$(this).children("ul").animate({ height:'toggle', opacity:'toggle' }, 200);			
			}
		,
		timeout: 10,
		out:
			function(){
				$(this).children("ul").animate({ height:'toggle', opacity:'toggle' }, 200);
			}
	});
/*
	$(".colorboxPOSTs").click(function(){
		$.post($(this).attr("href"), {"modal":"true"} , function(data){
		    $.fn.colorbox({opacity:0.4, open:true, html:data});
		});
		return false;
	});
*/
	// Modal colorbox handler
	$(".colorbox").click(function(){
		url=$(this).attr("href");
		url+=(url.match(/\?/) ? '&' : '?');
		url+='-modal=true';
		$.fn.colorbox({opacity:0.4, open:true, href:url});
		return false;
	});

//	$(".colorbox").colorbox({opacity:0.4});
//	$(".colorbox_img").colorbox({opacity:0.4});

	$("#accordian_nav li").click(function () {
		// close all open panels
		$(this).siblings("li").children("ul").animate({ height:'hide', opacity:'hide' }, 200);	
		// open select panel
		$(this).children("ul").animate({ height:'toggle', opacity:'toggle' }, 200);	
	});

	$("a[rel='external']").click(function() {
		window.open(
				$(this).attr("href")
		);
		return false;
	});

});
