// JavaScript Document

$(document).ready(function(){
	$.easing.custom = function (x, t, b, c, d) { 
	    var s = 1.70158;  
	    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
	    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
	}
	
	$('#secondaryNav ul li:not(#backTo)').click( function() {
			var selMenu = $(this).find("a").attr('childid');
			var thisHref = $(this).find("a").attr("href");
			var thisTitle = $(this).find("a").attr("title");
			
			if (selMenu.length) {
				$("#childOf_" + selMenu).toggle(200, function(){
					$('#secondaryNavSlideContainer').animate({
						marginLeft: "-220px"
					}, 700, 'custom', function(){
						//$('#secondaryNavTitle').html(thisTitle);
						$("#secondaryNavSlideContainer").animate({height: $("#childOf_" + selMenu).height()+20},700, 'custom', function(){
							window.location = thisHref;
						});
					});
				});
			} else {
				window.location = thisHref;
			}
			return false;
		});
	
	$("#alertBox").show(1000);
	$('#alertBox .alertClose').click( function() {
			$('#alertBox').hide(1000);
			return false;
		});
	
	// popup window links (unobtrusive)
	$('a.popup').click(function() {
		var popupWin = window.open(
				$(this).attr('href')
				,'popupWin'
				,'status,scrollbars,resizable,menubar=no,toolbar=no,dependent,width=680,height=580,left=50,top=50'
			);
		popupWin.focus(); 
		return false;
	});

});