/*
Autor: Kai Röder
Erstellt am: 26/05/2009
Kommentar: Die Inhalte dieses Scripts dürfen ohne Nachfrage kopiert und verändert werden.

++++ Beschreibung ++++
Benötigt wird ein DIV (<div id='LC_Switch'></div>) für die Ausgabe der Auswahl und ein Wrap-DIV zum 
formatieren des Inhalts via CSS oder ähnlichem.
Innerhalb dieses Wraps müssen die verschiedenen Inhalte mit folgender Syntax stehen:
-- <div id="LC_Content_1">FOO</div>
-- <div id="LC_Content_2">Bar</div>

In der beiliegenden CSS (layerchanger.css) kann die Formatierung des Switchers bearbeitet werden. 
*/
function LayerChange(_AnzLayer, _ObjName, _DivName) // Mode = 0 => Switcher-Ausgabe in Zahlen, Mode = 1 => Switcher-Ausgabe in Text 
{
	this.AnzLayer = _AnzLayer;
	this.ObjName = _ObjName;
	this.DivName = _DivName;
	this.CookieDel = 1000*60*60;
	
	this.CurrentLayer = 0;
	this.FirstStart = true;
	
	this.HideDivs = function() {
		for(var i=0; i<this.AnzLayer; i++)
		{
			document.getElementById("LC_" + this.DivName + "_" + i).style.display = 'none';
		}

		document.getElementById("LC_" + this.DivName + "_0").style.display = 'block';
	}
	
	this.OutputSwitcherNum = function() 
	{
		var NumOut = 1;
		
		for(var i=0; i<this.AnzLayer; i++)
		{
			NumOut = i+1;
			document.getElementById("LC_Switch_" + this.ObjName).innerHTML += "<div class='lc_changer_num'><a href='' id='lc_num_"+i+"' onClick='" + this.ObjName + ".ChangeLayer(" +i+ "); return false;'>"+ NumOut +"</a></div>";
			document.getElementById("lc_num_0").style.backgroundColor = '#337399';
		}
	}
	
	this.OutputSwitcherStr = function(_StringArray) 
	{
		var NumOut = 1;
		
		for(var i=0; i<this.AnzLayer; i++)
		{
			NumOut = i+1;
			document.getElementById("LC_Switch_" + this.ObjName).innerHTML += "<div class='lc_changer_str'><a href='' onClick='" + this.ObjName + ".ChangeLayerStr(" +i+ "); return false' id='LC_str_" +i+ "'>"+ _StringArray[i] +"</a></div>";
		}
		document.getElementById("LC_str_0").style.backgroundColor = '#337399';
	}
	
	this.ChangeLayer = function (id, timeout) {
		for(var i=0; i<this.AnzLayer; i++)
		{
			document.getElementById("LC_" + this.DivName + "_" + i).style.display = 'none';
			document.getElementById("lc_num_" + i).style.backgroundColor = '';
		}
		
		document.getElementById("LC_" + this.DivName + "_" + id).style.display = 'block';
		document.getElementById("lc_num_" + id).style.backgroundColor = '#337399';
		if(timeout == true) { clearInterval(Switch); }
		
		this.CurrentLayer = id;
	}
	
	this.ChangeLayerStr = function(id)
	{
		for(var i=0; i<this.AnzLayer; i++)
		{
			document.getElementById("LC_" + this.DivName + "_" + i).style.display = 'none';
			document.getElementById("LC_str_" +i).style.backgroundColor = '';
		}	
		document.getElementById("LC_" + this.DivName + "_" + id).style.display = 'block';
		document.getElementById("LC_str_" +id).style.backgroundColor = '#337399';
	}	
	
	this.AutoSwitch = function() 
	{
			if(this.CurrentLayer == this.AnzLayer)
			{
				this.CurrentLayer = 0;
			}
			
			if(this.FirstStart == true) {
				this.ChangeLayer(1, false);
				this.FirstStart = false;
			} else {
				this.ChangeLayer(this.CurrentLayer, false);
			}
			
			this.CurrentLayer++;

	}
	
	this.SaveCookie = function(n,w,expire) {
		document.cookie = n+'_SaveChange='+w+'; expires='+ expire +';'; 
	}
	

}