var NS=(navigator.appName == "Netscape")?1:0;
var VER=parseInt(navigator.appVersion);
var windowWidth=0;
var windowHeight=0;

function reloadpage()
{
	location.reload(); /*oder history.go(0);*/
}

var slowShowImageNr=0;
function showAnotherImage()
{
	setLayerVisibility("b"+slowShowImageNr, true);
  
	slowShowImageNr++;
	window.setTimeout("showAnotherImage()", slowShowDelay);
}

function startSlowShow()
{
	showAnotherImage();
}

function setbgcolorred()
{
	color='ff0000';
	if(NS)
	{
		document.bgColor = '#'+ color;
	}
	else
	{
		document.body.style.backgroundColor = '#'+ color;
	}
}

function preload()
{
	var NS=(navigator.appName == "Netscape")?1:0;
	var VER=parseInt(navigator.appVersion);
	if (NS && (VER<=4))
	{
		window.captureEvents(Event.RESIZE);
		setTimeout("window.onresize = reloadpage", 1000);
	}
	var preloaded_images=new Array;
	menu = new Array("graphicguestbook1.gif", "draw1.gif", "dra1.gif", "admin1.gif");
	if(document.images)
	{
		for(i=0;i<menu.length;i++)
		{
			preloaded_images[i]=new Image;
			preloaded_images[i].src=maindirurl+"/img/"+menu[i];
		}
	}
}

function changeimg(what, append)
{
	//var ext=((what=="scrollup")||(what=="scrolldown"))?"gif":"jpg";
	var img = eval("document.images."+what);
	if (typeof(img) == "object")
	{
		var f=img.src;
		// f is a filename like ..../..../<what><XXX>.<ext>
		// <XXX> has to be replaced by <append>
		var p=f.lastIndexOf(what)+what.length;
		var q=f.lastIndexOf(".");
		img.src=f.substring(0,p)+append+f.substring(q,f.length);
		return true;
	}
	return false;
}

function newsrc(name, newsrc)
{
	var img = eval("document.images."+name);
	if (typeof(img) == "object")
	{
		if(img.src!=newsrc)
		img.src=newsrc;
	}
}

function getWindowSize()
{
	if(typeof(window.innerWidth)=='number')
	{
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	}
	else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function mouseover(what, newstatustext)
{
  statustext=newstatustext;
  status=statustext;
  return changeimg(what, "1");
}  

function mouseout(what)
{
  status="";
  return changeimg(what, "0");
}

function submitForm(name)
{
	var form=eval("document."+name);
	if(form) form.submit();
}
function submitFormWithAction(name, action)
{
	var form=eval("document."+name);
	if(form)
	{
		if((action!="")&&form.elements&&form.elements.action)
			form.elements.action.value = action;
		form.submit();
	}
}
function setStatus(text)
{
	status=text;
	return true;
}
function openURL(url)
{
	if(top.frames.length > 0)
	{
		//top.location.href=self.location;
		w = window.open(url,"_blank");
		w.focus();
	}
	else
	{
		location.href=url;
	}
}

function moveLayer(layerName, x, y)
{
	if (NS)
	{
		if(VER>4)
		{
			layer=document.getElementById(layerName);
			if(typeof(layer)=="object" && typeof(layer.style)=="object")
			{
				layer.style.left=x+"px";
				layer.style.top=y+"px";
			}
		}
		else
		{
			layer=eval("document."+layerName);
			if(typeof(layer)=="object")
			{
				layer.left=x;
				layer.top=y;
			}
		}
	}
	else
	{
		layer=document.all[layerName];
		if(typeof(layer)=="object" && typeof(layer.style)=="object")
		{
			layer.style.left = x;
			layer.style.top = y;	
		}
	}
}

function setLayerVisibility(layerName, visible)
{
	if (NS)
	{
		if(VER>4)
		{
			layer=document.getElementById(layerName);
			if(typeof(layer)=="object" && typeof(layer.style)=="object")
			{
				layer.style.visibility=visible?"visible":"hidden";
			}
		}
		else
		{
			layer=eval("document."+layerName);
			if(typeof(layer)=="object")
			{
				//newsrc("vorschaubild", "fake.gif");
				layer.visibility=visible?"show":"hide";
			}
		}
	}
	else
	{
		layer=document.all[layerName];
		if(typeof(layer)=="object" && typeof(layer.style)=="object")
		{
			layer.style.visibility = visible?"visible":"hidden";
		}
	}
}
