// JavaScript Document
$(document).ready( function() {
	checkScroll();
	
	/*$('.mmBlock2 > div').hover( function() {
		$(this).css('cursor','pointer');
		$(this).addClass('hovered');							 
	}, function() {
	 	$(this).removeClass('hovered');	
	});*/
	
	$(window).scroll(function(){
       checkScroll();
    });
	function checkScroll() {
		var scrollTop = $(window).scrollTop();
		if( scrollTop > 60 ) {
			$('.mNavDD').css('top','48px');	
		} else {
			$('.mNavDD').css('top','-345px');		
		}
	}
	
	$.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; 
	}
	
	$('#sliderNav 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).length > 0)  {
			$("#childOf_" + selMenu).toggle(200, function(){
				$('#sliderNavSlideContainer').animate({
					marginLeft: "-210px"
				}, 700, 'custom', function(){
					$('#sliderNavTitle').html(thisTitle);
					$("#sliderNavSlideContainer").animate({height: $("#childOf_" + selMenu).height()+20},700, 'custom', function(){
						window.location = thisHref;
					});
				});
			});
		} else {
			window.location = thisHref;
		}
		return false;
	});
	
	
	setScroll();
	$(window).bind('resize', function(){
       setScroll();
    });
	function setScroll() {
		var sTop = parseInt($(window).scrollLeft());
		var winWidth = parseInt($(window).width());
		if(winWidth >= 960 && winWidth < 1200){
			//$('#myText').html(sTop + ':' + winWidth);
			$(window).scrollLeft((winWidth * .07));
		}
		
	}
	
	/*
	$('#backTo').click( function() {
			var selMenu = $(this).find("a").attr('parentid');
			var thisHref = $(this).find("a").attr("href");
			var thisTitle = $(this).find("a").attr("title");
			if (selMenu.length) {
				$("#parentOf_" + selMenu).animate({height:"100%"},700,'custom', function(){
					$('#secondaryNavSlideContainer').animate({
						marginLeft: "0px"
					}, 700, 'custom', function(){
						$('#secondaryNavTitle').html(thisTitle);
						$("#secondaryNavSlideContainer").animate({
							height: $("#parentOf_" + selMenu).height() + 20
						}, 700, 'custom', function(){
							window.location = thisHref;
						});
					});
				});
			} else {
				window.location = thisHref;
			}
			return false;
		});
	*/
	
	/*$('#alertSlider').hover(function() {
		$(this).stop().animate({
			marginTop: '0px'
		}, 750,'swing');
	}, function() {
		$(this).stop().animate({
			marginTop: '100px'
		}, 750,'swing');
	});*/
	
	$('#alertSlider h2').click( function() {
		var mTop = $('#alertSlider').css('margin-top');
		var targetTo = '0px';
		//alert(mTop);
		if(mTop == "100px") {
			$('#alertSlider').stop().animate({
			marginTop: targetTo
			}, 750,'swing');
		} else {
			$('#alertSlider').stop().animate({
			marginTop: '100px'
			}, 750,'swing');
		}
			
	});
	
});

$(window).ready( function() {
	$('#alertSlider').animate({
		marginLeft: '0px'
	}, 1000,'swing', function() {
	
	});
});



