var $j = jQuery.noConflict();

$j(function() {

	// comment next lines to disable features

	navigation(); // dynamic light selection in the menu (windows7-like)

	if ($j("#slides").length > 0) setInterval("slides()", 5000); // slide timer (5000 / 1000ms = 5 sec)

	if ($j("#folio").length > 0) folio(500, 0.6); // portfolio sleek image shade (timer, opacity)

});

// functions

function navigation() {
	$j("li a", "#nav").
		mousemove(function(e) {
			var relativeY = (e.pageY - this.offsetTop - 45) / 4;
			$j(this).css("backgroundPosition", "center " + relativeY + "px");
		}).
		mouseout(function(e) {
			$j(this).css("backgroundPosition", "center center");
		});
}

//

function folio(time, opacity) {
	$j("img", "#folio")
		.css("opacity", 1)
		.hover(
			function() {
				$j(this).stop().animate({ opacity: opacity }, time);
			},
			function() {
				$j(this).stop().animate({ opacity: 1 }, time);
			}
		);
}

//

function slides() {

	if (ie6) {
		return; // ie6 fails to animate overall opacity of the transparent PNGs
	}

	var $active = $j("#slides img.active");

	if ($active.length == 0) {
		$active = $j("#slides img:last");
	}

	var $next = $active.next().length ?
			$active.next() :
			$j("#slides img:first");

	$active.addClass("pre-active");

	$next.
		css({ opacity: 0 }).
		addClass("active").
		animate({ opacity: 1 }, 1000, function() {
			$active.removeClass("active pre-active");
		});

}

//

var ie6 = jQuery.browser.msie && parseInt(jQuery.browser.version) < 7;

$j("a[rel]").overlay({expose: 'grey', effect: 'apple'}); 
 
$j("ul.menuslide").tabs("#slideshow > div", { 
         effect: 'fade', 
        fadeOutSpeed: "slow", 
         rotate: true 
     }).slideshow();
   // expose the form when it's clicked or cursor is focused 
    $j("#area").bind("click keydown", function() { 
 
        $(this).expose({ 
 
            // custom mask settings with CSS 
            maskId: 'mask', 
 
            // when exposing is done, change form's background color 
            onLoad: function() { 
                this.getExposed().css({backgroundColor: '#CCC'}); 
            }, 
 
            // when "unexposed", return to original background color 
            onClose: function() { 
                this.getExposed().css({backgroundColor: null}); 
            }, 
 
            api: true 
 
        }).load(); 
    }); 

$('.ajax').ajaxContent({
event:'click',
loaderType:'img',
loadingMsg:'http://www.rickdolphijn.nl/images/javascript/images/loading.gif',
target:'#ajaxContent'
});
 
$('.ajax1').ajaxContent({
event:'click',
loaderType:'img',
loadingMsg:'http://www.rickdolphijn.nl/images/javascript/images/loading.gif',
target:'#ajaxContent1'
});

