jQuery.noConflict(); 

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}

function getScrollY() {
	var scrOfX = 0, scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return scrOfY;
}


function getViewPortHeight() {
	var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 
 return viewportheight;

}

/*
function moveToPosition(target, targetY) {
	jObj = $("#" + target);
	obj = document.getElementById(target);

	speed = 20;
	recentY = obj.offsetTop;
	
	distance = (targetY - recentY) / speed;
		jObj.css("top", recentY + distance);
	
	if(distance < 1) {
	
		jObj.css("top", targetY);
	} else {
		setTimeout(moveToPosition, 31, target, targetY);
	}
}
*/
function positionMainNavi() {
	yVar = jQuery("#mainnavi").height() + 12;
	pos = findPosition(document.getElementById("footer"));
	if((pos[1] - yVar) > getViewPortHeight() + getScrollY() - yVar) {
		newY = getViewPortHeight() + getScrollY() - yVar;
	} else {
		newY = (pos[1] - yVar);
	}
	
	//moveToPosition("mainnavi", newY);
	jObj = jQuery("#mainnavi");
	obj = document.getElementById("mainnavi");

	speed = 2;
	recentY = obj.offsetTop;
	
	distance = (newY - recentY) / speed;
		
	
	if(distance < 1) {
		jObj.css("top", newY);
	} else {
		jObj.css("top", recentY + distance);
	}
	
}

jQuery(document).ready(function() {
	jQuery("#mainnavi").css("position", "absolute");
	positionMainNavi();
	setInterval(positionMainNavi, 30);
	
	jQuery("div.toggleSliderNavi").hover( 
		function() {
			jQuery("ul.navigation").css("top", jQuery("div.toggleSliderNavi").css("top"));
			
			jQuery("ul.navigation").hover(
				function() {},
				function() {
					jQuery("ul.navigation").css("top", -999 + "px");
				}
			);
			
			jQuery("ul.navigation a").click(function() {
				jQuery("div.toggleSliderNavi").html( jQuery(this).html() );
				jQuery("ul.navigation").css("top", -999 + "px");
			});
			
			jQuery("ul.navigation a").hover(
				function() {
					if(!jQuery(this).hasClass("selected")) {
						jQuery(this).addClass("dropNaviHover");
					}
				},
				function() {
					jQuery(this).removeClass("dropNaviHover");
				}
			);
	});
	
	// Adress Entry Animation	
	var pid = jQuery('#pid').html();
	if(pid == 46) { //Mitglieder (Vorstand im Kiwi-Slider
		jQuery('.address-entry').css('cursor', 'pointer');
		var click_address = function() {
			if(jQuery(this).hasClass('open')) {
				jQuery(this).removeClass('open');
				jQuery(this).children('.address-img').css('display', 'none');
				jQuery(this).animate({
					height: '30px' 
				}, 500);
			} else {
				jQuery(this).addClass('open');
				jQuery(this).children('.address-img').css('display', 'block');
				jQuery(this).animate({
					height: '100px' 
				}, 500);
			}
		};
		
		jQuery('.address-entry').hover(
			function() {
				jQuery(this).css('background', '#f4d67e');
			}, function() {
				jQuery(this).css('background', '#ffffff');
			}
		);
		
		jQuery('.address-entry').click(click_address);
	} else {
		jQuery('.address-entry').addClass('open');
		jQuery('.address-entry').children('.address-img').css('display', 'block');
		jQuery('.address-entry').animate({
			height: '100px' 
		}, 500);
	}
	
	//Deactivate Submit-Button onClick
	/*jQuery('.powermail_submit').click(function() {
		var intCnt = 1;
		jQuery(this).attr("readonly", true);
		jQuery(this).val('Warten: ' + 5);
		var countdown = setInterval(function() {
			if(intCnt == 5) {
				 clearInterval(countdown);
				 jQuery('.powermail_submit').val('Abschicken');
				 jQuery('.powermail_submit').removeAttr("readonly");
			} else {
				jQuery('.powermail_submit').val('Warten: ' + (5 - intCnt));
				intCnt++;
			}
		}, 1000);
		
	});*/
	
	
	//Header Fla
	var flashvars = {};
		var params = {
			menu: "false",
			scale: "noScale",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			wmode: "transparent",
			bgcolor: "none"
		};
		
		var attributes = {
			
		};
		swfobject.embedSWF("fileadmin/templates/swf/fskonfetti.swf", "konfettiSWF", "740", "150", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
});
