jQuery(function(){
	
	jQuery('form#aspnetForm').attr("action", window.location.href);
	
	// Nav rounded
	jQuery('#site-nav ul li a').addClass("rounded").append("<span />");
	
	// odd rows in side nav
	jQuery('.site-side-nav .products li:odd').addClass("odd");
	jQuery('.site-side-nav .portfolio li:odd').addClass("odd");
	jQuery('.site-side-nav .products li:first').addClass("first");
	jQuery('.site-side-nav .products li:last').addClass("last");
	jQuery('.site-side-nav .portfolio li:first').addClass("first");
	jQuery('.site-side-nav .portfolio li:last').addClass("last");
	
	jQuery('.site-side-nav .top a').click(function(){
	    $this = jQuery(this);
	    if (!$this.hasClass("active")){
	        $this.toggleClass("active")
	            .parent().siblings().find("a").toggleClass("active").end().parent().next()
	            .find("."+$this.attr("href").replace('#','')).show().siblings().hide();
	    }
	    return false;
	});
	if (window.location.href.indexOf("/case-studies") > -1)
	{
	    jQuery('.site-side-nav .top a[href=#portfolio]').trigger("click");
	}
	
	if (jQuery.browser.msie)
	{
	    jQuery('#ctl00_Fabrikat_SideMenu_div_ProductsPortfolio .top h2 a').css("position", "relative").prepend('<span class="tl" /><span class="tr" />');
	}
	
});

function InitHomePageImageRotator()
{
    images = jQuery('#index-img-container .index-large-image').show();

    i = 0;
    jQuery('#index-img-container .index-large-image').each(function(){
        jQuery(this).css("z-index", images.length-i);
        i++;
    });
    jQuery('#index-img-container #index-large-image-overlay, #index-img-container #index-header').css("z-index", images.length+1);

    if (images.length > 1)
    {
        setInterval(function(){
            i = 0;
            img = jQuery('#index-img-container .index-large-image:eq(0)').fadeOut(600, function(){
                jQuery(this)
                    .nextAll().each(function(){ jQuery(this).css({"z-index":images.length-(i++)}) })
                    .end().css({"z-index":images.length-(i++)}).show()
                    .parent().append(jQuery(this));
            });
        }, 5000);
    }
}

/**
* 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);