
function _communiacs_show(element){
	element.className += " hover";
}

function _communiacs_hide(element){
	if(element.className == 'hover')
		element.className = '';
	else {
		element.className = element.className.replace(/ hover/g, "");
	}
}

function _communiacs_getElementsByTagAndClass(p_source, p_tag, p_class) {
	var t_return = new Array();
	var t_elements = p_source.getElementsByTagName(p_tag);
	for(var i = 0; i < t_elements.length; i++) {
		if(t_elements[i].className.indexOf(p_class) > -1) {
			t_return[t_return.length] = t_elements[i];
		}
	}
	return t_return;
}

function openPreviousLink(elem) {
	elem.parentNode.parentNode.getElementsByTagName('a')[0].onclick();
}



var communiacs_real_content_height = -1;
var communiacs_real_content_height_style = -1;
var communiacs_dynamic_height_running = false;
function communiacs_dynamic_height() {
	if(!communiacs_dynamic_height_running) {
		communiacs_dynamic_height_running = true;
		var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
		if(window.innerHeight)
			var t_client_height = window.innerHeight;
		else if(document.documentElement.clientHeight)
			var t_client_height = document.documentElement.clientHeight;
		else if(document.body.clientHeight)
			var t_client_height = document.body.clientHeight;
		
		var t_wrapper_top = document.getElementById('wrapper').offsetTop;
		var t_wrapper_height = document.getElementById('wrapper').offsetHeight;
		var t_content_height = document.getElementById('wrapper_main').offsetHeight;
		var t_footer_height = document.getElementById('footer').offsetHeight;
		
		if(communiacs_real_content_height == -1) {
			if(window.getComputedStyle) {
				var t_content_padTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('padding-top'));
				var t_content_padBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('padding-bottom'));
				var t_content_borTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('border-top-width'));
				var t_content_borBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('border-bottom-width'));
			}
			else {
				var t_content_padTop = parseInt(document.getElementById('wrapper_main').currentStyle.paddingTop);
				var t_content_padBot = parseInt(document.getElementById('wrapper_main').currentStyle.paddingBottom);
				var t_content_borTop = parseInt(document.getElementById('wrapper_main').currentStyle.borderTopWidth);
				var t_content_borBot = parseInt(document.getElementById('wrapper_main').currentStyle.borderBottomWidth);
			}
			if(isNaN(t_content_padTop)) t_content_padTop = 0;
			if(isNaN(t_content_padBot)) t_content_padBot = 0;
			if(isNaN(t_content_borTop)) t_content_borTop = 0;
			if(isNaN(t_content_borBot)) t_content_borBot = 0;
			communiacs_real_content_height = t_content_height;
			communiacs_real_content_height_style = t_content_height - t_content_padTop - t_content_padBot - t_content_borTop - t_content_borBot;
			if(IE6) {
				communiacs_real_content_height_style = t_content_height;
			}
		}
		
		var t_real_wrapper_height = t_wrapper_height - (t_content_height - communiacs_real_content_height);
		document.getElementById('wrapper_left').style.height = 'auto';
		document.getElementById('footer').style.top = '0';
		if(t_real_wrapper_height < t_client_height - t_wrapper_top) {
			document.getElementById('wrapper_main').style.height = (((t_client_height - t_wrapper_top) - t_real_wrapper_height) + communiacs_real_content_height_style) + 'px';
		}
		else {
			if(t_content_height != communiacs_real_content_height)
				document.getElementById('wrapper_main').style.height = communiacs_real_content_height_style + 'px';
		}
		
		//Linke Spalte auf volle Größe skalieren
		var t_left_height = document.getElementById('wrapper_left').offsetHeight;
		var t_left_avail_height = document.getElementById('wrapper_main').offsetHeight;
		if(t_left_height < t_left_avail_height) {
			if(window.getComputedStyle) {
				var t_left_padTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_left'),"").getPropertyValue('padding-top'));
				var t_left_padBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_left'),"").getPropertyValue('padding-bottom'));
				var t_left_borTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_left'),"").getPropertyValue('border-top-width'));
				var t_left_borBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_left'),"").getPropertyValue('border-bottom-width'));
			}
			else {
				var t_left_padTop = parseInt(document.getElementById('wrapper_left').currentStyle.paddingTop);
				var t_left_padBot = parseInt(document.getElementById('wrapper_left').currentStyle.paddingBottom);
				var t_left_borTop = parseInt(document.getElementById('wrapper_left').currentStyle.borderTopWidth);
				var t_left_borBot = parseInt(document.getElementById('wrapper_left').currentStyle.borderBottomWidth);
			}
			if(isNaN(t_left_padTop)) t_left_padTop = 0;
			if(isNaN(t_left_padBot)) t_left_padBot = 0;
			if(isNaN(t_left_borTop)) t_left_borTop = 0;
			if(isNaN(t_left_borBot)) t_left_borBot = 0;
			if(IE6) {
				document.getElementById('wrapper_left').style.height = t_left_avail_height + 'px';
			}
			else {
				document.getElementById('wrapper_left').style.height = t_left_avail_height - (t_left_padTop + t_left_padBot + t_left_borTop + t_left_borBot) + 'px';
			}
		}
		
		//Content-Schatten entsprechend skalieren
		document.getElementById('left_shadow').style.height = t_left_avail_height + 'px';
		
		//iFrame-höhe anpassen, falls vorhanden
		var t_iframe_height = t_content_height - t_footer_height;
		
		//Footer an den unteren Rand befördern
		if(document.getElementById('page_header')) {
			var t_right_height1 = document.getElementById('page_header').offsetHeight;
			var t_right_height2 = document.getElementById('wrapper_right').offsetHeight;
			var t_right_max_height = (t_right_height1 > t_right_height2) ? t_right_height1 : t_right_height2;
			t_iframe_height -= t_right_max_height;
			t_right_max_height += document.getElementById('content_wrapper').offsetHeight;
		}
		else {
			var t_right_height1 = document.getElementById('content_wrapper').offsetHeight;
			var t_right_height2 = document.getElementById('wrapper_right').offsetHeight;
			var t_right_max_height = (t_right_height1 > t_right_height2) ? t_right_height1 : t_right_height2;
		}
		
		//iFrame-höhe anpassen, falls vorhanden
		// if(document.getElementById('stellen_iframe')) {
			// t_right_max_height -= (t_iframe_height - document.getElementById('stellen_iframe').offsetHeight)
			// document.getElementById('stellen_iframe').style.height = t_iframe_height + 'px';
		// }
		
		document.getElementById('footer').style.position = 'relative';
		document.getElementById('footer').style.top = (t_left_avail_height - t_right_max_height - t_footer_height) + 'px';
		
		communiacs_dynamic_height_running = false;
	}
}

function communiacs_dynamic_height_reinit() {
	document.getElementById('wrapper_left').style.height = 'auto';
	document.getElementById('footer').style.marginTop = '0';
	document.getElementById('wrapper_main').style.height = 'auto';
	var t_content_height = document.getElementById('wrapper_main').offsetHeight;
	if(window.getComputedStyle) {
		var t_content_padTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('padding-top'));
		var t_content_padBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('padding-bottom'));
		var t_content_borTop = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('border-top-width'));
		var t_content_borBot = parseInt(window.getComputedStyle(document.getElementById('wrapper_main'),"").getPropertyValue('border-bottom-width'));
	}
	else {
		var t_content_padTop = parseInt(document.getElementById('wrapper_main').currentStyle.paddingTop);
		var t_content_padBot = parseInt(document.getElementById('wrapper_main').currentStyle.paddingBottom);
		var t_content_borTop = parseInt(document.getElementById('wrapper_main').currentStyle.borderTopWidth);
		var t_content_borBot = parseInt(document.getElementById('wrapper_main').currentStyle.borderBottomWidth);
	}
	if(isNaN(t_content_padTop)) t_content_padTop = 0;
	if(isNaN(t_content_padBot)) t_content_padBot = 0;
	if(isNaN(t_content_borTop)) t_content_borTop = 0;
	if(isNaN(t_content_borBot)) t_content_borBot = 0;
	communiacs_real_content_height = t_content_height;
	communiacs_real_content_height_style = t_content_height - t_content_padTop - t_content_padBot - t_content_borTop - t_content_borBot;
	if(IE6) {
		communiacs_real_content_height_style = t_content_height;
	}
}

if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", cm_onload_handler, false);
  window.addEventListener("resize", cm_resize_handler, false);
}
else if(window.attachEvent) {
	window.attachEvent('onload', cm_onload_handler);
	window.attachEvent('onresize', cm_resize_handler);
}
else {
	var onload_old = window.onload;
	window.onload = function() {
		if(onload_old) {
			onload_old();
		}
		cm_onload_handler();
	}
	var onresize_old = document.body.onresize;
	document.body.onresize = function() {
		if(onresize_old) {
			onresize_old();
		}
		cm_resize_handler();
	}
}

function cm_onload_handler() {
	communiacs_dynamic_height();
	cm_header_rotate();
}

function cm_resize_handler() {
	communiacs_dynamic_height();
}





/*** FONT-SIZER ***/

//standardgroesse
var communiacs_fontSize = 12;
var communiacs_defaultFontSize = 12;

if(document.cookie) {
	var t_cookies = document.cookie.split(';');
	var t_cook_len = t_cookies.length;
	for(var i = 0; i < t_cook_len; i++) {
		t_cookie = t_cookies[i];
		// trim
		t_cookie = t_cookie.replace( /^\s+/g,'').replace(/\s+$/g,'');
		// split name/value
		t_cook = t_cookie.split('=');
		if(t_cook[0] == 'font_sizer') {
			communiacs_fontSize = parseInt(t_cook[1]);
		}
	}
}

//schrift verkleinern
function _font_smaller() {
	communiacs_fontSize -= 1;
	if(communiacs_fontSize < 6)
		communiacs_fontSize = 6;
	_font_set();
	document.cookie = 'font_sizer='+communiacs_fontSize+';';
}

//schrift vergroessern
function _font_bigger() {
	communiacs_fontSize = parseInt(communiacs_fontSize) + 1;
	if(communiacs_fontSize > 24)
		communiacs_fontSize = 24;
	_font_set();
	document.cookie = 'font_sizer='+communiacs_fontSize+';';
}

//schrift auf standardgroesse setzen
function _font_normal() {
	communiacs_fontSize = communiacs_defaultFontSize;
	_font_set();
	document.cookie = 'font_sizer='+communiacs_fontSize+';';
}

//schrift auf aktuelle groesse setzen
function _font_set() {
	document.body.style.fontSize = communiacs_fontSize + 'px';
	//communiacs_dynamic_height_reinit();
	communiacs_dynamic_height();
}




var cm_header_rotate_index = -1;
var cm_header_rotate_images = null;
function cm_header_rotate() {
	if(cm_header_rotate_images == null) {
		cm_header_rotate_images = $$('#header_back img');
	}
	if(cm_header_rotate_images.length > 0) {
		if(cm_header_rotate_index >= 0) {
			cm_header_rotate_images[cm_header_rotate_index].style.display = 'none';
		}
		cm_header_rotate_index++;
		if(cm_header_rotate_index >= cm_header_rotate_images.length) {
			cm_header_rotate_index = 0;
		}
		cm_header_rotate_images[cm_header_rotate_index].style.display = 'block';
		if(cm_header_rotate_images.length > 1) {
			setTimeout('cm_header_rotate()',6000);
		}
	}
}

