﻿// ==========================================
//	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 show_hinweis()
{
	var obj = document.getElementById('haftungsverzichtserklerung_text');
	var mode = obj.style.display;
 
	if(mode == 'none')
	{
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
	}
	else
	{
		obj.style.display = 'none';
		obj.style.visibility = 'hidden';
	}
}

function gotop()
{
	//document.location.href = '#top';
	window.scrollTo(0,0);
}


//Hilfsfunktion, die den aufgeklappten sub-Container des letzten Dropdown-Tabs rechtsbündig ausrichtet.
//ACHTUNG: IE bug
//Das Ein- und Ausblenden des Tabs erfolgt in allen Browsern per CSS hover.
//IE stellt aber beim ersten aufruf dieser Funktion hier, also beim ersten hover nur eine offsetWidth von 0px fest.
//Erst nach dem zweiten hover wird immer die korrekte Breite des jetzt sichtaren tab ermittelt (>0).
//Dies könnte daran liegen, dass zum Zeitpunkt des mousover-Events der tab-DIV noch nicht sichtbar ist.
//Elemente mit display:none geben aber keine Breite/Höhe zurück.
//Alle anderen Browser geben auch ohne Tricks sofort die richtige Breite zurück.
//Um das Problem zu beheben, könnte tab vor der Messung kurzfristig explizit style.display=block und nach der Messung
//wieder style.display='' gesetzt werden. Dies führt aber im IE7 und IE8 Kompatibilitätsmodus zu Darstellungsfehlern auf dem
//tabjoin-DIV. Deshalb wird hier die gewünschte Breite explizit numerisch angegeben (s. C# Funktion tab_width).
function cms4d_dropdown_align_last(e, tab_width)
{
	var p = e.parentNode;
	var tab = null;
	for(var i = 0; i < p.childNodes.length; i++)
	{
		var cnode = p.childNodes[i];
		if(cnode.className == 'tab')
		{
			tab = cnode;
			break;
		}
	}
	if(tab == null)return;
	var pw = p.offsetWidth;
	//Auch wenn tab weniger breit ist als der übergeordnete Registerbutton wird auf eine Neupositionierung verzichtet.
	if(pw < 1 || tab_width < 1 || tab_width < pw)return;
	var x = pw - tab_width;
	//tab ist in CSS schon absolut positioniert. Deshalb kann hier direkt left auf einen negativen Wert gesetzt werden.
	tab.style.left = x + 'px';
}


//---
