/**
*
* @author Lukas Bürki < >, Remo Häusler < >
* @version 1.0
* @module Rosengarten
*/


var dom = (document.getElementById) ? true : false;
var ie = (document.all) ? true : false;

var menuitem = {};

//////////////////////////////////////////////////////////////////////
function getElement (id)
{
	if (dom) return(document.getElementById(id));
	if (ie) return(document.all[id]);
	
	return(null);
}
function hover (id)
{
	var e = getElement(id);
	if (e != null){
		e.className = "hover";
		menuitem[id] = true;
	}
}

function out (id)
{
	setPoint("_r.gif");
	// firefox benötigt eine verzögerung!
	menuitem[id] = false;
	setTimeout("invisible('"+id+"')", 100);
}

function invisible (id)
{
	if (menuitem[id]) return;
	
	var e = getElement(id);
	if (e != null) e.className = '';
}


//////////////////////////////////////////////////////////////////////
function setJsMenu ()
{
	var e = getElement("menu");
	if (e != null) e.className = "jsMenu";
}
function fitPage ()
{
	//var e = getElement("site");
	//if (e != null) e.style.height = "100%";
	
	var e = getElement("pane");
	if (e != null)e.className = "fitPane";
	
	var e = getElement("foot");
	if (e != null) e.className = "fitFoot";
	
	window.scrollTo(0, 0)	
}
function unfitPage ()
{
	//var e = getElement("site");
	//if (e != null) e.style.height = "100%";

	var e = getElement("pane");
	if (e != null) e.className = "";

	var e = getElement("foot");
	if (e != null) e.className = "";
}
function getPageHeight ()
{
	// mozilla firefox
	if (window.innerHeight)
		return(window.innerHeight);
	// internet explorer
	if (document.body && document.body.clientHeight)
		return(document.body.clientHeight);
	// no size
	return(0);
}

var MIN_HEIGHT;
var IE_MIN_HEIGHT;

function checkPageSize (reload)
{

	var height = getPageHeight();
	var minHeight = (ie) ? 
		((IE_MIN_HEIGHT == null) ? 450: IE_MIN_HEIGHT) : 
		((MIN_HEIGHT == null) ? 430: MIN_HEIGHT);
	
	if (height < minHeight){
		unfitPage();
	}else{
		fitPage();
	}
}

//////////////////////////////////////////////////////////////////////

function changeSource (id, src)
{
	var e = getElement(id);
	if (e != null) e.src = src;
}
function setPoint (name)
{
//alert(name)
	changeSource('Point', 'images/'+name);
}
function MultiImage (id, index, dir, src)
{
	var e = getElement('ButtonPrev');
	if (e != null) e.style.display = 'inline';

	var e = getElement('ButtonNext');
	if (e != null) e.style.display = 'inline';
	
	this.id = id;
	this.src = [];
	this.index = index;
	var arg = MultiImage.arguments;
	for (var n=3; n<arg.length; n++){
		var img = new Image();
		img.src = dir+arg[n];
		this.src.push(img);
	}
}

MultiImage.prototype.prev = function  ()
{
	//this.src.unshift(this.src.pop());
	if (--this.index < 0)
		this.index = this.src.length-1;
	changeSource(this.id, this.src[this.index].src);
}
MultiImage.prototype.next = function  ()
{
	//this.src.push(this.src.shift());
	if (++this.index > this.src.length-1)
		this.index = 0;
	
	changeSource(this.id, this.src[this.index].src);
}

//////////////////////////////////////////////////////////////////////


window.onresize = checkPageSize;
window.onload = function ()
{
	
	if (checkPageSize != null) checkPageSize();	
	if (setJsMenu != null) setJsMenu();
	if (initSlideShow != null) initSlideShow();
}
