// filename: reiber_gen.js
// functions for the main navigation and other pages
// version 1.01 - 2004-01-31
// Distributed under the terms of the GNU Library General Public License
// author: kontakt at manderbachmedia dot de

//window.onerror = null

var posMapX = -33;
var posMapY = -156;


function pageInit() {
	
	is = new BrowserCheck();
	
	// display font-change-buttons on new browser; init fontchange
	if (is.ie || is.ns6up) {
		document.getElementById("fontchangeDiv").style.visibility = "visible";
		initFontchange();
		// checks if there is a fontcookie and sets individual fontsize
		checkFontCookie();
	}
	
	
}


function checkForm(){

return true;
}

/////////////////////////////////
////////// functions  map  /////
////////////////////////////////
var mapscrolling;

function moveMap(wohin) {
	if (is.dom) {	
		switch (wohin) {
		case "up": mapscrolling = window.setInterval("mapScrollerVert(-3)",80); break;
		case "down": mapscrolling = window.setInterval("mapScrollerVert(3)",80); break;
		case "left": mapscrolling = window.setInterval("mapScrollerHoriz(-3)",80); break;
		case "right": mapscrolling = window.setInterval("mapScrollerHoriz(3)",80); break;
		}
	}
}

function mapScrollerVert(num) {
	posMapY += num;
	if (posMapY > 0) posMapY = 0;
	if (posMapY < -384 + 200) posMapY = -384 + 200;
	document.getElementById('mapDiv').style.top = posMapY+"px";
}

function mapScrollerHoriz(num) {
	posMapX += num;
	if (posMapX > 0) posMapX = 0;
	if (posMapX < -555 + 345) posMapX = -555 + 345;
	document.getElementById('mapDiv').style.left = posMapX+"px";
}

function moveMapClear(){
	if (is.dom) window.clearInterval(mapscrolling);

}

function showDetail(num) {
	if (is.dom) {
		//repositioning of  detailmap to cursor		
		document.getElementById('mapdetailDiv').style.top = posMapY + 150 +"px";
		document.getElementById('mapdetailDiv').style.left = posMapX + 70 +"px";
				
		if (num == 1) document.getElementById('mapdetailDiv').style.visibility = "visible";
		else document.getElementById('mapdetailDiv').style.visibility = "hidden";
	}
	else if (is.ns4) {
		//repositioning of  detailmap 
		document.mapdetailDiv.left = 5;
		document.mapdetailDiv.top = 5;
	
		if (num == 1) document.mapdetailDiv.visibility = "visible";
		else document.mapdetailDiv.visibility = "hidden";
	
	}

}
/////////////////////////////////////////////
////////// functions for font-change ////////
/////////////////////////////////////////////

// global vars for changing of fontsize
var globalFontchange = 0; // difference to default
var contentObj; // contentlayer obj
var fontTag = new Array();
	fontTag[0]="p";
	fontTag[1]="h1";
	fontTag[2]="h2";
	fontTag[3]="h3";
	fontTag[4]="a";
	fontTag[5]="div";
	fontTag[6]="li";
	fontTag[7]="address";
	
function initFontchange(){
contentObj = document.getElementById("mainContentDiv");

}
	
function changeFontsize(num){
	globalFontchange+=num;
	var newfontsize=0;
	var helpobj;
	for (var i=0; i<fontTag.length; i++){
		for (var j=0; j<contentObj.getElementsByTagName(fontTag[i]).length; j++){
			if (is.ie) newfontsize = parseInt(contentObj.getElementsByTagName(fontTag[i])[j].currentStyle.fontSize);
			else newfontsize = parseInt(document.defaultView.getComputedStyle(contentObj.getElementsByTagName(fontTag[i])[j],"").getPropertyValue("font-size"));
			newfontsize+=num;
			contentObj.getElementsByTagName(fontTag[i])[j].style.fontSize = newfontsize+"px";// set new fontsize
			contentObj.getElementsByTagName(fontTag[i])[j].style.lineHeight = Math.round(newfontsize*(15/11))+"px";// set new line-height
		}
	}
	setFontCookie(globalFontchange);
}

function checkFontCookie(){
	if (document.cookie) {
	var userfontsize = parseInt(document.cookie.substring(11,document.cookie.length));
	changeFontsize(userfontsize);
	}	
}

function setFontCookie(){
	document.cookie = "mmediafont="+escape(globalFontchange)+";path=/";
}
	
///////////////////
// navfunctions //
//////////////////
var navsubbgclass = "bgnavsub";
var navsubbgclassover = "bgnavsubAct";

var navmainbgclass = "bgnavmain";
var navmainbgclassover = "bgnavmainAct";



function navmainover(which){
if (is.dom) which.className = navmainbgclassover;
}

function navmainout(which){
if (is.dom) which.className = navmainbgclass;
}


function navsubover(which){
if (is.dom) which.className = navsubbgclassover;
}

function navsubout(which){
if (is.dom) which.className = navsubbgclass;
}

function getUrl(newurl) {
document.location.href = newurl;
return false;
}
	
	
// makeArray() - make new arrays with image objects
function makeArray(n) {
	this.length = n + 1
	for (var i = 1; i<=n; i++) {
		this[i] = new Image()
		}
	return this
	}
	
// open pop-up window
function windowOpener(winUrl,winWidth,winHeight,winName,winX,winY,winScrollbars,winLocation,winStatus,winPersonalbar,winResizable,winToolbar,winMenubar,winDependent,winDirectories) {
	var windowName = ""
	// set defaults
	if (!winWidth) winWidth = 345
	if (!winHeight) winHeight = 323
	if (!winName) winName = 'popupWindow'
	if (!winX) winX = 10
	if (!winY) winY = 10
	if (!winScrollbars) winScrollbars = "yes"
	if (!winLocation) winLocation = "no"
	if (!winStatus) winStatus = "no"
	if (!winPersonalbar) winPersonalbar = "no"
	if (!winResizable) winResizable = "no"
	if (!winToolbar) winToolbar = "no"
	if (!winMenubar) winMenubar = "yes"
	if (!winDependent) winDependent = "no"
	if (!winDirectories) winDirectories = "no"
	// open pop-up window
	eval(winName +  '= window.open(winUrl,winName,"width=' + winWidth + ",height=" + winHeight + ",left=" + winX + ",top=" + winY + ",screenX=" + winX + ",screenY=" + winY + ",scrollbars=" + winScrollbars + ",location=" + winLocation + ",status=" + winStatus + ",personalbar=" + winPersonalbar + ",resizable=" + winResizable + ",toolbar=" + winToolbar + ",menubar=" + winMenubar + ",dependent=" + winDependent + ",directories=" + winDirectories + '")')
	eval(winName).focus()
	}