/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.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){$(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;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(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);



/**
* the rest of the cusom code for this site
* 
*/

var last_url = "";
$(document).ready(function(){
	$("#breadcrump ul li:has(a)").each(function(){
		if($(this).find("a").attr("href") == last_url){
			$(this).remove();
		}
		last_url = $(this).find("a").attr("href");
	});

// at@opengate.dk - mainmenu mouseover, hover
$("#menu ul li").hoverIntent({    
    sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
    interval: 100, // number = milliseconds for onMouseOver polling interval    
    timeout: 400, // number = milliseconds delay before onMouseOut    
    over:function(){
        $(this).addClass("hover");
    },
    out: function(){
        $(this).removeClass("hover");
    }
});



//	$("#menu ul li").hover(function(){
//		$(this).addClass("hover");
//	},function(){
//		$(this).removeClass("hover");
//	});



	$("#slidemenuinner>ul>li>ul").each(function(){
		$(this).attr("jqheight",$(this).height());
	});
	$("#slidemenuinner>ul>li>ul").hide();
	$("#slidemenuinner>ul>li>ul").css("height","0px");
	$("#slidemenuinner>ul>li").hover(function(){
		//$(this).find(">ul").stop().animate({height:$(this).find(">ul").attr("jqheight"),paddingTop:"10px",paddingBottom:"10px"},300);
		$(this).find(">ul").stop().animate({height:$(this).find(">ul").attr("jqheight"),marginTop:"10px",marginBottom:"10px"},300);
		$(this).addClass("active");
		/*
		if($(this).find(">ul").is(":animated")){
			$(this).find(">ul").stop().slideDown("fast");
		}else{
			$(this).find(">ul").slideDown("fast");
		}*/
	},function(){
		//$(this).find(">ul").stop().animate({height:"0px",paddingTop:"0px",paddingBottom:"0px"},300);
		$(this).find(">ul").stop().animate({height:"0px",marginTop:"0px",marginBottom:"0px"},300);
		$(this).removeClass("active");
		/*
		if($(this).find(">ul").is(":animated")){
			$(this).find(">ul").stop().slideUp("fast");
		}else{
			$(this).find(">ul").slideUp("fast");
		}
		*/
	});
	// change background color in frontpage
	$("div#div-col1").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});
	$("div#div-col2").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});
	$("div#div-col3").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});	
});