var contactUrls = new Array();
var contactOptions = new Array();
var emptySearchAlertText = "Bitte geben Sie einen Suchterm ein.";
var termTooShortSearchAlertText = "Der Begriff muss mindestens 3 Zeichen lang sein.";

setFontSize = function(obj){
	//alert(obj.className);
	//test = document.getElementById("deltaBody");
	document.body.className = obj.className;
	//document.body.fontSize = "150%";
	//alert(document.body.fontSize);
}


sfHover = function() {
	var sfNav = document.getElementById("nav");
	if (sfNav == null) {
		return;
	}
	sfEls = sfNav.getElementsByTagName("LI");
	if (sfEls == null) {
		return;
	}
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function focusSearch(elem) {
	if (elem.value == 'Suche') {
		elem.value = '';
	}
}

function blurSearch(elem) {
	if (elem.value == '') {
		elem.value = 'Suche';
	}
}

function portal_balanceCols() {
  if (!document.getElementById('middleContentLeft') || !document.getElementById('portalSubColHeadline') ||
      !document.getElementById('portalSubColLeft') || !document.getElementById('portalSubColRight')) { return; }
  
  var newHeight = parseInt(document.getElementById('middleContentLeft').offsetHeight) - parseInt(document.getElementById('portalSubColHeadline').offsetHeight);
  
  document.getElementById('portalSubColLeft').style.height = newHeight + 'px';
  document.getElementById('portalSubColRight').style.height = newHeight + 'px';
}



if (self.Class) {    // we assume that if "Class" exists then prototype.js has been included, then we can execute the following code
	
	
	// ----- mouseover-highlight for headlines on portal page
	function highlightChange(elem, pageType) {
		if ($(elem).hasClassName('color_' + pageType + '1')) {
			$(elem).removeClassName('color_' + pageType + '1');
			$(elem).addClassName('color_' + pageType + '7');
		} else {
			$(elem).removeClassName('color_' + pageType + '7');
			$(elem).addClassName('color_' + pageType + '1');
		}
	}
	
	

	// ----- class to control tabbed content behaviour
	var tabController = Class.create();
	
	tabController.prototype = {
		// -- constructor --
		// params:
		//   tabList       = list of tab IDs to register for this controller
		//   activeTabID   = ID of tab to be shown initially
		//   activeColor   = CSS class to be used to set color for active tab
		//   inactiveColor = CSS class for inactive tab
		initialize: function (tabList, activeTabID, activeColor, inactiveColor) {
			// init private vars
			this.tabList = tabList;              // list of IDs for tabs on this page
			this.activeTabID = activeTabID;      // ID of currently active tab
			this.activeColor = activeColor;      // CSS class for color of active tab
			this.inactiveColor = inactiveColor;  // CSS class for color of inactive tab
			
			// prepare elements involved
			for (var i = 0; i < this.tabList.length; ++i) {
				// set CSS classes for tab heads and content
				$(this.tabList[i]).addClassName('tabHead');
				$(this.tabList[i] + '_content').addClassName('tabContent');
				
				// set active tab head color, hide inactive tabs
				if ($(this.tabList[i]).id == this.activeTabID) {
					$(this.tabList[i]).addClassName('tabActive ' + activeColor);
				} else {
					$(this.tabList[i]).addClassName(this.inactiveColor);
					$(this.tabList[i] + '_content').hide();
				}
				
				// set event handlers on each tab head
				Event.observe(tabList[i], 'click', this.showTab.bindAsEventListener(this), false);
			}
		},
		
		// -- shows tab according to element which triggered the event --
		// params:
		//   evt = event which triggered this listener function
		showTab: function (evt) {
			var child = Event.findElement(evt, 'div');
			
			// we don't want to go through all this trouble if the tab is already active, or if it's not even in the list
			if (child.id == this.activeTabID || this.tabList.indexOf(child.id) == -1) return;
			
			// switch classes to make tab look active, and show appropriate content div for this tab
			$(this.activeTabID).removeClassName('tabActive');
			$(this.activeTabID).removeClassName(this.activeColor);
			$(this.activeTabID).addClassName(this.inactiveColor);
			$(this.activeTabID + '_content').hide();
			this.activeTabID = child.id;
			$(this.activeTabID).removeClassName(this.inactiveColor);
			$(this.activeTabID).addClassName('tabActive ' + this.activeColor);
			$(this.activeTabID + '_content').show();
		}
	};

}

function isEmpty(field) {
    if (field != null && field.length > 0) {
        return false;
    }
    return true;
}





function popupUrl(url, params) {
	if (params == null) params = 'width=550,height=550,dependent=yes,resizable=yes';
	w = window.open(url, '', params);
	w.focus();   
	return false;
}


function go(form, selectBox) {
	box = form.elements[selectBox];
	destination = box.options[box.selectedIndex].value;
	if (destination) 
		location.href = destination;
}


function goPop(form, selectBox) {
	var popupPrefix = 'popup+';
	box = form.elements[selectBox];
	destination = box.options[box.selectedIndex].value;
	if (destination.substring(0, popupPrefix.length) == popupPrefix) {
	destination = destination.substring(popupPrefix.length);
		return popupUrl(destination);
	}
	else if (destination) 
		location.href = destination;
}
 
function buildSelectBox(aSelectBoxObj, aValues, aOptions) {
	aSelectBoxObj.length=0;
	if (aValues.length!=0) {
		for(var i=0; i<aValues.length; i++) {		
		 	var vSelectBoxOption = new Option(aOptions[i], aValues[i], false, true);
			aSelectBoxObj.options[aSelectBoxObj.length] = vSelectBoxOption;
		}
		aSelectBoxObj.selectedIndex=0;
	}
}

function buildSelectBoxes(aSelectBoxName, aValues, aOptions) {
	var vSelectBoxes = document.getElementsByName(aSelectBoxName);
	if(vSelectBoxes!=null) {
		for(var i=0; i<vSelectBoxes.length; i++) {
			buildSelectBox(vSelectBoxes[i], aValues, aOptions);
		}
	}
}