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

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

function _communiacs_validateMail(p_address) {
	var t_regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return p_address.match(t_regex);
}

function _communiacs_trim(p_string) {
  return p_string.replace (/^\s+/, '').replace (/\s+$/, '');
}

function _communiacs_arrayMerge(p_array_1, p_array_2) {
	var t_array = new Array();
	for(var i = 0; i < p_array_1.length; i++) {
		t_array[t_array.length] = p_array_1[i];
	}
	for(var i = 0; i < p_array_2.length; i++) {
		t_array[t_array.length] = p_array_2[i];
	}
	return t_array;
}

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 _communiacs_getElementsByClass(p_source, p_class) {
	var t_return = new Array();
	var t_elements = p_source.childNodes;
	for(var i = 0; i < t_elements.length; i++) {
		if(t_elements[i].nodeType == 1) {
			if(t_elements[i].className.indexOf(p_class) > -1) {
				t_return[t_return.length] = t_elements[i];
			}
			else if(t_elements[i].childNodes.length > 0) {
				var t_subelems = _communiacs_getElementsByClass(t_elements[i], p_class);
				t_return = _communiacs_arrayMerge(t_return, t_subelems);
			}
		}
	}
	return t_return;
}

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



function communiacs_menu_shadow(element) {
	var t_shadow_l = _communiacs_getElementsByTagAndClass(element,'div','menu_shadow_left')[0];
	var t_shadow_lb = _communiacs_getElementsByTagAndClass(element,'div','menu_shadow_lbottom')[0];
	var t_shadow_b = _communiacs_getElementsByTagAndClass(element,'div','menu_shadow_bottom')[0];
	var t_shadow_rb = _communiacs_getElementsByTagAndClass(element,'div','menu_shadow_rbottom')[0];
	var t_shadow_r = _communiacs_getElementsByTagAndClass(element,'div','menu_shadow_right')[0];
	if(t_shadow_l) {
		var t_ul = element.getElementsByTagName('ul')[0];
		var t_w = t_ul.offsetWidth;
		var t_h = t_ul.offsetHeight;
		var t_top = t_ul.offsetTop;
		t_shadow_l.style.height = t_h + 'px';
		t_shadow_lb.style.top = t_h + 'px';
		t_shadow_b.style.top = t_h + 'px';
		t_shadow_b.style.width = (t_w - 2) + 'px';
		t_shadow_rb.style.left = (t_w - 1) + 'px';
		t_shadow_rb.style.top = t_h + 'px';
		t_shadow_r.style.left = (t_w - 1) + 'px';
		t_shadow_r.style.height = t_h + 'px';
	}
}



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;
		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('content').offsetHeight;
		
		if(communiacs_real_content_height == -1) {
			if(window.getComputedStyle) {
				var t_content_padTop = parseInt(window.getComputedStyle(document.getElementById('content'),"").getPropertyValue('padding-top'));
				var t_content_padBot = parseInt(window.getComputedStyle(document.getElementById('content'),"").getPropertyValue('padding-bottom'));
				var t_content_borTop = parseInt(window.getComputedStyle(document.getElementById('content'),"").getPropertyValue('border-top-width'));
				var t_content_borBot = parseInt(window.getComputedStyle(document.getElementById('content'),"").getPropertyValue('border-bottom-width'));
			}
			else {
				var t_content_padTop = parseInt(document.getElementById('content').currentStyle.paddingTop);
				var t_content_padBot = parseInt(document.getElementById('content').currentStyle.paddingBottom);
				var t_content_borTop = parseInt(document.getElementById('content').currentStyle.borderTopWidth);
				var t_content_borBot = parseInt(document.getElementById('content').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;
			var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
			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);
		if(t_real_wrapper_height < t_client_height - t_wrapper_top) {
			document.getElementById('content').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('content').style.height = communiacs_real_content_height_style + 'px';
		}
		communiacs_dynamic_height_running = false;
	}
}

function communiacs_background() {
	var t_wrapper_top = document.getElementById('wrapper').offsetTop;
	var t_wrapper_new_height = document.getElementById('wrapper').offsetHeight;
	document.getElementById('back_center').style.height = t_wrapper_new_height + 'px';
	document.getElementById('back_bottom').style.top = (t_wrapper_new_height + t_wrapper_top) + 'px';
}

function communiacs_resize_handler() {
	//communiacs_dynamic_height();
	communiacs_background();
}

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

/* Konfiguration */
var home_rotate_cycle_delay = 4000;
/* Feste Initialwerte */
var home_rotate_images = null;
var home_rotate_index = -1;
function home_rotate_start() {
	// get the images for rotation and hide them all, if not done yet
	if(home_rotate_images == null) {
		home_rotate_images = $$('.home_image_rotate');
		home_rotate_images.each(function(t_elem, idx) {
			if(idx != 0) {
				t_elem.style.display = 'none';
			}
		});
	}
	
	//check, if more than one image has to be rotated
	if(home_rotate_images != null && home_rotate_images.length > 1) {
		//calulate new index
		var t_new_index = home_rotate_index + 1;
		if(t_new_index >= home_rotate_images.length) {
			t_new_index = 0;
		}
		
		//hide currently displayed image, if this is not the first cycle
		if(home_rotate_index >= 0) {
			Effect.Fade(home_rotate_images[home_rotate_index], {duration: 1});
		}
		
		//display the new image
		Effect.Appear(home_rotate_images[t_new_index], {duration: 1});
		
		//update cycle-index
		home_rotate_index = t_new_index;
		
		//set timeout for next cycle
		setTimeout("home_rotate_start()", home_rotate_cycle_delay);
	}
	//if there is only one image, then simply display it
	else if(home_rotate_images != null && home_rotate_images.length == 1) {
		Effect.Appear(home_rotate_images[0], {duration: 1});
	}
}

