/* * ARITHNEA GmbH * JavaScript Utilities*/// activate stylesheet with certain media typefunction setActiveStyleSheet(mediaType) {  var i, a, main;   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("media") == mediaType) {       a.disabled = false;       a.media='all';     }   }}// set all links target="_top" to target="_self" ; hint: include call at the end of the page function setLinkTargets() {    var oldTarget = '_top';    var newTarget = '_self';    var links = document.getElementsByTagName('a');    for (var i=0; i<links.length; i++) {        var link = links[i];        if (link.target == oldTarget) {          link.target = newTarget;          if (link.href.indexOf('?') == -1) {               link.href = link.href + '?KeepThis=true';          } else {               link.href = link.href + '&KeepThis=true';          }        }    }    return true;}// highlight a location in map with a red dot and location titlefunction highlightLocation () {     var loc = getParam('loc');     if(loc != 'undefined') {     	var spot = document.getElementById(loc);     	spot.className = 'spotSelected';     	spot.innerHTML = spot.title;     	spot.onmouseout  = function(){this.className = 'spot redspot';this.innerHTML='&nbsp;';};     	spot.onmouseover = function(){this.className = 'spotSelected';this.innerHTML=spot.title;};     }}// set boxes (e.g. teasers) to the same heightfunction setBoxHeight(id,matchClass) {	var tsr = $(id).find(matchClass);  // formerly: $(id).children('.tsrBoxL,.tsrBoxR')	var h = 0;	for(var i=0; i<tsr.size(); i++) {          var tsrH = tsr[i].offsetHeight;          if (tsrH > h) h = tsrH;     }	for(var i=0; i<tsr.size(); i++) {          tsr[i].style.height = h+'px';	}}// read heights of picture and text in stage and adjust stage heigth via css-class function setStageHeight(id) {	var pic = $(id).find('.imgSection');	var txt = $(id).find('.txtSection');	if(pic && txt) {		picH = pic.get(0).offsetHeight;		txtH = txt.get(0).offsetHeight;		if(txtH < picH) {               $(id).removeClass('templateStage');               txt.css('padding-bottom','500px');		}	}}var stageImgInit;var mmpc = 0;var showPic;function changeStagePic(pic,delay) {	// timeout function for little delay     clearTimeout(showPic);	showPic = setTimeout( function(){	    // find image to be changed         var stageImg = $('#mainMenu').find('img:first');	    var stageImgSrc = stageImg.attr('src');	    if(mmpc++ == 0) stageImgInit = stageImgSrc;	    if(pic != stageImgSrc) {	         // fade image out, change src, fade it in again              stageImg.fadeOut('slow',function(){                    stageImg.attr('src',pic);                    stageImg.fadeIn('slow');              });	    }	},delay);}// Overlay settings, this function should be called onloadvar overlayParam  = getParam('KeepThis');var overlayScroll = getParam('noScroll');var allowSetLinkTargets = true;function loadOverlay(){     /* activate overlay css by url parameter */ 	if(overlayParam=='true'){		//$(".toggleof").removeClass('closed');		setActiveStyleSheet('overlay');	}	if(overlayScroll=='true') document.getElementsByTagName('html')[0].style.overflow = 'auto';}// EVENTS Functions Start	// read GET-Parameter	function getParam(term){				HTTP_GET_VARS = new Array();		strGET = document.location.search.substr(1,document.location.search.length);		if(strGET!=''){		    var gArr=strGET.split('&');		    for(i=0;i<gArr.length;++i){		        var v='';		        var vArr=gArr[i].split('=');		        		        if(vArr.length>1){v=vArr[1];}		        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);		    }	    }		if(!HTTP_GET_VARS[term]){return 'undefined';}		return HTTP_GET_VARS[term];	}		function getElementsByClass(className){       var class_arr = new Array();       var all_tags = document.getElementsByTagName("*");       for(var i=0; i<all_tags.length; i++){         if(all_tags[i].className.indexOf(className) != -1) class_arr.push(all_tags[i]);       }       return class_arr;     }     function show(obj){          obj.style.display = "";          return true;     }     function hide(obj){          obj.style.display = "none";          return true;     }	      function showHideEvent(blockName,box,layer,page) {          		  var className = layer;		  var defaultpage = page;          var blocks = getElementsByClass(blockName); // all rows with outer class "events"          var shows = getElementsByClass(className); // all rows where checkbox is checked          var allBoxes = document.event_selector.eventselect;		  var resultCounter = 0;		            // reset Filter          if(className == '') {		   for(var i=0; i<blocks.length; i++){               show(blocks[i]);           }		   for(var i=0; i<allBoxes.length; i++){				allBoxes[i].checked = false;			}	    	window.location = defaultpage;	      	      //set Filter	          } else {          	                  for(var i=0; i<blocks.length; i++){										hide(blocks[i]);               }			   			   for(var i=0; i<allBoxes.length; i++){					if(allBoxes[i].checked){						//alert(allBoxes[i].id);						shows = getElementsByClass(allBoxes[i].id);						for(var j=0; j<shows.length; j++){							show(shows[j]);					    }					}				}				// if none is checked, show all rows			   var isChecked = false;          	   for(var i=0; i<allBoxes.length; i++){          	   		if(allBoxes[i].checked){isChecked = true};          	   }          	   if(!isChecked){	 			   for(var i=0; i<allBoxes.length; i++){						shows = getElementsByClass(allBoxes[i].id);						for(var j=0; j<shows.length; j++){							show(shows[j]);					    }					}         	   	          	   }          }		  for(var i=0; i<blocks.length; i++){				if(blocks[i].style.display == ""){resultCounter++;}				//alert(blocks[i].style.display);		  }		  var allCounters = getElementsByClass("eventResultCounter");		  for(var i=0; i<allCounters.length; i++){									allCounters[i].innerHTML = resultCounter;          }		  if(resultCounter==0){show(document.getElementById("noresult"));}		  else{hide(document.getElementById("noresult"));}	     //document.getElementById("eventResultCounter").innerHTML = resultCounter;          return false;          }        // all checked Checkboxes are deliverd as GET-Parameter String	function getAllChecked(){		var paramString = "";		var allBoxes = document.event_selector.eventselect;	   for(var i=0; i<allBoxes.length; i++){			if(allBoxes[i].checked){				var divider = "&";				if(paramString.length > 0){divider = "&";};				paramString = paramString + divider + allBoxes[i].id + "=true";			}		}		return paramString;			}		// initial Filter setting via GET-Parameter	function setChecked(){		// set Federal State	   document.event_selector.eventStateFilter.selectedIndex = getParam("fstate");		   	   var allBoxes = document.event_selector.eventselect;	   var isChecked = false;	   for(var i=0; i<allBoxes.length; i++){	   		if(getParam(allBoxes[i].id) == "true"){				isChecked = true;			}	   }	   // only if any Checkbox is checked, do hide/show	   if(isChecked){	   	   // set all DIVS hidden		   for(var i=0; i<allBoxes.length; i++){				blocks = getElementsByClass(allBoxes[i].id);				for(var j=0; j<blocks.length; j++){					hide(blocks[j]);			    }		   }		   for(var i=0; i<allBoxes.length; i++){		  			  		 	if(getParam(allBoxes[i].id) == "true"){					// set DIVs with Checkboxes checked visible					allBoxes[i].checked = true;					shows = getElementsByClass(allBoxes[i].id);					for(var j=0; j<shows.length; j++){						show(shows[j]);				    }				}			}		}	}			// Change Federal Country via Dropdown + GET-Parameter with Filterinformation	function changeLocation(obj) {		window.location = obj.value + "?fstate=" + obj.selectedIndex + getAllChecked();	}	// EVENTS Functions Endfunction ie8SafePreventEvent(e){    if(e.preventDefault){       e.preventDefault();      window.history.go(-1);      }    else{      window.history.go(-1);    };    e.returnValue = false;    e.stopPropagation();  }
