function init(){	
	checkVersion();
	doPopups();
	updateHeights();
}


function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
	  
    if (links[i].className.match("popup")) {
      links[i].onclick=function() {
        // Below - to open a full-sized window, just use: window.open(this.href);
        window.open(this.href, "", "top=40,left=40,width=570,height=400,scrollbars=no");
        return false;
      }
    }
  }
}

function Numsort (a, b) {
  return a - b;
}

function updateHeights(){
	
	 var ver = getInternetExplorerVersion();
	 if(ver == -1){
		 
	 } else if (ver > 6){
		
	 } else{
		// return;	 
	 }
	
	
	var right = document.getElementById("right");
	var left = document.getElementById("left");
	var content = document.getElementById("content");
	
	var container = document.getElementById("container");
	
	var heights = new Array(right.offsetHeight, left.offsetHeight, content.offsetHeight);
	heights.sort(Numsort);
	var max = heights[2];
	resize(right, max);
	resize(left, max);
	resize(content, max);
	resize(container, max+findPosY(content)-15);
	var footer = document.getElementById("footer");
	footer.style.top = "" + (142+max)+ "px";
 //	footer.style.left = ""+left.offsetWidth+"px";
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

function isSet(prm) {
	var und;
	return (prm != und && prm != null);
}
function resize(elmnt, height) {
    if (!isSet(elmnt)) {
		return;
	}
	if (typeof elmnt != 'object') {
		fatherElmnt = document.getElementById(elmnt);
	}
	if (!elmnt) {
		return;
	}
	if (!isSet(height)) {
		height = 0;
	}
    
    if(elmnt.id == "content") {
        elmnt.style.height = height+"px";
    } else {
        elmnt.style.height = height+"px";
    }
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver > 6.0 ) {
		var ie7 = document.getElementById('ie7specials');
     ie7.href = "/themes/spitalnetz/css/ie7specials.css";
	} 
  }

}



