// =================>				Content-Initialisierung				<===============
// ==============================================================================
// <Copyright: Martin Kaiser><Chili-Site Web Design><www.chili-site.de><webdesign@chili-site.de>
// ==============================================================================

//	===== Content Variablen =====
var pos_co; var co = new Array(); var LastLvl = new Array(); LastLvl[0] = 0

//	=====	Function AddContent	=====
function  coa(level, url, text, OneImg)
{
if (arguments.length < 4) {var OneImg = null}
co_pos = co.length
co[co_pos] = new co_new(level, url, text, co_pos, OneImg)
}

//	=====	Function NewContent	=====
function co_new(level, url, text, co_pos, OneImg)
{
this.level = level
this.text = text
this.visible = false
if ( OneImg != null)	{this.img = OneImg}

// Directory = YES
if (url.indexOf("DIR") >= 0)
	{
	this.dir = true
	this.url = url.replace("DIR", "")
	this.open = false
	LastLvl[level] = co_pos
	}
// Directory = NO
if (url.indexOf("DIR") < 0)
	{
	this.dir = false
	this.url = url
	}

this.up = LastLvl[level-1]
if (level == 1)	{this.visible = true}
}

//	=====	Function WatchingChanges	=====
var DocChange = false

function WatchingChanges()
{
if (DocChange)
{DocChange = false; SearchContent()}
window.setTimeout('WatchingChanges()', 500)
}

//	=====	Function SearchContent	=====
var ActLoc = ""

function SearchContent()
{
var URL = main.location.href
URL = URL.replace(RootPath, "")
if (ActLoc != URL)
	{for ( var i = 0; i <co.length; i++) {
		if (co[co[i].up].url + co[i].url == URL)	{ActLoc = URL; OpenEntry(i); break} }
	}
}

//	=====	Function OpenEntry	=====
var ActNr; var ActOne = -1; var ActTwo; var SelOne; var SelTwo; var ChangeTitleCont

function OpenEntry(Nr)
{
ActNr = Nr; ActTwo = 0; SelOne = 0; SelTwo = 0
for ( var i = Nr; i >= 0; i--) {
	i = co[i].up
	co[i].open = true;
	if (co[i].level == 2) {ActTwo = i}
	if (co[i].level == 1)
		{
		if ( i != ActOne)	{ChangeTitleCont = true}
		else				{ChangeTitleCont = false}
		ActOne = i; break
		}
	i = i + 1
	}
SetVisible(Nr)
}

//	=====	Function OpenDir	=====
function OpenDir(Nr)
{
SelOne = 0; SelTwo = 0
co[Nr].open = !co[Nr].open
for ( var i = Nr; i >= 0; i--) {
	if (co[i].level == 2) {SelTwo = i}
	if (co[i].level == 1) {SelOne = i; break}
	i = co[i].up + 1
	}

SetVisible(Nr)
}

//	=====	Function SetVisible	=====
function SetVisible(Nr)
{
// alert(Nr + "#" + ActOne)
for ( var i = 0; i < co.length; i++)
	{
	if(co[i].level ==1 && HideLevelOne)
		{
		if ( i == ActOne)	{co[i].visible = true}
		if ( i != ActOne)	{co[i].visible = false}
		}
	if(co[Nr].level == 1) {
		if(co[i].level ==1 && CloseLevelOne && i!=Nr)
			{co[i].open = false}
		if(co[i].level ==1 && CloseLevelOne && i==Nr) {
			ActOne = Nr
			WriteTitelCont()
			}
		}

//	if(co[i].level ==1 && CloseLevelOne && i !=ActOne && i!=SelOne)
//		{co[i].open = false}

	if(co[i].level ==2 && CloseLevelTwo && i !=ActTwo && i!=SelTwo)
		{co[i].open = false}

	if(co[i].level >= 2)
		{
		if (co[co[i].up].open && co[co[i].up].visible) {co[i].visible = true}
		else {co[i].visible = false}
		}
	} 
if (HideLevelOne) {co[ActOne].visible = false}
WriteContent(Nr)
}

//	=====	Function WriteContent	=====
function WriteContent(Nr)
{
with(self.content)
	{
	window.document.open("text/html", "replace")
	window.document.write(GetContentHtml(Nr))
	window.document.close()
	}
if (!co[Nr].dir)			{WriteTitel()}
if (ChangeTitleCont)	{WriteTitelCont()}
}

//	=====	Function WriteTitel	=====
function WriteTitel()
{
GetDate(); GetTitel()
with(self.titel)
	{
	window.document.open("text/html", "replace")
	window.document.write(GetTitelHtml())
	window.document.close()
	}
}

//	=====	Function WriteTitelCont	=====
function WriteTitelCont()
{
with(self.locationbar)
	{
	window.document.open("text/html", "replace")
	window.document.write(GetTitelContHtml())
	window.document.close()
	}
}

//	=====	Function GetDate	=====
var UpYear; var UpDay; var UpMonth; var UpWoTag; var UpMoNam
var UpHours; var UpMin; var UpSec

if (ShortDay)	{var WoTage ="So.?Mo.?Di.?Mi.?Do.?Fr.?Sa."}
else			{var WoTage ="Sonntag?Montag?Dienstag?Mittwoch?Donnerstag?Freitag?Samstag"}
var WoTag = new Array(); WoTag = WoTage.split("?")

if (ShortMonth)	{var MoNamen ="?Jan.?Feb.?Mär.?Apr.?Mai?Jun.?Jul.?Aug.?Sep.?Okt.?Nov.?Dez."}
else				{var MoNamen ="?Januar?Februar?März?April?Mai?Juni?Juli?August?September?Oktober?November?Dezember"}
var MoNam = new Array(); MoNam = MoNamen.split("?")

function GetDate()
// ===
{
var UpDate = new Date (main.document.lastModified)
UpYear		= UpDate.getFullYear()
UpDay		= UpDate.getDate(); if (UpDay <10) {UpDay = "0" + UpDay}
UpMonth	= UpDate.getMonth() + 1
UpMoNam	= MoNam[UpMonth]
if (UpMonth <10) {UpMonth = "0" + UpMonth}
UpWoTag	= WoTag[UpDate.getDay()]
UpHours		= UpDate.getHours(); if (UpHours <10) {UpHours = "0" + UpHours}
UpMin		= UpDate.getMinutes(); if (UpMin <10) {UpMin = "0" + UpMin}
UpSec		= UpDate.getSeconds(); if (UpSec <10) {UpSec = "0" + UpSec}
}

//	=====	Function GetTitel	=====
var DocTitel

function GetTitel()
{
DocTitel = main.document.title
DocTitel = DocTitel.replace(TitelRoot, "")
var AllTitel = new Array(); AllTitel = DocTitel.split(" & ")
DocTitel = AllTitel[0]
}

// ==============================================================================
// <Copyright: Martin Kaiser><Chili-Site Web Design><www.chili-site.de><webdesign@chili-site.de>
// ==============================================================================
