﻿// ==========================================
//	v3.6, singlepage
//	diverse CMS Standard JavaScript-Funktionen
// ==========================================

/*
	31.01.2009, dogan

	©2009 Tanyel Dogan, alle Rechte vorbehalten
*/
function cms4d_write_flash(movie_src
							,f_objid
							,f_width
							,f_height
							,f_align
							,f_allow_script_access
							,f_loop
							,f_menu
							,f_quality
							,f_scale
							,f_salign
							,f_wmode
							,f_bgcolor
							,version_str)
{
	var src = movie_src;
	var t = '';
t += '<object';
t += '\n classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
t += '\n codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version_str + '"';
t += '\n width="' + f_width + '"';
t += '\n height="' + f_height + '"';
t += '\n id="' + f_objid + '"';
t += '\n align="' + f_align + '">\n';
t += '\t<param name="allowScriptAccess" value="' + f_allow_script_access + '"/>\n';
t += '\t<param name="movie" value="' + src + '"/>\n';
t += '\t<param name="loop" value="' + f_loop + '"/>\n';
t += '\t<param name="menu" value="' + f_menu + '"/>\n';
t += '\t<param name="quality" value="' + f_quality + '"/>\n';
t += '\t<param name="scale" value="' + f_scale + '"/>\n';
t += '\t<param name="salign" value="' + f_salign + '"/>\n';
t += '\t<param name="wmode" value="' + f_wmode + '"/>\n';
t += '\t<param name="bgcolor" value="' + f_bgcolor + '"/>\n';
	t += '\t<embed src="' + src + '"';
	t += '\n loop="' + f_loop + '"';
	t += '\n menu="' + f_menu + '"';
	t += '\n quality="' + f_quality + '"';
	t += '\n scale="' + f_scale + '"';
	t += '\n salign="' + f_salign + '"';
	t += '\n wmode="' + f_wmode + '"';
	t += '\n bgcolor="' + f_bgcolor + '"';
	t += '\n width="' + f_width + '"';
	t += '\n height="' + f_height + '"';
	t += '\n name="' + f_objid + '"';
	t += '\n align="' + f_align + '"';
	t += '\n allowScriptAccess="' + f_allow_script_access + '"';
	t += '\n type="application/x-shockwave-flash"';
	t += '\n pluginspage="http://www.macromedia.com/go/getflashplayer"/>\n';
t += '</object>';
//alert(t);
document.write(t);
}


//Positioniert einen Container mittig in einem übergeordneten offsetParent.
//ACHTUNG: die apple webkit Browser chrome und safari haben Probleme das DOM
//korrekt auszumessen solange die Seite noch nicht einmal komplett dargestellt wurde.
//Hier kommt es sporadisch zu falschen Messergebnissen, so dass das Element rest
//sichtbar später in die Mitte gerückt wird.
//Um diesen optischen Effekt so gering wie möglich zu halten werden mehrere
//schnelle Schleifendurchläufe ausgeführt. Das delay ist so kurz, dass auch das
//Springen des Elementes nach rechts nur für einen Sekundenbruchteil wahrzunehmen ist, wenn überhaupt.
function center_control(container_id)
{
	if(! window.cms4d_center_control_counter)window.cms4d_center_control_counter = 0;
	window.cms4d_center_control_counter++;
	this.ctrlid = 'center_control_' + window.cms4d_center_control_counter;
	//Im window-Kontext wird eine Eigenschatf hinzugefügt, über die dann in den Timerschleifen
	//direkt auf das Objekt zugegriffen werden kann.
	window[this.ctrlid] = this;
	this.timerid = null;
	this.timerdelay = 20;
	this.loopcounter = 0;
	this.loopmax = 50;
	this.container_id = container_id;
	this.container_div = null;
	this.pdiv = null;
	this.center_menu = function()
	{
		clearTimeout(this.timerid);
		this.loopcounter++;
		if(this.loopcounter > this.loopmax)return;

		this.container_div = document.getElementById(this.container_id);
		if(this.container_div != null)
		{
			this.pdiv = this.container_div.parentNode;
		}

		if(this.pdiv != null)
		{
			var pw = this.pdiv.offsetWidth;
			var cw = this.container_div.offsetWidth;
			var cx = Math.round((pw - cw) / 2);
			if(cx < 0)cx = 0;
			{
				this.container_div.style.left = cx + 'px';
			}
		}
		//Loop
		var func_str = 'window.' + this.ctrlid + '.center_menu()';
		this.timerid = setTimeout(func_str, this.timerdelay);
	}
	this.center_menu();
}



//------------- Standard neues Fenster öffnen ------------
function neuwindow(fenstername, url, w, h, status_flag, resize_flag, scroll_flag)
{
	var aw = screen.availWidth;
	var ah = screen.availHeight;
	if(w == null || h == null)
	{
		wb = screen.availWidth - 100;
		wh = screen.availHeight - 100;
	}
	else
	{
		wb = w;
		wh = h;
	}
	var wx = (aw / 2) - (wb / 2) - 6;
	var wy = (ah / 2) - (wh / 2) - 30;

	var status_enable = 1;
	if(status_flag != null)status_enable = status_flag;
	var scroll_enable = 1;
	if(scroll_flag != null)scroll_enable = scroll_flag;
	var resize_enable = 1;
	if(resize_flag != null)resize_enable = resize_flag;

	var fenster = window.open(url,fenstername,'toolbar=0,location=0,directories=0,status=' + status_enable + ',menubar=0,scrollbars=' + scroll_enable + ',resizable=' + resize_enable + ',Width=' + wb + ',height=' + wh + ',left=' + wx + ',top=' + wy);
	//return(fenster);
}



//------- Bild Zoomfunktion ----------
//Veraltet. Aus Gründen der Rückwärtskompatibilität vor v1.6 beibehalten !
function zoomwindow(url) 
{
	var wb = 300;
	var wh = 300;
	var sx = screen.width;
	var sy = screen.height;
	var wx = (sx / 2) - (wb / 2);
	var wy = (sy / 2) - (wh / 2);

	//WICHTIG: das window MUSS resizeable sein, da sonst Netscape 4.x
	//die Grösse nachträglich nicht ändern kann !

	zoomwin=window.open(url,'Zoom',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,WIDTH=" + wb + ",HEIGHT=" + wh + ",left=0,top=0,left=" + wx + ",top=" + wy)
	zoomwin.focus();
}
//ab v3.6
/*
function zoom(id)
{
	var url = 'cmszoom.asp?id=' + id;
	//WICHTIG: BasisURL der aufrufenden Seite einbeziehen.
	if(page_baseurl)
	{
		url = page_baseurl + url;
	}
	zoomwindow(url);
}
*/

function change_css1(obj,c)
{
	obj.className = c + '_on';
}

function change_css2(obj,c)
{
	obj.className = c;
}



function bg_balken_height()
{
	this.timerid = null;
	this.timerdelay = 20;
	this.loopcounter = 0;
	this.loopmax = 60;
	this.check_height = function()
	{
		clearTimeout(this.timerid);
		this.loopcounter++;
		if(this.loopcounter > this.loopmax)return;
		var img_div = document.getElementById('top_img_container');
		var bar_div = document.getElementById('bg_balken');
		var img_height = 0;
		//Ist kein Bild vorhanden bleibt der Balken-DIV auf der in CSS fesgelegten Standardhöhe. Es wäre theoretisch auch möglich
		//ihn dann ganz auszublenden. Darauf wird hier aber aus gestalterischen Gründen verzichtet. Ausserdem
		//würde bei der Weiche der DIV dann jedesmal wieder display:block gesetzt werden müssen. Dies verursacht
		//aber Darstellungsfehler beim Drucken, da dort der DIV immer display:none sein soll.
		//Im Grunde wird immer ein kleiner Sprung in der Balkenhöhe kurz sichbar sein. Deshalb sollten die
		//Kopfbilder für die Inhaltsseiten in der Höhe exakt der CSS Standardhöhe entsprechen. Dann ändert sich
		//durch diese JS-Funktion sichtbar kaum etwas.
		if(img_div != null && bar_div != null)
		{
			img_height = img_div.offsetHeight;
			//Es muss eine Minimalhöe überschritten sein. Dann ist mit relativer Sicherheit schon ein Teil des
			//Bildes geladen und das IMG-Element ggf. auf die Breite/Höhe des geladenen Bildes ausgedehnt.
			//Ist hingegen die Bildquelle fehlerhaft, so ist das IE-Fehlerbild i.d.R. ca. 40x40px groß, so dass
			//der Balken auf der voreingestellten CSS-height verbleibt. Bilder mit weniger als 80px Höhe machen hier
			//sowieso gestalterisch kaum Sinn.
			if(img_height > 80)
			{
				bar_div.style.height = img_height + 'px';
			}
		}
		//document.title = this.loopcounter + ': ' + this.timerdelay + ' | ' + img_height;

		var func_str = 'window.bgh_ctrl.check_height()';
		//Die Testschleife beginnt sehr schnell. Das Interval wird mit jedem Durchlauf langsamer und max. 1000ms
		if(this.timerdelay < 1000)this.timerdelay += 20;
		this.timerid = setTimeout(func_str, this.timerdelay);
	}
	this.check_height();
}
window.bgh_ctrl = new bg_balken_height();


function gotop()
{
	//document.location.href = '#top';
	window.scrollTo(0,0);
}


//---