
// function to show and hide the menu
function showMenuLayer2(obj){
	if(!hasClass(obj,'hover')){
		addClass(obj,'hover');
	};
}

function hideMenuLayer2(obj){
	if(hasClass(obj,'hover')){
		removeClass(obj,'hover');
	};
}


function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {

	if (!this.hasClass(ele,cls))  {
		ele.className += " "+cls;
		}
}

function removeClass(ele,cls) {

if (hasClass(ele,cls)) {
	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
	ele.className=ele.className.replace(reg,' ');
	}
}

// <![CDATA[


jQuery(window).resize(function() {
	contentResize();
});


function contentResize(){
	var windowSize	= jQuery(window).height();

	var overallHeight	= jQuery("#pageOverallWrapper").outerHeight(true);
	var pageTitleHeight	= jQuery("#pageTitle").outerHeight(true);
	var headerHeight	= jQuery("#pageHeaderMiddle").outerHeight(true);
	var footerHeight	= jQuery("#pageFooterMiddle").outerHeight(true);

	var newHeight	= overallHeight - headerHeight - footerHeight - pageTitleHeight;

	var testSize	= newHeight + headerHeight + footerHeight + pageTitleHeight;
	
	if( newHeight < 250) {
		newHeight = 250;
	}

	/**
	 * calculate the size again because webit doews have a calculation problem!
	 */
	if (jQuery.browser.webkit) {
		newHeight = newHeight - 8;
		jQuery("#pageFooterMiddle").outerHeight(footerHeight-5);
		jQuery("#pageFooterMiddle").css("border-bottom","none");
	} else {
	}



	jQuery("#pageBodyColumnMiddle").outerHeight(newHeight);

	var wingLeftPos	= jQuery("#wing-left").position();
	jQuery("#flash-link a").css("left", wingLeftPos.left -125);
	jQuery("#flash-content").css("left",wingLeftPos.left );
	jQuery("#flash-content").css("top",wingLeftPos.top + 3);
	jQuery("#pageFooterWrapper").css("bottom",0);
}


jQuery(document).ready(function() {

function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}

	/*
	 * calculate content
	 */
	var headerHeight	= jQuery("#pageHeaderWrapper").height();
	var contentHeight	= jQuery("#pageBodyWrapper").height();
	var contentLeft		= jQuery("#pageBodyColumnMiddle").position()
	jQuery("#middleContentBackgroundWrapper").css("top",parseInt(contentHeight)+parseInt(headerHeight));
	jQuery("#middleContentBackgroundWrapper").css("left", contentLeft.left);
	jQuery("#flash-helper").css("left", contentLeft.left);

	// content height
	contentResize();


	var flashHelper				= jQuery("#flash-helper");
	var navigation				= jQuery("#t3Navigation-Main");
	var subNavigation			= jQuery("#tq-subMenu");
	var content					= jQuery("#pageBodyColumnMiddleContent");
	var pageLogo				= jQuery("#pageLogo");
	var flashLink				= jQuery("#flash-link");
	//var flashLinkContainer		= jQuery("#flash-link a");
	var flashContent			= jQuery("#flash-content");
	
	
	flashLink.click(function(event) {
		event.preventDefault();
		event.stopPropagation();
		
		if(isiPhone()){
	
	jQuery("#flash-content").html("<video id='video' width='590' height='295' src='fileadmin/templates/flash/geschichte.m4v' autobuffer autoplay>"+
          "<div class='fallback'>"+
               "<p>You must have an HTML5 capable browser.</p>"+
	"</div>"+
	"</video>");
	
	var video = jQuery("#video").get(0);		
	  video.play();
	
	} else {
		

		flashembed("#flash-content", {
			src:				"fileadmin/templates/flash/geschichte.swf",
			allowfullscreen:	false,
			menu:				false,
			wmode:				"opaque"


		});
	}
		pageLogo.addClass("flash");
		flashContent.show();
		flashHelper.show();
		navigation.hide();
		subNavigation.hide();
		content.hide();
		//flashLinkContainer.hide();
	});

	flashContent.click(function(event) {
		event.preventDefault();
		event.stopPropagation();
	});

	jQuery(document).click(function(event) {
		pageLogo.removeClass("flash");
		flashContent.hide();
		flashContent.html("");
		flashHelper.hide();
		navigation.show();
		subNavigation.show();
		content.show();
		//flashLinkContainer.show();
	});
});
// ]]>


