/********************************************************************/
// vars
/********************************************************************/

var sExpressInstall = "../pix/expressInstall.swf";
var requiredFlashVersion = "9.0.0";

/********************************************************************/
// general functions
/********************************************************************/

// address flash movie for external interface in action script
function thisMovie( movieName )
{
    if ( navigator.appName.indexOf("Microsoft") != -1 )
    {
        return window[movieName];
    }
    else
    {
        return document[movieName];
    }
}

function stopSlideshow() {
	var slideshow = swfobject.getObjectById('slideshowObject');
	if (slideshow) {
		slideshow.stopSlideshow();
	}
}

function startSlideshow() {
	var slideshow = swfobject.getObjectById('slideshowObject');
	if (slideshow) {
		slideshow.startSlideshow();
	}
}

var createId = (function() {
	var genericPrefix = 'jsid';
	var ids = {};

	return function(prefix) {
		prefix = prefix || genericPrefix;

		if (typeof ids.prefix == "undefined") {
			ids.prefix = 0;
		}

		ids.prefix += 1;

		return prefix + "-" + ids.prefix;
	};
})();

/********************************************************************/
//CONTENT
$(document).ready(function(){

	$(".show").click(function(ev){
		ev.preventDefault();
		if ($("#content").is(":visible")) {
			$(".show").addClass("close");
			$("#content").slideUp(60);
		} else {
			$(".show").removeClass("close");
			$("#content").slideDown(60);
		}
	});

	$("body").addClass("jsenabled");


	$(".tabs").each(function() {
		var navItems = [], tabs = [];
		$(this).children(":header").
			each(function() {
				var header = $(this), next = header.next().get(0);
				if (!next || next.nodeName == this.nodeName) { return; }

				if (!next.id) {
					next.id = createId("tab");
				}
				navItems.push([next.id, header.text()]);
				tabs.push(next);
			});

		tabs = $(tabs).removeClass("current");
		if (tabs.is(window.location.hash)) {
			$(window.location.hash).addClass("current");
		}
		else {
			tabs.filter(":first").addClass("current");
		}

		var setActiveLink = function(liNode) {
			var li = $(liNode);
			var link = li.find("a:first");

			li.parent().find("strong").each(function() {
				$(this).replaceWith($(this.parentNode).data("inform.tabs.link"));
			});

			link.replaceWith($(document.createElement("strong")).text(link.text()));
		};
		var nav = $(document.createElement("ol")).addClass("paging");
		for (var i=0, item; item=navItems[i]; i+=1) {
			nav.
				append("<li><a></a></li>").
				find("a:last").
					attr("href", window.location.href.replace(/#.*$/, '') + "#" + item[0]).
					text(item[1]).
					parent().
						data("inform.tabs.target", $("#"+item[0])).
						data("inform.tabs.link", $(nav.get(0).lastChild).children("a:first")).
						click(function(event) {
							setActiveLink(this);
							var tab = $(this).data("inform.tabs.target");

							tab.
								addClass("current").
								siblings().
									removeClass("current");

							event.preventDefault();
						});
		}

		var firstChild = nav.children(":first").addClass("first");
		setActiveLink(firstChild.get(0));

		$(this).prepend(nav);
	});

	//LIGHTWINDOW
	$(document).ready(function() {
		$(".imgNavi a").fancybox({
				'frameWidth': 800,
				'frameHeight': 600,
				'overlayOpacity': 0.8
		});

	});
});

