/*////////////////////////////////////////////////////////////////////////////////////////////
//Function.js
//Written by Electric Solutions GbR
//Copyright 2002-20010 by Electric Solutions GbR
//Authors: R. Grosseck
//elso@p-link.de
//www.electric-solutions.de
////////////////////////////////////////////////////////////////////////////////////////////*/
/*////////////////////////////////////////////////////////////////////////////////////////////
//Browser
////////////////////////////////////////////////////////////////////////////////////////////*/
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.isFF    = false;  // Firefox
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isFF = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();
/*////////////////////////////////////////////////////////////////////////////////////////////
//Table Hover Effekt f�r IE6
////////////////////////////////////////////////////////////////////////////////////////////*/
function mover() {
	for (var i = 0; i < this.cells.length; i++) {
		if (this.cells[i].className == 'tab_level1') this.cells[i].className = 'hlt-tab_level1';
		else this.cells[i].className = 'hlt';
	}
}
function mout() {
	for (var i = 0; i < this.cells.length; i++) {
		if (this.cells[i].className.replace('hlt-','') == 'tab_level1') this.cells[i].className = 'tab_level1';
		else this.cells[i].className = '';
	}
}

/*////////////////////////////////////////////////////////////////////////////////////////////
//Checkboxen
////////////////////////////////////////////////////////////////////////////////////////////*/
var checkbox=0;
function select_checkbox(id, typ){
	//nach ID
	if(typ)
	{
		if(checkbox == 0){
			var obj = document.getElementsByTagName("input");
			for(x=0; x<obj.length; x++){
				if(obj[x].getAttributeNode("class")){
					if(obj[x].getAttributeNode("class").nodeValue == id){			
						obj[x].checked = true;
					}
				}
			}			
			checkbox=1;
		}
		else {
			var obj = document.getElementsByTagName("input");
			for(x=0; x<obj.length; x++){
				if(obj[x].getAttributeNode("class")){
					if(obj[x].getAttributeNode("class").nodeValue == id){			
						obj[x].checked = false;
					}
				}
			}		
			checkbox=0;
		}
	}
	//nach Form
	else
	{
		if(checkbox == 0){
			for(x=0; x<document.forms[id].elements.length; x++){
				document.forms[id].elements[x].checked = true;
			}
			checkbox=1;
		}
		else {
			for(x=0; x<document.forms[id].elements.length; x++){
				document.forms[id].elements[x].checked = false;
			}		
			checkbox=0;
		}
	}
}

/*////////////////////////////////////////////////////////////////////////////////////////////
//Screen Update
////////////////////////////////////////////////////////////////////////////////////////////*/
function UpdateScreen(){
	var winh = Dialog.getWinHeight() - document.getElementById('headerContainer').offsetHeight-document.getElementById('mainMenu').offsetHeight - document.getElementById('footerContainer').offsetHeight;
	document.getElementById("contentLayout").style.minHeight = winh + 'px';
	if(document.getElementById("contentContainerLeft") && document.getElementById("contentContainerMain")){
		if(browser.isIE == true){
			document.getElementById("contentContainerLeft").style.height = winh + 'px';
			document.getElementById("contentContainerMain").style.height = winh + 'px';
		}
		else {
			document.getElementById("contentContainerLeft").style.minHeight = winh + 16 + 'px';
			document.getElementById("contentContainerMain").style.minHeight = winh + 'px';
		}
		document.getElementById("campainArticle").style.height = document.getElementById("contentContainerLeft").offsetHeight - 66 + 'px';
	
	//if(!ie5 && !ie4){
		var winw=Dialog.getWinWidth();
		//var cCLeft = parseInt((15*winw/100));
		//var cCMain =  parseInt(winw - cCLeft - 95);
		//document.getElementById("contentContainerLeft").style.width = cCLeft + 'px';
		document.getElementById("contentContainerLeft").style.width = 210 + 'px';
		//document.getElementById("contentContainerLeft").style.minWidth = 200 + 'px';
		var cCMain =  parseInt(winw - 200 - 85);
		document.getElementById("contentContainerMain").style.minWidth = 800 + 'px';
		cCMain = browser.isIE == true ? (cCMain < 800 ? 800 : cCMain) : cCMain;
		document.getElementById("contentContainerMain").style.width = cCMain + 'px';
		
	//}
	}
	else if(document.getElementById("contentContainer")){
		if(browser.isIE == true)
		document.getElementById("contentContainer").style.height = winh + 'px';
		else
		document.getElementById("contentContainer").style.minHeight = winh + 'px';
	}
	
}


function ClickScreen(event){

}
/*////////////////////////////////////////////////////////////////////////////////////////////
//DIV ein/ausblenden
////////////////////////////////////////////////////////////////////////////////////////////*/
function ShowHide(id){
	var obj = document.getElementById(id);
	obj.style.display = (obj.style.display == "none" || obj.style.display == "") ? "block" : "none";
}

/*////////////////////////////////////////////////////////////////////////////////////////////
//Events
////////////////////////////////////////////////////////////////////////////////////////////*/
function addEvent(obj, type, fn ) {
	if(obj.attachEvent){
		obj[type+fn] = function(){fn.call(obj,window.event);}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} 
	else
		obj.addEventListener( type, fn, false );
}

function removeEvent( obj, type, fn ) {
	if ( obj.detachEvent ) {
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	} 
	else
	obj.removeEventListener( type, fn, false );
} 

/*////////////////////////////////////////////////////////////////////////////////////////////
//Start
////////////////////////////////////////////////////////////////////////////////////////////*/
addEvent(window, "click", function(event){ClickScreen(event)});
addEvent(window, "load", function(){UpdateScreen();});
addEvent(window, "resize", function(){UpdateScreen();});

function openPopup(gotourl){
	var windowprops = "width=1200,height=768,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes";
	newWindow = window.open(gotourl,'Codecheck',windowprops);
}


