$(function(){ 
/*  ------------------------------------------------------------------
	External Link ---------------------------------------------------- */
	var allowedDomains = [location.hostname];
	$("#containerFooterMain a[href^=http]:not(.internal)")
	.filter(function(el){
		for ( var i=0; i < allowedDomains.length; i++ ) {
			if ( this.href.indexOf(allowedDomains[i])>-1 ) return false;
		}
		return true;
	})
	.bind("click", function(){ return !window.open(this.href); });
	$('#recipe_nav').show(); 
	
	$('#recipe_nav li a').each(function(){
        $(this).click(function(){
            module = $(this).attr('href');
            showRecipes($(this), module);
            return false;   
        });       
    });
	
/*  ------------------------------------------------------------------
	Banner Widget ---------------------------------------------------- */
	$("#dfc_data").DFCWidget({
		onLoad: {show:true, delay:4500},
		onShow:function (widget) { 
			$('#wrap')
			.css({ marginTop: 64 })
			.delay(3000)
			.animate({ marginTop: 0 }, 1500 );
		},
		wtSite:"Any-day-magic"
	});
});


/*  -----------------------------------------------------------------------
	Smart Columns --------------------------------------------------------- */
	$.fn.smartColumns = function(options) {
		return this.each(function() {
			$list = $(this);
			$list.css({'width':"100%"});

			var colWrap = $list.width();
			var colNum = Math.floor(colWrap / 240);
			var colFixed = Math.floor(colWrap / colNum);
			var rowFixed = Math.floor(colFixed / 1.36);

			$list.css({'width':colWrap});
			$("li", $list).css({'width':colFixed, 'height':rowFixed });

			if($list.hasClass("list_smartcolumns_onerow")){ $($list).css({ 'height': rowFixed}); }
		});  
	};
	
	
/*  -----------------------------------------------------------------------
    Show recipes ---------------------------------------------------------- */
    function showRecipes(a, module) {          
        $('#loader').show();
        $('#list_recipes').load(module, {}, function() {
            $('#list_recipes a').each(function(){
                $(this).attr("rel", "external");
            });
            $('#list_recipes').smartColumns();
            $('#loader').hide(); 
        });
        $('#recipe_nav li').each(function(){
            $(this).removeClass('selected');
        });
        a.parent().addClass('selected');
        return false;
    }
	
/*  ------------------------------------------------------------------
    Dock Milk Products ----------------------------------------------- */
	function dock_milkproducts(){		
        $('#containerMainMenu').removeClass("noscript");
		$('#containerMainMenu').Fisheye({
			maxWidth: 15,
			items: 'a',
			itemsText: 'span',
			container: '#m2',
			itemWidth: 55,
			proximity: 40,
			alignment : 'left',
			valign: 'bottom',
			halign : 'center'
		});
	}
	
	
	