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;




