function initTabs(container) {
	contentUrl = $(container).parents("li").find(".handle a").attr("href");
	sectionName = contentUrl.replace(/.*\/(.*)\.html/, "$1");
	if($(container).children(".content-element").length > 0) {
		contentElementList = '<ul>';
		$(container).children(".content-element").each(function(iterator) {
			$(this).attr("id", sectionName + iterator);
			title = $(this).find("h1").text();
			contentElementList += '<li><a href="#' + sectionName + iterator + '"><span>' + title + '</span></a></li>';
			extraParagraphs = $(this).find("p:gt(0)");
			if(extraParagraphs.length > 0) {
				$("body").append('<div id="' + sectionName + iterator + '-more" style="display:none"></div>');
				moreSection = $("#" + sectionName + iterator + "-more");
				$(this).find("h1").clone().appendTo(moreSection);
				$(this).find("p:eq(0)").clone().appendTo(moreSection);
				extraParagraphs.appendTo(moreSection);
				$(this).find("p:eq(0)").append('&nbsp;<a href="#' + sectionName + iterator + '-more" id="' + sectionName + iterator + '-more-link" class="more-link">[ ' + label["more"] + '... ]</a>');
				$(this).find("p:eq(0) a#" + sectionName + iterator + "-more-link").fancybox({"padding": 20, "frameWidth": 550, "frameHeight": "auto", "overlayOpacity": 0.5});
			}
			$(this).find("h1").remove();
		});
		contentElementList += '</ul>';
		$(container).prepend(contentElementList);
		$(container).tabs({ fx: { opacity: 'toggle' } });
	}
}

$(document).ready(function() {
	$(".listItemStatic").each(function() {$(this).replaceWith('<li class="listItem">' + $(this).html() + '</li>');});
	$(".listItemStatic").each(function() {$(this).replaceWith('<li class="listItem">' + $(this).html() + '</li>');});
	$(".handleStatic").each(function() {$(this).replaceWith('<div class="handle">' + $(this).html() + '</div>');});
	$(".contentWrapperStatic").each(function() {$(this).replaceWith($(this).html());});
	$(".contentInnerWrapperStatic").each(function() {$(this).replaceWith($(this).html());});
	$(".contentContainerStatic").each(function() {$(this).replaceWith($(this).html());});
	$(".menu").hrzAccordion({
		openOnLoad				: currentPageIndex,
		handlePosition			: "right"
	});
	$(".contentContainer").css("overflow", "hidden");
	$(".contentInnerWrapper").each(function() {
		if($(this).html().replace(/\s+/, "") != "") {
			initTabs(this);
		}
	});
	$('.news-item a').each(function() {
		$(this).fancybox({"padding": 20, "frameWidth": 550, "frameHeight": "auto", "overlayOpacity": 0.5, "transformLink": transformLink});
	});
	$(".handle").each(function() {
		contentInnerWrapper = $(this).parent("li").find(".contentInnerWrapper");
		if(contentInnerWrapper.html().replace(/\s+/, "") == "") {
			contentUrl = $(this).find("a").attr("href");
			ajaxUrl = contentUrl.replace(".html", "/ajax");
			sectionName = contentUrl.replace(/.*\/(.*)\.html/, "$1");
			contentInnerWrapper.attr("id", sectionName);
// if(!$.browser.msie) {
			contentInnerWrapper.load(ajaxUrl, {}, function() {
				initTabs(this);
			});
// } else { }
		}
	});
});
