sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function mycarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function() {
	$('#nav li').hover(function() {
        $(this).addClass('hover');
        $('ul:first',this).css('visibility', 'visible');
    }, function() {
        $(this).removeClass('hover');
        $('ul:first',this).css('visibility', 'hidden');
    });
    
    $('#nav li ul li:has(ul)').find('a:first').addClass('child');
	
	$('a[rel="colorbox"], a[rel="jacobsgallery"]').colorbox({transition:"fade"});
	$('#jacobsgallery').jcarousel({visible: 2, auto: 5, initCallback: mycarousel_initCallback});

	
	$('ul.children').mouseenter(function() {
		$(this).parent().addClass('activ');
	}).mouseleave(function() {
		if( !($(this).parent().hasClass('current_page_item') || $(this).parent().hasClass('current_page_ancestor')) )
			$(this).parent().removeClass('activ');
	})/*.each(function() {
		var docWidth = $(document).width();
		var off = $(this).parent().offset();
		if( off.left > docWidth / 2 ) {
			$(this).css('right', '0')
			$(this).find('li').css('float', 'right');
			$(this).find('li').each(function() {
				$(this).prependTo($(this).parent());
			});
		}
	})*/;
	
	$('a[rel="colorbox2"]').colorbox({iframe:true, innerWidth:500, innerHeight:700});
	
});
