/*
ppzCore.js
Copyright (C) PEPPERZAK Multimedia GmbH 2001-2002
Author: Horst Pralow
Purpose: Provide JavaScript Core services for other JavaScript modules

History:	0.1	09/Jan/2002	New today
			0.2 22/Jan/2002 Remove several unused functions
			0.3 4/Sep/2003	Slight change in ppzCore_browser
*/


ppz_Core.prototype.inspect = function (inObj)
{
	var s = "";
	for (var p in inObj)	{
		s = s + p + ": " + inObj[p] + ";\n ";
	}
	var w = window.open("", "ppzConsole");
	w.document.open('text/plain');
	w.document.write(s);
	w.document.close();
}

ppz_Core.prototype.searchTree = function (inStart, inType, inName)
{
	var tree = inStart[inType];
	if (tree)	{
		for (var i = 0; i < tree.length; ++i)	{
			if (tree[i].name == inName)	{
				return tree[i];
			} else {
				var foundlayer = this.searchTree(tree[i], inType, inName);
				if (foundlayer) return foundlayer;
			}
		}
	}
	return null;
};


function ppz_Core ()
{
	this.app = new ppzCore_browser();

	if (this.app.compat_d_layers)	{
		document.ppzGetImageByName = function (inID, inDiv)
			{
				if (inDiv != "") {
					var lay = document.ppzCore.searchTree(document, 'layers', inDiv);
					return (lay) ? lay.document.images[inID] : null;
				} else {
					return document.images[inID];
				}	
			};
		document.__ppz_ns4_getLayerByName = function (inDiv)
			{
				return document.ppzCore.searchTree(document, 'layers', inDiv);
			}	

	}	else if (this.app.compat_d_all)	{
		document.ppzGetImageByName = function (inID, inDiv)
			{
				return document.all[inID];
			};
	}	else	{
		document.ppzGetImageByName = function (inID, inDiv)
			{
				return document.images[inID];
			};
	}
	
	this.pathprefix = "../../";
	return this;
}

if ((typeof(document.ppzCore) == 'undefined') || (!(document.ppzCore)))	{
	document.ppzCore = new ppz_Core();
}


// <!-- #PPZ
//	Browser object which detects and stores commonly
//	used properties for the browser it is run on.
//	The library creates an instance of this object at parse time.
//	This instance has the name "app".
//
//	Interface:
//		properties: All properties are Read-Only (r/o)
//			compat_dom: does this browser support the W3 Document Object Model (r/o)
//			compat_d_all: does this browser support the MSIE Document Object Model (r/o)
//			compat_d_layers: does this browser support the Nestacpe 4 Document Object Model (r/o)
//			version_name: The string returned by navigator.appVersion (r/o)
//			ie5, ie4, ns4:	Shorthand boolean flag for the respective browser (r/o)
//			platform: OS the browser runs on (r/o)
//			scrollfactor: corrector to apply for different OS's interpretations of setTimeout delay value
//			supported_browser: true if the browser is fully supported by this library
//		methods:
//			scrollspeed(inSpeed): returns OS dependant corrected value of inSpeed
// PPZ# -->


function ppzCore_browser()
{
	this.compat_dom = ((typeof(document.getElementById) != 'undefined') && (document.getElementById)) ? 1 : 0;
	this.compat_d_all = ((typeof(document.all) != 'undefined') && (document.all)) ? 1 : 0;
	this.compat_d_layers = ((typeof(document.layers) != 'undefined') && (document.layers)) ? 1 : 0;
	this.version_name = navigator.appVersion;
	this.ie5 = ((this.version_name.indexOf('MSIE') != -1) && this.compat_dom);
	this.ie4 = (this.compat_d_all && !this.compat_dom);
	this.ns4 = (this.compat_d_layers && !this.compat_dom);
	this.op5 = (this.compat_dom && (parseInt(this.version_name, 10) >= 5) && (navigator.appName.indexOf('Opera') != -1));
	this.ns6 = (this.compat_dom && (parseInt(this.version_name, 10) >= 5) && (navigator.userAgent.indexOf('Gecko') != -1));
	this.platform = (this.version_name.indexOf('Mac') != -1) ? 'mac' : ((this.version_name.indexOf('Win') != -1) ? 'win' : 'unix');
	this.screen_width = screen.width; 
	this.screen_height = screen.height; 
	this.supported_browser = (this.ie5 || (this.ie4 && (this.platform == "win")) || this.ns4 || this.op5 || this.ns6);
	return this;
}

if ((typeof(document.ppzRollList) == 'undefined') || (!(document.ppzRollList))){
	document.ppzRollList = new Array(0);
}

function __ppzArrayFind (inVal)
{
	for (var i = 0; i < this.length; i++)	{
		if (this[i] == inVal)	return i;
	}
	return -1;
}

function ppz_RollGroup(inDiv, inPathOff, inPathOn, inImgList)
{
	this.container = inDiv;
	this.idList = new Array(0);
	this.idList.ppzFindIndex = __ppzArrayFind;
	this.offPics = new Array(0);
	this.onPics = new Array(0);
	this.currentHigh = -1;
	this.tempHigh = -1;
	this.pathOff = inPathOff;
	this.pathOn = (inPathOn != '') ? inPathOn : this.pathOff;
	for (var i = 0; i < inImgList.length; i+=3)	{
		this.idList[this.idList.length] = inImgList[i];
		var k = new Image();
		k.src = this.pathOff + inImgList[i+1];
		this.offPics[this.offPics.length] = k;

		k =  new Image();
		if (inImgList[i+2] != '')	{
			k.src =	this.pathOn + inImgList[i+2];
		} else {
			var dot = this.offPics[this.offPics.length - 1].src.lastIndexOf('.');
			var suf = this.offPics[this.offPics.length - 1].src.substring(dot);
			k.src =	this.pathOn + this.offPics[this.offPics.length - 1].src.substring(0, dot) + '_on' + suf;
		}
		this.onPics[this.onPics.length] = k;
	}
	
	if (!(document.ppzRollList))	{
		document.ppzRollList = new Array(0);
	}
	document.ppzRollList[document.ppzRollList.length] = this;
	
	this.picOver = function	(inID)	{
		if (this.tempHigh != -1)	{
			this.picOut(this.tempHigh);
		}
		var idx = this.idList.ppzFindIndex(inID);
		if (idx != -1)	{
			var img = document.ppzGetImageByName('pic' + inID, this.container);
			img.src = this.onPics[idx].src;
			this.tempHigh = inID;
		}
	};
	
	this.picOut = function(inID)	{
		if (this.currentHigh == inID)	return;
		var idx = this.idList.ppzFindIndex(inID);
		if (idx != -1)	{
			var img = document.ppzGetImageByName('pic' + inID, this.container);
			img.src = this.offPics[idx].src;
			this.tempHigh = -1;
		}
	};
	return  this;
}

function ppzPicOver(n,inLayer)	
{	
	for (var i = 0; i < document.ppzRollList.length; ++i)	{
		if (document.ppzRollList[i].container == inLayer)	{
			document.ppzRollList[i].picOver(n);
			return;
		}
	}
}

function ppzPicOut(n,inLayer)
{	
	for (var i = 0; i < document.ppzRollList.length; ++i)	{
		if (document.ppzRollList[i].container == inLayer)	{
			document.ppzRollList[i].picOut(n);
			return;
		}
	}
}

function ppzPicClick(n,inLayer)	
{
	for (var i = 0; i < document.ppzRollList.length; ++i)	{
		if (document.ppzRollList[i].container == inLayer)	{
			if (document.ppzRollList[i].currentHigh != -1)	{
				var s = document.ppzRollList[i].currentHigh;
				document.ppzRollList[i].currentHigh = -1;
				document.ppzRollList[i].picOut(s);
			}
			document.ppzRollList[i].picOver(n);
			document.ppzRollList[i].currentHigh = n;
			document.ppzRollList[i].tempHigh = -1;
			return;
		}
	}
}

function ppzPicReset(inLayer)
{
	for (var i = 0; i < document.ppzRollList.length; ++i)	{
		if (document.ppzRollList[i].container == inLayer)	{
			if (document.ppzRollList[i].currentHigh != -1)	{
				document.ppzRollList[i].tempHigh = document.ppzRollList[i].currentHigh;
				document.ppzRollList[i].currentHigh = -1;
				document.ppzRollList[i].picOut(document.ppzRollList[i].tempHigh);
			}
		}
	}
}

function change_list(id, select)	{
	switch(id)	{
		case "Guestbook":
			openChild('/sixcms/detail.php?template=kontakt_frame&content_frame=guestbook','kontaktchild',690,450,'center','center','no','no','no','no','no');
			break;
		case "Newsletter":
			openChild('/sixcms/detail.php?template=kontakt_frame&content_frame=newsletter','kontaktchild',690,450,'center','center','no','no','no','no','no');
			break;
		case "E-Mail":
			openChild('/sixcms/detail.php?template=kontakt_frame&content_frame=email','kontaktchild',690,450,'center','center','no','no','no','no','no');
			break;
		case "Hilfe":
			openChild('/sixcms/detail.php?template=kontakt_frame&content_frame=hilfe','kontaktchild',690,450,'center','center','no','no','no','no','no');
			break;
		case "":
			break;
		default :
			parent.document.location.href = id+"&_select="+select;
			break;
	}
}