jQuery.noConflict();

function addMega(){
	jQuery(this).addClass("hovering");
	jQuery(this).children("h2").addClass("hover");
}

function removeMega(){
	jQuery(this).removeClass("hovering");
	jQuery(this).children("h2").removeClass("hover");
}


function tagCloudExternalInterfaceHandler(text){
	
	if(jQuery(document).ready(function() {
		if(jQuery("#mTagcloud .popup_" + text).length > 0) {
			jQuery.fn.colorbox({
				width: "770px",
				inline: true,
				href: "#mTagcloud .popup_" + text
			});	
		}
	}));
	
}

jQuery(document).ready(function() {
	
    var megaConfig = {
         interval: 0,
         sensitivity: 4,
         over: addMega,
         timeout: 200,
         out: removeMega
    };

    jQuery("#navmenu li.mega").hoverIntent(megaConfig);
	
	jQuery("#navmenu li").hover(
	  function () {
		jQuery(this).siblings().children("h2").addClass("inactive");
	  }, 
	  function () {
		jQuery(this).siblings().children("h2").removeClass("inactive");
	  }
	);

	//Popup printbutton
	jQuery("#udskrivPrint").click(function() 
	{
		jQuery(".printPopup").stop(true, true).animate({opacity: "show"}, "slow");
		jQuery("#udskrivPrint").hide();
		jQuery(".annuller").show();
	});

	jQuery(".annuller").click(function() 
	{
		jQuery(".printPopup").stop(true, true).animate({opacity: "hide"}, "slow");
		jQuery(".annuller").hide();
		jQuery("#udskrivPrint").show();
		jQuery("#printButton").css('background', 'red');
	});
	
	jQuery("#printCheckbox").click(function()
	{
		var var_checkbox = jQuery("#printCheckbox").attr("checked")?1:0;
		if (var_checkbox == 0) {
			jQuery(".printImage img").hide();
			jQuery(".wideCol img").addClass('hideImg');
			jQuery(".printImage").addClass('printImage02');
		}
		else {
			jQuery(".printImage img").show();
			jQuery(".wideCol img").removeClass('hideImg');
			jQuery(".printImage").removeClass('printImage02');
		}
		
	});
	
	//Printing the recipe
	jQuery("#popupPrintButton").click(function() {
		window.print(); 
	});
	
	//Ie8 hover fix
	jQuery(".restaurant p").mouseover(function() {
        jQuery(this).css('backgroundColor', '#1a1a1a');
    })
	.mouseout(function() {
            jQuery(this).css('backgroundColor', 'transparent');
        });
	
	
	//Inputfelter, som skal cleares på focus tilføjes til følgende selector
    jQuery("#commentForm input, #commentForm textarea").each( function () {
        var $this = jQuery(this),
			origTxt = $this.val();
			origColor = $this.css("color");
			
		$this.css("color", "#888888");
		
        $this.bind("focus",  function() {
			$this.css("color", origColor);
            if($this.val() == origTxt) {
                $this.val("");
            }
        })
        .bind("blur", function() {
			
            if($this.val() == "") {
                $this.val(origTxt);
            }
			if($this.val() == origTxt) {
              	$this.css("color", "#888888");
            }
        });
     });
	
	//Tagcloud - fallback item link texts must match exactly the classname of a-tags in .popups - ie: popup_[NAMEOFLINKTEXT]
	if(jQuery("#mTagcloud").length > 0) 
	{
		
		/* HTML fallback popup binds */
		jQuery("#tagcloudAltContent").children("a").each(function() {
			
			jQuery(this).click( function(){
				if(jQuery("#mTagcloud .popup_" + jQuery(this).text()).length > 0) {
					jQuery.fn.colorbox({
						width: "770px",
						inline: true,
						href: "#mTagcloud .popup_" + jQuery(this).text()
					});	
				}
			});
		});	
		
		var flashvars = null;
		var params = {
			menu: "false",
			scale: "noScale",
			allowFullscreen: "true",
			allowScriptAccess: "sameDomain",
			bgcolor: "#FFFFFF",
			wmode: "opaque"
		};
		var attributes = {
			id:"mTagcloudObject"
		};
		
		swfobject.embedSWF("/flash/sushi_tagcloud.swf", "tagcloudAltContent", "301", "295", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	}
	

	
	/*
	//Administration hover
	jQuery(".administrationSmall a").mouseover(function() {
    	//jQuery(this).children("div").show();
		jQuery(this).children("h4").css('color','#d71a21');
		jQuery(this).children("p").css('color','#d71a21');
		jQuery(this).children("h4").css('text-decoration','none');
		jQuery(this).children("p").css('text-decoration','none');		
    })
	jQuery(".administrationSmall a").mouseout(function() {
    	//jQuery(this).children("div").hide();
		jQuery(this).children("h4").css('color','#000000');
		jQuery(this).children("p").css('color','#000000');
    })
	*/
});
