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(document.location.href, document.title);
    window.external.AddFavorite(url,titel);
  }
  else
  {
    //alert("Diese Funktion steht nur f?r Internet Explorer zur Verf?gung");
    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();

  /* ::: 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 ##### */

});


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' } });
      }
    });
  });
}














$(function(){
  //highlightWord($("body")[0],"Lorem");
  $.bpalib(["striper", "popup", "external", "autoClearInput", "jqtabs"]);

  $.formreplacement();
  $.addicons("body");
// 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});

});



//-->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);
};








window.onload = function(){

  var options = {
    overlayOpacity: '0.9',
    slideshowDelay: 5
  };
  Shadowbox.init(options);

  $.each( $("div.imgleft"), function(i, n){
    $(n).width($(n).children("img:first:child").width());
  });
  $.each( $("div.imgright"), function(i, n){
    $(n).width($(n).children("img:first:child").width());
  });

};


