/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function toggleNav(element, prefix, counter) {
	element.blur();

	if ($.browser.msie && ($.browser.version == "6.0")) {
		$('#'+prefix+counter+':has(*)').slideToggle('swing',
			function () {$("."+prefix+":not(#"+prefix+counter+"):visible").slideUp('swing');}
		);
	} else {
		if ($("."+prefix+":not(#"+prefix+counter+"):visible").slideUp('swing',
			function () {$('#'+prefix+counter+':has(*)').slideToggle('swing');}
		).size() == 0) {
				$('#'+prefix+counter+':has(*)').slideToggle('swing');
		}
	}
}

function start_slimbox(images) {
	jQuery.slimbox(images, 0);
}

(function($){
	$.fn.w_showroom = function (options) {

		var opts = $.extend(defaults, options);

		return this.each(function() {
			$(this).find(".filmstrip img").css("cursor", "pointer").bind("click", function() {running = false;activate($(this))});
			activate($(this).find(".filmstrip img:last"));

			$.fn.run = function() {
				setInterval(function(item) {
					if (running) {
						next = item.find(".filmstrip img.active").next();
						if (next.size() == 0) next = item.find(".filmstrip img:first");
						activate(next);
					}
				}, opts.timeout, $(this));
			}
		});
	};

	var defaults = {
		timeout: 5000
	}

	var running = true;

	function activate(item) {
			var id = item.attr("id");
			item.addClass("active").parent().find("img").not($(item)).removeClass("active");
			$(".panel").hide();
			$("#panel_"+id).show();
			$('div.showroom_info').hide();
			$('#showroom_info_' + id).show();
	}

	function activateNext(current) {
		var next = current.next();
		if (next.size() == 0) next = current.parent().first();
		hier.activate(next);
	}

})(jQuery);




$(document).ready(function() {
	$("#showroom").w_showroom().run();
});
