function setBookmark() {
  var brty = navigator.appName;
  var brve = navigator.appVersion;
  var url=document.location.href; 
  var titel = document.title; 
  if (brty.indexOf("Explorer")>-1) {
    // add this page to favorites for IE4+
    window.external.AddFavorite(url,titel);
  } else {
    alert(unescape("Diese Funktion steht nur f%FCr Internet Explorer zur Verf%FCgung"));
  }
}

function Top(){
 document.location.href="#Top";
}

function winOpen(theURL,winName,features) {
  winName = window.open(theURL,winName,features); 
  if(winName == null || winName.closed) {
    window.open(theURL,winName,features);
  } else {
    winName.location.href = theURL;
  } 
  if (!winName.closed) {
    winName.focus(); 
  }
}



$(document).ready(function(){
  initTabs();

  $.each($("div.kasten-3"), function(i, n) {
   $(n).wrapInner("<div class=\"kasten-3-content\"></div>");
  });
  
  $.each($("div.teaser-kasten"), function(i, n) {
   $(n).wrapInner("<div class=\"teaser-kasten-content\"></div>");
  });

  $.each($("div.link a"), function(i, n) {
   $(n).addClass("videolink");
   $(n).wrapInner("<span></span>");
  });



	$('.logos').cycle({ 
		fx:    'fade', 
		pause:  5 
	});


$.each($(".labelh2"), function(i, n) {
	var str = $(n).html();
	str = str.substring(21);	
	$(n).html(str);
});
$.each($("select.text"), function(i, n) {
	$(n).attr("disabled", "");
});

$.each($("#kontaktformular input.text, #empfehlen input.text, #empfehlen textarea.text"), function(i, n) {
	if ($(n).val() != '') {  $(n).addClass("filled"); }
});
$("#kontaktformular input.text, #empfehlen input.text, #empfehlen textarea.text").focus(function () {
	$(this).addClass("filled"); 
});
$("#kontaktformular input.text, #empfehlen input.text, #empfehlen textarea.text").blur(function () {
	if ($(this).val() == '') { $(this).removeClass("filled"); }
});

$.each($(".firstcol, .secondcol"), function(i, n) {
	if ($(n).children().size() == 0) {  $(n).addClass("hide"); }
});

$.each($(".contentbottom"), function(i, n) {
	var number = $(n).children().size();					 
	var numberfirstcol = $(n).children(".firstcol").children().size();
	var numbersecondcol = $(n).children(".secondcol").children().size();
	if (number <= 3 && numberfirstcol == 0 && numbersecondcol == 0 ) {  $(n).addClass("hide"); }
});


$.each($("#kontaktformular input.sonstige"), function(i, n) {
	if ($(n).val() != '') {  $(n).prev().children().attr("checked","checked").val("1"); }
});
$("#kontaktformular input.sonstige").focus(function () {
	$(this).prev().children().attr("checked","checked").val("1"); 
});
$("#kontaktformular input.sonstige").blur(function () {
	if ($(this).val() == '') { $(this).prev().children().attr("checked","").val("0"); }
});



  /* ::: Start H1 Kasten Function ::: */
  $.each( $(".h1-kasten > .h1-kasten-center"), function(i, n){
    jQuery(n).before("<div class='h1-kasten-top'><h1>"+$(n).children("h1:first-child").html()+"</h1></div>");
	$(n).children("h1:first-child").remove();
	jQuery(n).after("<div class='h1-kasten-bottom'></div>");
  });
  
  zahl = 0;

  $.each( $(".h1-kasten > .h1-kasten-center > .kasten-3-kasten"), function(i, n){							
           info = $(n).parent().children(1).attr("class"); /* liegt schon eine neue Verschachtelung vor? im ersten Durchgang nicht */
           /*$(n).append("<div class='mkl'>Info: "+ info +"</div>"); */
           if (info == "kasten-3-kasten") { zahl = 1; }
           /*$(n).append("<div class='mkl'>Zahl: "+ zahl+"</div>"); */
								   
           if (zahl % 3 == 1 ) { $(n).before("<div class='kasten-3'><div class='kasten-3-content'></div></div>"); }
           $(n).prev(".kasten-3").children(".kasten-3-content").append($(n));
           /*if (zahl % 3 == 0) { $(n).parent(".kasten-3-content").append("<div class='clear'></div>"); } wird nun weiter unten f?r alle bereits bestehenden kasten-3-content gesetzt */
           if (zahl % 3 == 1) { $(n).parent(".kasten-3-content").parent(".kasten-3").append("<div class='halfspacer></div>"); }

           zahl = zahl + 1; 
   });
  
   $(".kasten-3-content").append("<div class='clear'></div>"); 

  $.each( $(".h1-kasten-13 > .h1-kasten-center"), function(i, n){
    jQuery(n).before("<div class='h1-kasten-top'><h1>"+$(n).children("h1:first-child").html()+"</h1></div>");
	$(n).children("h1:first-child").remove();
	jQuery(n).after("<div class='h1-kasten-bottom'></div>");
  });
  
    $.each( $(".h1-kasten-23 > .h1-kasten-center"), function(i, n){
    jQuery(n).before("<div class='h1-kasten-top'><h1>"+$(n).children("h1:first-child").html()+"</h1></div>");
	$(n).children("h1:first-child").remove();
	jQuery(n).after("<div class='h1-kasten-bottom'></div>");
  });


  $.each( $(".h1-kasten > .h1-kasten-center"), function(i, n){	
   video=0;
   gesamtvideo = jQuery(".video-box-small", n).size();
   $.each( jQuery(".video-box-small", n), function(i, m){							
           video = video + 1
           if (video % 4 == 0) { $(m).after("<div class='halfspacer'></div>"); $(m).addClass("video-box-small-last"); } ; 
           if (video == gesamtvideo) { $(m).after("<div class='clear'></div>"); } ; 
       });
   });




  /* ::: Start cutter Function ::: */
  $.each( $("div.cutter > div"), function(i, n){
    $(n).children("h2:first-child").addClass("hide");
    jQuery(n).before("<h2 class='cutter-top'>"+$(n).children("h2:first-child").html()+"</h2>");
	$(n).wrapInner("<div class=\"cutter-cut\"></div>");
  });
  $(".start").children(".cutter-cut").css("height","137px");
  $(".cutter-top").click(function() {
    $(this).next("div.start, div.selected").children(".cutter-cut").animate({ height: '100%'},{duration: 300, 
      complete:function(){
        $(this).parent().addClass("notselected");  
		$(this).parent().removeClass("selected");  
		$(this).parent().removeClass("start");
		$(this).parent().prev(".cutter-top").toggleClass("selected");
    } });
	$(this).next("div.notselected").children(".cutter-cut").animate({ height: '137px'},{duration: 300, 
      complete:function(){
        $(this).parent().addClass("selected");  
		$(this).parent().removeClass("notselected");  
		$(this).parent().prev(".cutter-top").toggleClass("selected");
    } });
  });
/* ##### End cutter Function ##### */





  /* ::: Start Accordion Function ::: */
  $.each( $("div.onAccordion > div"), function(i, n){
    $(n).children("h2:first-child").addClass("hide");
    jQuery(n).before("<h2 class='onAccHead'>"+$(n).children("h2:first-child").html()+"</h2>");

    if ($(n).hasClass('open')) {
      $(n).prev(".onAccHead").addClass("selected")
      $(n).prev(".onAccHead").addClass("selected")
    } else {
      $(n).addClass("hide");
    }
  });

  $(".onAccHead").click(function() {
    $(this).addClass("current");
    $.each( $(this).parent(".onAccordion").children(".selected:not('.current')"), function(i, n){
      $(n).next("div").animate({ height: 'toggle', opacity: 'toggle'},{duration: 300,
        complete:function(){ 
          $(n).parent(".onAccordion").children(".onAccHead:not('.current')").removeClass("selected");
      } });
    });
    $(this).next("div").animate({ height: 'toggle', opacity: 'toggle'},{duration: 300, 
      complete:function(){
        $(this).prev(".onAccHead").toggleClass("selected");  
        $(this).prev(".onAccHead").removeClass("current");
    } });
  });
/* ##### End Accordion Function ##### */

$("#teasernavi").css("display","block");



/*Kongressanmeldung-Montag */
$('input#ctl00_ctl00_content_contentwide_montagrrg').click(function() {
     $('#ctl00_ctl00_content_contentwide_montagexp').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labelmontagrrg').click(function() {
     $('#ctl00_ctl00_content_contentwide_montagexp').removeAttr('checked');
});
$('input#ctl00_ctl00_content_contentwide_montagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_montagrrg').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labelmontagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_montagrrg').removeAttr('checked');
});

/*Kongressanmeldung-Donnerstag */
$('input#ctl00_ctl00_content_contentwide_donnerstagreg').click(function() {
     $('#ctl00_ctl00_content_contentwide_donnerstagexp').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labeldonnerstagreg').click(function() {
     $('#ctl00_ctl00_content_contentwide_donnerstagexp').removeAttr('checked');
});
$('input#ctl00_ctl00_content_contentwide_donnerstagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_donnerstagreg').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labeldonnerstagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_donnerstagreg').removeAttr('checked');
});

/*Kongressanmeldung-Freitag*/
$('input#ctl00_ctl00_content_contentwide_freitagreg').click(function() {
     $('#ctl00_ctl00_content_contentwide_freitagexp').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labeldfreitagreg').click(function() {
     $('#ctl00_ctl00_content_contentwide_freitagexp').removeAttr('checked');
});
$('input#ctl00_ctl00_content_contentwide_freitagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_freitagreg').removeAttr('checked');
});
$('label#ctl00_ctl00_content_contentwide_Labelfreitagexp').click(function() {
     $('#ctl00_ctl00_content_contentwide_freitagreg').removeAttr('checked');
});




});


function initTabs() {
  $("div.generate-ui-tab").prepend("<ul></ul>");
  $.each( $("div.generate-ui-tab > .supertab > h2"), function(i, n){
    var test = $(n).html();
    $(n).parent(".supertab").attr("id","tab_"+i+"");
    $(n).parent(".supertab").parent(".generate-ui-tab").children("ul").append("<li><a href='#tab_"+i+"'>"+test+"</a></li>");
    $(n).addClass("hide");
  });
  $.each( $("div.generate-ui-tab"), function(j, m){  
    $.each( $(m).children(".supertab"), function(i, n){  
      if($(n).parent(".generate-ui-tab").children().is(".defaulttab")){
        if($(this).is(".defaulttab")){
          $(this).parent(".generate-ui-tab").children("ul").tabs({ fx: { height: 'toggle', opacity: 'toggle' },selected: i });
        } 
      } else {
        $(n).parent(".generate-ui-tab").children("ul").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
      }
    });
  });
}















//-->checkbox/radio-replacement<--
jQuery.formreplacement = function () {
	$.each( $("label[for]"), function(i, n){
		if($(n).next("input").hasClass("replace")){
			$(n).next("input").removeClass("replace").addClass("chbxhide");
			if ($(n).next("input").attr("type") == "checkbox") {
				$(n).addClass("chbx");
				$(n).click(function(){
					$(n).toggleClass("chkd");
				});
			} else {
				$(n).addClass("rd");
				$(n).click(function(){
					labelname = $(n).next().attr("name");
					$.each( $("input[name="+labelname+"]"), function(j, o){
						if($(o).hasClass("chbxhide")){
							$(o).prev("label").removeClass("chkd");
						}
					});
					$(n).addClass("chkd");
				});
			}
			if ($(n).next("input").attr("checked")) {
						$(n).addClass("chkd");
			}
		}
	});
};
// addicons //
jQuery.addicons = function(options) {
	var elem = options.split(",");
	for(var i = 0; i<elem.length; i++){
		//$(elem[i] +" a[target='_blank']").addClass("blank");
		//$(elem[i] +" a[rel='external']").addClass("blank");
		$(elem[i] +" a[href*='pdf']").addClass("pdf");
		//$(elem[i] +" a[href*='doc']").addClass("doc");
		$(elem[i] +" a[href*='xls']").addClass("xls");
		$(elem[i] +" a[href*='zip']").addClass("zip");
		$(elem[i] +" a[href*='mp3']").addClass("mp3");
		//$(elem[i] +" a[href*='window.print()']").addClass("print");
		//$(elem[i] +" a[href*='#top']").addClass("totop");
		//$(elem[i] +" a[href*='mailto:']").addClass("mailto");
	}
};

// bpalib //
(function($j){
	$j.bpalib = function(enabled_modules){
		
		var modules = {
			
			striper: function(){
				$j(".striped").children(":odd").addClass("odd");
			},

			popup: function(){
				$j("a[rel^='popup']").click(function(){
					var dims = this.getAttribute('rel').match(/.*\[([0-9]+)-([0-9]+)\].*/);
					window.open(this.getAttribute('href'),'Info','width=' + dims[1] + ',height=' + dims[2] + ',resizable,scrollbars');
					return false;
				});
			},
			external: function(){
				$j("a[rel='external']").click(function(){
					window.open(this.getAttribute('href'));
					return false;
				});
			},
			autoClearInput: function(){
				$j("input.autoclear:text, input.autoclear:password").focus(function(){
					if (this._defaultValue == this.value){
						this.value="";
					}
				})
				.each(function(){
					this._defaultValue = this.getAttribute("value");
				});
			},
			
			autoFocusInput: function(){
				var focusElmts = $j("input.autofocus");
				if (focusElmts.length != 0){
					 focusElmts.get(0).focus();
				}
			}
		};
		
		if (enabled_modules){
			$j.each(enabled_modules,function(i,n){
				if(modules[n]){
					modules[n](i);
				}
			});
		}
		else {
			$j.each(modules,function(i,n){n();});
		}
		
	};
})(jQuery);

// scroll //
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e) {
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e)  {
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};
jQuery.intval = function (v) {
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};
jQuery.fn.ScrollTo = function(s) {
	o = jQuery.speed(s);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, o);
	});
};
jQuery.fx.ScrollTo = function (e, o) {
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};


/*
 * jQuery 'onImagesLoaded' plugin v1.1.0
 * Fires callback functions when images have loaded within a particular selector.
 *
 * Copyright (c) Cirkuit Networks, Inc. (http://www.cirkuit.net), 2008.
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * For documentation and usage, visit "http://includes.cirkuit.net/js/jquery/plugins/onImagesLoad/1.1/documentation/"
 */
(function($){$.fn.onImagesLoad=function(options){var self=this;self.opts=$.extend({},$.fn.onImagesLoad.defaults,options);self.bindEvents=function($imgs,container,callback){if($imgs.length===0){if(self.opts.callbackIfNoImagesExist&&callback){callback(container);}}else{var loadedImages=[];if(!$imgs.jquery){$imgs=$($imgs);}$imgs.each(function(i,val){$(this).bind('load',function(){if(jQuery.inArray(i,loadedImages)<0){loadedImages.push(i);if(loadedImages.length==$imgs.length){if(callback){callback(container);}}}}).each(function(){if(this.complete||this.complete===undefined){this.src=this.src;}});});}};var imgAry=[];self.each(function(){if(self.opts.itemCallback){var $imgs;if(this.tagName=="IMG"){$imgs=this;}else{$imgs=$('img',this);}self.bindEvents($imgs,this,self.opts.itemCallback);}if(self.opts.selectorCallback){if(this.tagName=="IMG"){imgAry.push(this);}else{$('img',this).each(function(){imgAry.push(this);});}}});if(self.opts.selectorCallback){self.bindEvents(imgAry,this,self.opts.selectorCallback);}return self.each(function(){});};$.fn.onImagesLoad.defaults={selectorCallback:null,itemCallback:null,callbackIfNoImagesExist:false};})(jQuery);


$(function(){
  //highlightWord($("body")[0],"Lorem");
  Highlight("content");
  $.bpalib(["striper", "popup", "external", "autoClearInput", "jqtabs"]);
  $.formreplacement();
  $.addicons("#content");
  $.addicons("#teaser");
  
  // scroll to pagetop
  $('.totop').click(function(){$('#top').ScrollTo(800);return false});
  $('.tonavigation').click(function(){$('#navigation').ScrollTo(800);return false});
  $('.tocontent').click(function(){$('#content').ScrollTo(800);return false});

  //attach onImagesLoad to the body 
  $('body').onImagesLoad({ 
    selectorCallback: selectorImagesLoaded 
  }); 
  //the selectorCallback function, invoked once when all images contained within $('body') have loaded 
  function selectorImagesLoaded($selector){
	//::: set width of image-keeper for IE :::
    //note: $selector is $('body') here
    //$selector.prepend('<div class="loaded">All images have loaded within &lt;BODY&gt;</div>');
    $.each( $("div.imgleft"), function(i, n){
      var imgwidth = $(n).children("img:first:child").width();
      var linkedimgwidth = $(n).children("a:first").children("img:first").width();
      if(imgwidth != null){
        $(n).width(imgwidth);
      } else if (linkedimgwidth != null){
        $(n).width(linkedimgwidth);
      }
    });
    $.each( $("div.imgright"), function(i, n){
      var imgwidth = $(n).children("img:first:child").width();
      var linkedimgwidth = $(n).children("a:first").children("img:first").width();
      if(imgwidth != null){
        $(n).width(imgwidth);
      } else if (linkedimgwidth != null){
        $(n).width(linkedimgwidth);
      }
    });
	
  //::: init Shadowbox :::
  var options = {
    overlayOpacity: '0.85',
    slideshowDelay: 5
  };
  Shadowbox.init(options);
	  
	  $.each($(".imglefttextdiv"), function(i, n) {
	   var width = $(n).children("div").children("img").width();
	   $(n).children("div").children("ul").children("li").css("background-position",width +"px 3px");
	   $(n).children("div").children("ul").children("li").css("padding-left", width+15);
	  });

  }

});



function isEventCodeEnter( evt, frm)
{
  var keyCode = null;
  if( evt.which ) 
    keyCode = evt.which;
  else if( evt.keyCode ) 
    keyCode = evt.keyCode;

  if( 13 == keyCode )
    return true;
  else
    return false;

}
function onEnterSearch( evt, frm) 
{
    if(isEventCodeEnter( evt, frm))
    {
      fulltextsearch();
      return false;
    }
   return true;
}

function fulltextsearch()
{
  document.location.href="/Suche.aspx?searchvalue=" + document.getElementById("searchvalue").value; 
}
