/*$(window).scroll(function() {
    if ($(this).scrollTop() > 176) { //I just used 200 for testing
        $("#headernav").css({ "position": "fixed", "top": 0 });
    } else {
        $("#headernav").css({ "position": "absolute", "top": "176px" }); //same here
    }                           
});*/




//var $ = jQuery.noConflict(); this is requires so that there is no conflict between Jquery & Prototype.  See http://docs.jquery.com/Using_jQuery_with_Other_Libraries

$(document).ready(function(){ 
		
		//Header Color Change Links
		$("#headernav a").hover(  
		function () {  
			if ($(this).is(":animated")) {  
				$(this).stop().animate({color:"#e3163d"}, 400);  
			}else{  
				$(this).animate({color:"#e3163d"}, 400);  
			}  
		},  
		
		function () {  
			if ($(this).is(":animated")) {  
				$(this).stop().animate({color:"#000"}, 400);  
			}else{  
				$(this).animate({color:'#000'}, 400);  
			}  
		});
		
		//Header Color Change Links
		$("#topbars a").hover(  
		function () {  
			if ($(this).is(":animated")) {  
				$(this).stop().animate({color:"#e3163d"}, 400);  
			}else{  
				$(this).animate({color:"#e3163d"}, 400);  
			}  
		},  
		
		function () {  
			if ($(this).is(":animated")) {  
				$(this).stop().animate({color:"#fff"}, 400);  
			}else{  
				$(this).animate({color:'#fff'}, 400);  
			}  
		});
		
		
	var nav = $("#headernav");
	nav.css({"position": "absolute"});
/*
	 * MAGICAL SCROLLING NAV
	 * (not that magical)
	 * 
 	 * This is using lots of vars because it gets called all the time 
 	 * on scroll, so it needs to be fast.
	 */
	var topmost_point = nav.offset().top;
    var left_point = $('#wrapper').offset().left;
	var PADDING_TOP = 0; // MAGIC NUMBER
    var REAL_TOP = topmost_point - PADDING_TOP;
	var the_window = $(window);
	var NAV_IS_FIXED = (nav.css('position') == 'fixed');
	the_window.scroll(function () {
        if (the_window.scrollTop() > REAL_TOP) {
            if ($.browser.msie && $.browser.version == "6.0") {
                nav.css('top', the_window.scrollTop() + PADDING_TOP);
            } else if (!NAV_IS_FIXED) {
        	    nav.css({
                    left: left_point,
        	        top: PADDING_TOP,
        	        position: 'fixed'
        	    });
        	    NAV_IS_FIXED = true;
        	}
        } else {
            if (NAV_IS_FIXED) {
                nav.css({
                    position: 'absolute',
                    top: topmost_point,
                    left: ''
                });
                NAV_IS_FIXED = false;
            }
        }
	});
	
	the_window.resize(function () {
	    left_point = $('#wrapper').offset().left;
	    if (NAV_IS_FIXED) {
    	    nav.css('left', left_point);	        
	    }
	});

		   	         
});

