/* dasteam.js */

// ---------------------------------------------------------------------------
// configuration 
// ---------------------------------------------------------------------------

// used for recognizing current position before resizing the main content
var base_url_1 = 'http://pdc.gpm.de:8129/';
var base_url_2 = 'http://proxy29.gpm.de/';
var base_url_3 = 'http://www.ede-team.de/';


// ---------------------------------------------------------------------------


window.onresize = initlayersizes;


function pageInit(woher) {
	is = new BrowserCheck();
	fenster = new screenObject();
	if (is.dom) initlayersizes();
	if (woher == "forum") initforum();
	if (is.ns4) {// corrections for netscape 4.7
		document.layers["navmainDiv"].top = -15;
		document.layers["navmainDiv"].left = 180;
		document.layers["navmetaDiv"].top = 400;
		document.layers["colRightDiv"].visibility = "hidden";
	}
}


function searchSubmit(searchform) {

document.forms["suchform"].submit();
}

function kill_search_default(obj) {
// kill search default on first focus
	obj.value = '';
}

function initlayersizes() {	
	if (is.ns4) {
		window.location.reload(); 
		exit;
	}
	
	// default sizes
	var mincontentwidth = 300;
	var maxcontentwidth = 600;
	var correctforforum = 200;
	
	fenster = new screenObject();
	wobinich = window.location.href;
	dercontentlayer = "contentDiv";
	// if (wobinich.indexOf("8") > 0) dercontentlayer = "contentHomeDiv";

	//using global vars from the config area above 
	 if ((wobinich == base_url_1) || (wobinich == base_url_2) || (wobinich == base_url_3)) {dercontentlayer = "contentHomeDiv";}

	// forum needs greater width
	if (wobinich.indexOf("/forum") > 0) {
		mincontentwidth += correctforforum;
		maxcontentwidth += correctforforum;
	}
	
	
	var contentfromleft = (is.ie5up || is.opera || is.safari) ? document.getElementById(dercontentlayer).offsetLeft : parseInt(getComputedStyle(document.getElementById(dercontentlayer), null).getPropertyValue('left'));
	var colrightwidth = (is.ie5up || is.opera || is.safari) ? document.getElementById("colRightDiv").offsetWidth : parseInt(getComputedStyle(document.getElementById("colRightDiv"), null).getPropertyValue('width'));
		
	var newwidth = fenster.visWidth - contentfromleft - colrightwidth - 10;
	
	if (newwidth < mincontentwidth) newwidth = mincontentwidth;
	else if (newwidth > maxcontentwidth) newwidth = maxcontentwidth;
	
	if (newwidth == mincontentwidth) document.getElementById('colRightDiv').style.visibility = "hidden";
	else document.getElementById('colRightDiv').style.visibility = "visible";
	
	/* resize contentlayer */
	document.getElementById(dercontentlayer).style.width = newwidth+"px";
	/* deko bg - hides right col in small screen-width */
	document.getElementById('bgforsmallscreenDiv').style.width = newwidth+"px";
	
	resizeRightCol();
	
}

function initforum() {
// mark active subnavigation and display path of forum
	wobinich = window.location.href;
	if (is.dom) {
		if (wobinich.indexOf("/forum1/") > 0) {
			document.getElementById("subnavforum1").className = "navsubAct";
			document.getElementById("forumpath1").style.display = "inline";
		}
		else if (wobinich.indexOf("/forum2/") > 0) {
			document.getElementById("subnavforum2").className = "navsubAct";
			document.getElementById("forumpath2").style.display = "inline";
		}
	}
}



function resizeRightCol() {
	if (is.dom) {
		derlayer = "contentDiv";
		if (document.getElementById("contentHomeDiv")) derlayer = "contentHomeDiv";
		else if (document.getElementById("contentForumDiv")) {derlayer = "contentForumDiv"};
		
		// get height content
		diecontenthoehe = (is.ie5up || is.opera || is.safari) ? document.getElementById(derlayer).offsetHeight : parseInt(getComputedStyle(document.getElementById(derlayer), null).getPropertyValue('height'));
		dierechtehoehe = (is.ie5up || is.opera || is.safari) ? document.getElementById('colRightDiv').offsetHeight : parseInt(getComputedStyle(document.getElementById('colRightDiv'), null).getPropertyValue('height'));
		
		// height + distance to top
		diehoehe = diecontenthoehe + 85;
				
		// set new colheight if < contentheight
		if (diehoehe > dierechtehoehe) {
			if(is.ie || is.opera || is.safari){
	  			document.getElementById("colRightDiv").style.height = diehoehe+"px";
	  		}
	  		else{
	  			document.getElementById("colRightDiv").style.minHeight = diehoehe+"px";
	  		}
		}
	}
	
}

// screenObject() creates universally accessible screen attribute objects
function screenObject() {
	// bottom edge
	if (window.pageYOffset) {
		this.bottom = window.pageYOffset;}
	else if (document.body && document.body.scrollHeight) {
		this.bottom = document.body.scrollHeight;}
	else {this.bottom = false;}

	// height	
	if (window.outerHeight) {
		this.height = window.outerHeight;}
	else if (document.body && document.body.offsetHeight) {
		this.height = document.body.offsetHeight;}
	else {this.height = false;}
		
	// visible height
	if (window.innerHeight) {
		this.visHeight = window.innerHeight;}
	else if (document.body && document.body.clientHeight) {
		this.visHeight = document.body.clientHeight;}
	else {this.visHeight = false;}
		
	// width
	if (window.outerWidth) {
		this.width = window.outerWidth;}
	else if (document.body && document.body.offsetWidth) {
		this.width = document.body.offsetWidth;}
	else {this.width = false;}
		
	// visible width
	if (window.innerWidth) {
		this.visWidth = window.innerWidth;}
	else if (document.body && document.body.clientWidth) {
		this.visWidth = document.body.clientWidth;}
	else {this.visWidth = false;}
		
	// scroll position
	if (window.pageYOffset) {
		this.scrollTop = window.pageYOffset;}
	else if (document.body && document.body.scrollTop) {
		this.scrollTop = document.body.scrollTop;}
	else {this.scrollTop = 0}
}
