// JavaScript Document

sfHover = function() {     
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");     
	
		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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var sv;
function akt(id){
	if (sv) document.getElementById("a"+sv).style.fontWeight = "normal";
	document.getElementById("a"+id).style.fontWeight = "bold";
	//if (id < 8) document.getElementById("v"+id).style.borderColor = "#0170B7";
	sv = id;
}

function sb2(){
	var f = 0;
	f += al((document.getElementById("v2").value) ? 0 : 2);
	f += al((document.getElementById("v4").value) ? 0 : 4);
	f += al((document.getElementById("v5").value) ? 0 : 5);

	if (f > 0) alert("Bitte die Pflichtfelder ausfüllen!");
	else window.document.form1.submit();
}

function sb3(){
	var f = 0;
	
	f += al((document.getElementById("v1").value) ? 0 : 1);

	if (f > 0) alert("Bitte die Pflichtfelder ausfüllen!");
	else window.document.form1.submit();
}


function sb4(){
	var f = 0;
	f = (document.getElementById("t1").value) ? 0 : 1;
	if (f > 0) alert("Bitte beantworten Sie erst die Preisfrage!");
	else window.document.form1.submit();		
}

function sb5(){
	var f = 0;
	f += al((document.getElementById("v1").value) ? 0 : 1);
	f += al((document.getElementById("v2").value) ? 0 : 2);
	f += al((document.getElementById("v3").value) ? 0 : 3);
	f += al((document.getElementById("v5").value) ? 0 : 5);
	f += al((document.getElementById("v6").value) ? 0 : 6);	

	if (f > 0) alert("Bitte die Pflichtfelder ausfüllen!");
	else window.document.form1.submit();
}

function al(id){
	if (id != 0) {
		document.getElementById("v"+id).style.borderColor = "#FF0000";
		return 1;
	} else return 0;
}






(function($){
     $.fn.extend({
          center: function (options) {
               var options =  $.extend({ // Default values
                    inside:window, // element, center into window
                    transition: 0, // millisecond, transition time
                    minX:0, // pixel, minimum left element value
                    minY:0, // pixel, minimum top element value
                    withScrolling:true, // booleen, take care of the scrollbar (scrollTop)
                    vertical:true, // booleen, center vertical
                    horizontal:true // booleen, center horizontal
               }, options);
               return this.each(function() {
                    var props = {position:'absolute'};
                    if (options.vertical) {
                         var top = ($(options.inside).height() - $(this).outerHeight()) / 2;
                         if (options.withScrolling) top += $(options.inside).scrollTop() || 0;
                         top = (top > options.minY ? top : options.minY);
                         $.extend(props, {top: top+'px'});
                    }
                    if (options.horizontal) {
                          var left = ($(options.inside).width() - $(this).outerWidth()) / 2;
                          if (options.withScrolling) left += $(options.inside).scrollLeft() || 0;
                          left = (left > options.minX ? left : options.minX);
                          $.extend(props, {left: left+'px'});
                    }
                    if (options.transition > 0) $(this).animate(props, options.transition);
                    else $(this).css(props);
                    return $(this);
               });
          }
     });
})(jQuery);


var $j = jQuery.noConflict();


function doSomething() {
	$j('div.wbgContainer').center();
};


var resizeTimer = null;
$j(window).bind('resize', function() {
	if (resizeTimer) clearTimeout(resizeTimer);
	resizeTimer = setTimeout(doSomething, 100);
});

var resizeTimer2 = null;
$j(window).bind('scroll', function() {
	if (resizeTimer) clearTimeout(resizeTimer2);
	resizeTimer = setTimeout(doSomething, 100);
});

var wbgId;
function clickIt(id){
	

	wbgId = id;	
	$j('div.wbgContainer').center();
	$j("div.wbgContainer").show("slow");
	$j("div.wbg"+id).show("slow");
};

function closeWrb(){
	$j("div.wbgContainer").hide("slow");
	$j("div.wbg"+wbgId).hide("slow");
}


function changeWbg(id){
	$j("div.wbg"+wbgId).hide("slow");
	$j("div.wbg"+id).show("slow");
	
	//$("div.wbg"+wbgId).slideUp("slow");
	//$("div.wbg"+id).slideDown("slow");
	
	wbgId = id;
}

<!--  KLEINE SLIDESHOW //-->
$j(window).load(GetRandom);

var maxMiniSlide = 8;
var miniSlideId;

function GetRandom() {
	miniSlideId = Math.floor(Math.random()*7)
	
	$j("div.miniSlide"+miniSlideId).show();
	$j("div.miniSlide"+miniSlideId).animate({opacity: 1.0}, 1000, stepper());
	
}

function minislide(x){
	clickIt(x);
}


function nextMiniSlide(){
	$j("div.miniSlide"+miniSlideId).animate({opacity: 0.0}, 1000, nextNextMiniSlide());
}


function nextNextMiniSlide(){

	$j("div.miniSlide"+miniSlideId).hide();
	miniSlideId ++;

	if (miniSlideId >= maxMiniSlide){
		miniSlideId = 0;
	}

	$j("div.miniSlide"+miniSlideId).show();
	$j("div.miniSlide"+miniSlideId).animate({opacity: 1.0}, 1000, stepper());


}

function stepper(){
	setTimeout( "nextMiniSlide()", 5000);
}




/*
function nextMiniSlide(){
	
	$j("div.miniSlide"+miniSlideId).hide("fast");
	
	miniSlideId ++;

	if (miniSlideId >= maxMiniSlide){
		
		miniSlideId = 0;
	}

	$j("div.miniSlide"+miniSlideId).show("fast");

}
*/


<!-- RENDEER //-->

$j(window).load(startRendeer);

function startRendeer(){
	
	moveRendeer();
	
	setTimeout(closeRendeer, 15000);
}


function moveRendeer() {
	
	var wHeight = $j(window).height();
	var wWidth	= $j(window).width();
	
	var offsetDocument = $j(document).scrollTop();
	
	var newTop = (wHeight + offsetDocument) - $j("div.apDiv1").height();
	var divPos	= $j("div.apDiv1").offset();	
	
	//alert(wHeight);
	
	$j("div.apDiv1").stop();
	$j("div.apDiv1").offset({top: newTop});
	$j("div.apDiv1").animate({"left": wWidth-$j("div.apDiv1").width(),"top":newTop}, 5000);


}

function closeRendeer() {
	$j("div.apDiv1").animate({opacity: 0.0}, 1000);
}



$j(window).bind('resize', function() {
	moveRendeer();
});

$j(window).bind('scroll', function() {
	moveRendeer();
});


// Rolle

$j(window).load(showRoll);

function showRoll() {
	$j('div.rolle').center();
};

function closeRolle(){
	$j("div.rolle").animate({opacity: 0.0}, 1000);	
}

var resizeTimer3 = null;
$j(window).bind('resize', function() {
	if (resizeTimer3) clearTimeout(resizeTimer3);
	resizeTimer3 = setTimeout(showRoll, 100);
});

$j(window).bind('scroll', function() {
   if (resizeTimer3) clearTimeout(resizeTimer3);
	resizeTimer3 = setTimeout(showRoll, 100);
});






