/**********************************************
** Copyright - Virtual Life GmbH
**********************************************/

/**********************************************
** Start jQuery in "no conflict" mode
**********************************************/
var j = jQuery.noConflict();

/**********************************************
** jQuery
**********************************************/
(function(j){j.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=j.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){j(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;j(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{j(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
//On Hover Over
function megaHoverOver(){
    j(this).find(".sub").stop().fadeTo(500, 1).show(); //Find sub and fade it in
    //j(this).find(".sub").stop().slideDown('fast').show();
    (function(j) {
        //Function to calculate total width of all ul's
        jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            j(this).find("ul").each(function() { //for each ul...
                rowWidth += j(this).width(); //Add each ul's width together
            });
        };
    })(jQuery); 

    if ( j(this).find(".row").length > 0 ) { //If row exists...

        var biggestRow = 0;	

        j(this).find(".row").each(function() {	//for each row...
            j(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if(rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        j(this).find(".sub").css({'width' :biggestRow}); //Set width
        j(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

    } else { //If row does not exist...

        j(this).calcSubWidth();  //Call function to calculate width of all ul's
        j(this).find(".sub").css({'width' : rowWidth}); //Set Width

    }
}
//On Hover Out
function megaHoverOut(){
  //j(this).find(".sub").stop().slideUp('slow').hide();
  j(this).find(".sub").stop().fadeTo('slow', 0, function() { //Fade to 0 opactiy

      j(this).hide();  //after fading, hide it
  });
}
//Set custom configurations
var config = {
     sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
     interval: 10, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 10, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};



j(document).ready(function() {
	j("ul#topnav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	j("ul#topnav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	
});





j(document).ready(function() {
    if (jQuery.browser.mozilla || jQuery.browser.safari || jQuery.browser.opera)
    {
    	j('.weinflaschen_links').animate({"opacity": "1"}, 1200);
	 	j('.layout_full .bild').animate({"opacity": "1"}, 1200);

	 	j('.home .fl-1').animate({"opacity": "1"}, 1200);
 		j('.home .fl-2').delay(250).animate({"opacity": "1"}, 1200);
	 	j('.home .fl-3').delay(450).animate({"opacity": "1"}, 1200);
 	}	
});






/*
j(document).ready(function() {

j('#flasch .image_container img').mouseover(function(){
	j('#flaschentxt').animate({"top": "70px", "opacity": "1"}, 400).animate({"top": "45px"}, 600);
	
	});
			
j('#flasch .image_container img').mouseout(function(){
	j('#flaschentxt').animate({"top": "0px", "opacity": "0"}, 400);
	
	});
	

j('#flasch2 .image_container img').mouseover(function(){
	j('#flaschentxt2').animate({"top": "70px", "opacity": "1"}, 400).animate({"top": "45px"}, 600);
	
	});
		
j('#flasch2 .image_container img').mouseout(function(){
	j('#flaschentxt2').animate({"top": "0px", "opacity": "0"}, 400);
	
	});
	

j('#flasch3 .image_container img').mouseover(function(){
	j('#flaschentxt3').animate({"top": "70px", "opacity": "1"}, 400).animate({"top": "45px"}, 600);
	
	});
		
j('#flasch3 .image_container img').mouseout(function(){
	j('#flaschentxt3').animate({"top": "0px", "opacity": "0"}, 400);
	
	});

});
*/



/**********************************************
** Mootools
**********************************************/








