$(document).ready(function() {

function highlight( items ) {
	items.filter(":eq(0)").css({
		"cursor": "default",
		opacity: 1.0,
		"-webkit-transition": "opacity 0.3s linear",
		"-moz-transition": "opacity 0.3s linear",
		"-o-transition": "opacity 0.3s linear",
		"-ms-transition": "opacity 0.3s linear",
		"transition": "opacity 0.3s linear"
	});
}
function unhighlight( items ) {
	items.css({
		opacity: 0.3
	});
}

$("#photos").carouFredSel({
	width: 1800,
	align: "left",
	items: {
		visible: 4,
		width: "variable",
		height: 576
	},
	scroll: {
		mousewheel: true,
		items: 1,
		onBefore: function(oldItems, newItems) {
			unhighlight( oldItems );
		},
		onAfter : function(oldItems, newItems) { 
			$(this).trigger("currentPosition", function( pos ) {
				var txt = (pos+1) + " of " + $("> *", this).length;
				$("#location").html( txt );
			});
			highlight( newItems );
		}
	},
	auto: false,
	prev: {
		button: ".prev",
		key: "left"
	},
	next: {
		button: ".next",
		key: "right"
	}
}).find("li").click(function() {
	$("#photos").trigger("slideTo", [$(this), $("#foo2_deviation").val()]);
	});
	
	unhighlight( $("#photos > *") );
highlight( $("#photos > *") );

	$(function() {
		$( "#accordion" ).accordion({
			active: false,
			autoHeight: false,
			header: 'a.header',
			collapsible: true,
			navigation: true
		});
	});	
});
