var black = (function () {

function balance_tops (nodes) {
    var local_max = 0;
    nodes.each(function () {
        local_max = Math.max($(this).offset().top, local_max);
    });
    nodes.each(function () {
        var me = $(this);
        var needs = local_max - me.offset().top;
        me.css('margin-top', needs + 20);
    });
};

$(function () {
    
	var nav = $('#nav');
	nav.css({'position': 'absolute'});
	
	var topmost_point = nav.offset().top;
    var left_point = $('#container').offset().left;
	var PADDING_TOP = 63; // 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 = $('#container').offset().left;
	    if (NAV_IS_FIXED) {
    	    nav.css('left', left_point);	        
	    }
	});
});


//---
    return {
        format_price: format_price,
        get_price: get_price
    };
})();