isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
isIE = navigator.userAgent.indexOf("MSIE") > -1;

nextElementID = 0;

seiten=[];

window.addEvent('domready', function(){
	//CT_LayerLink.layerUrlPrefix = 'layer/';
	l = new CT_Layer();
	l.documentContainer = $('page');

	var p = new CT_Processor();
	p.registerList([CT_HoverItem]);
	p.process($(document.body));

	if(currentSection){
		$('nav' + currentSection).store('CT_Toggled', true);
		$('nav' + currentSection).fireEvent('refresh');
	}

	if(currentSubSection){
		$('subNav' + currentSubSection).store('CT_Toggled', true);
		$('subNav' + currentSubSection).fireEvent('refresh');
	}

	if(currentSubSection2){
		$('subNav' + currentSubSection2).store('CT_Toggled', true);
		$('subNav' + currentSubSection2).fireEvent('refresh');
	}
});

/*function init(aktSeiten){
	seiten=aktSeiten;
	var imga = document.getElementsByTagName('img');
	for(var i=0;i<imga.length;i++){
		if(imga[i].src.indexOf('core/nav/')>0 || imga[i].src.indexOf('core/subnav/')>0 || imga[i].src.indexOf('core/icons/')>0)
			initMenuItem(imga[i]);
	}
}
function nover(obj){
	for(var i=0;i<seiten.length;i++){
		if(seiten[i]==obj) return;
	}

	if(obj.src.lastIndexOf('_over') == -1)
		obj.src = obj.src.substr(0,obj.src.length-4)+"_over.gif";
}
function noverFFIE(e){
	if(e)
		nover(e.originalTarget);
	else
		nover(window.event.srcElement);
}
function noutFFIE(e){
	if(e)
		nout(e.originalTarget);
	else
		nout(window.event.srcElement);
}

function nout(obj){
	for(var i=0;i<seiten.length;i++){
		if(seiten[i]==obj) return;
	}

	if(obj.src.lastIndexOf('_over') > -1)
		obj.src = obj.src.substr(0,obj.src.length-9)+".gif";
}
function initMenuItem(pic){
	var tempPic = new Image();
	tempPic.src = pic.src.substr(0,pic.src.length-4)+"_over.gif";

	if(isFirefox||isIE){
		pic.onmouseover=noverFFIE;
		pic.onmouseout=noutFFIE;
	}else{
		pic.onmouseover="nover(this);";
		pic.onmouseout="nout(this);";
	}
	if(pic.src.lastIndexOf("/nav/")>-1){
		if(pic.src.lastIndexOf(seiten[0])>-1){
			nover(pic);
			seiten[0]=pic;
		}
	}else if(pic.src.lastIndexOf("/subnav/")>-1){
		var lvl = pic.src.lastIndexOf("subnav_") + 7;
		lvl = pic.src.substring(lvl,lvl+1);
		if(seiten[lvl]!="" && pic.src.lastIndexOf(seiten[lvl])>-1){
			nover(pic);
			seiten[lvl]=pic;
		}
	}
}*/

function focusSearchBar(bar){
	if(bar.value=="suchbegriff") bar.value="";
}
function blurSearchBar(bar){
	if(bar.value=="") bar.value="suchbegriff";
}
function getNextElementID(){
	nextElementID++;
	return nextElementID-1;
}
function addSWF(file, width, height, flashVarsString){
	var id = "mediaContent_"+getNextElementID();
	document.writeln('<div id="'+id+'">');
	document.writeln('<p>Das Element kann nicht angezeigt werden. Installieren Sie bitte den Flash Player.</p>');
	document.writeln('<p><a class="none" href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>');
	document.writeln('</div>');
	document.writeln('<script type="text/javascript">');
	document.writeln('loadSWF("'+id+'","'+file+'", "'+width+'", "'+height+'",'+flashVarsString+');');
	document.writeln('</script>');
}
function loadSWF(id, file, width, height, flashvars, parameters, attributes){
	if(!parameters) parameters = {};
	if(!parameters.bgcolor) parameters.bgcolor = "#FFFFFF";
	if(!parameters.allowScriptAccess) parameters.allowScriptAccess = "always";
	parameters.allowFullscreen = "true";
	if(!attributes) attributes = {};
	if(width>640)
		attributes.style = "position:relative;left:"+Math.round((640-width)/2)+"px;";
	//if(width > 700) attributes["class"] = "mediaContentWide";
	swfobject.embedSWF(file, id, width, height, "9.0.0", "core/swf/expressInstall.swf", flashvars, parameters, attributes);
}
function loadMediaItem(config, width, height){
	if(!width) width = 800;
	if(!height) height = 480;
	loadSWF("mediaarea", "core/swf/cyantreeMediaPlayer.swf?b2", width, height, {"config":config, masterConfig:"core/contents/playlists/masterconfig.xml?v2"});
	if(!swfobject.hasFlashPlayerVersion('9.0.0'))
		document.getElementById('mediaarea').innerHTML = '<p>Das Element kann nicht angezeigt werden. Installieren Sie bitte den Flash Player.</p><p><a class="none" href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>';
}
