// no conflicts with prototype
// var j = jQuery.noConflict(); 

var jQ = jQuery.noConflict();

	jQ(function() {
		
	// Pronav	
	var paddingFix = 0;
	function megaHoverOver(){
		(function(jQ) {
	        //Function to calculate total width of all ul's
	        jQuery.fn.calcSubWidth = function() {
	            rowWidth = 0;
	            //Calculate row
	            jQ(this).find("ul").each(function() { //for each ul...
	                rowWidth += jQ(this).width(); //Add each ul's width together
	            });
	        };
	    })(jQuery);
	    
	    jQ(this).find(".sub").stop().fadeTo(0, 1).show(); //Find sub and fade it in
	    //jQ(this).find(".sub").stop().css('opacity', 1).slideDown('slow').show();
	    
	    subPaddingLeft = jQ(this).find('.sub').css('padding-right');
		 subPaddingRight = jQ(this).find('.sub').css('padding-left');
		 if (subPaddingLeft && subPaddingRight)
		 {
			 subPaddingLeft = parseInt(subPaddingRight.replace('px', ''));
			 subPaddingRight = parseInt(subPaddingRight.replace('px', ''));
			 paddingFix = subPaddingLeft + subPaddingRight;
		 }
	    if ( jQ(this).find(".row").length > 0 ) { //If row exists...
	
	        var biggestRow = 0;	
	        jQ(this).find(".row").each(function() {
	            jQ(this).calcSubWidth(); //Call function to calculate width of all ul's
	            //Find biggest row
	            if(rowWidth > biggestRow) {
	                biggestRow = rowWidth;
	            }
	        });
	        jQ(this).find(".sub").css({width : biggestRow + paddingFix}); //Set width
	        jQ(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin
	
	    } else { //If row does not exist...
	        jQ(this).calcSubWidth();  //Call function to calculate width of all ul's
	        jQ(this).find(".sub").css({'width' : rowWidth + paddingFix}); //Set Width
	
	    }
	}
	//On Hover Out
	function megaHoverOut(){
	  jQ(this).find(".sub").fadeTo(0, 0, function() { //Fade to 0 opactiy
	      jQ(this).hide();  //after fading, hide it
	  });
	}
	
	//Set custom configurations
	var config = {
	     sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
	     interval: 0, // number = milliseconds for onMouseOver polling interval
	     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
	     timeout: 0, // number = milliseconds delay before onMouseOut
	     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};
	jQ("ul#pronav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	jQ("ul#pronav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	
	
	//more
	jQ("a#aSeoMore").click(function(event){
			jQ(this).hide();
			jQ("div.dSeoMore").css("display","block")
	});
	
	
	
	
	jQ.fn.extend({
		toggleValue : function (defaultText) {
			return this.each(function() {
				jQ(this).focus(function() {
					if (jQ(this).val() == defaultText) {
						jQ(this).val('');
					}
					jQ(this).blur(function () {
						if (jQ.trim(jQ(this).val()) == '') {
							jQ(this).val(defaultText);
						}
					});
				});
			});
		}
	});

	
	jQ('#newsletter').toggleValue('E-Mail-Adresse eingeben');
	
	
});


