/****************************************************************************************
 * Toggle Box
 *
 * @version 14.09.2009 
 ****************************************************************************************/
 var FroschMenue = { start:function () {
		// Initializes navigation show/hide boxes
		FroschMenue.toggleSlideBox();
	},
// Navigation show/hide boxes
	toggleSlideBox:function () {
		
		// Show/hide menu box in mainnavigation on click
		$("#nav_service .TgBoxHeadline").bind("click", function(){

			// Toggles slider
			$(this).next(".tgBoxDiv").slideToggle("normal");

			return false;
		});

		// Show/hide menu box in service/kontakt navigation on mouseover/out
		var toSv1, toSv2;
		$("#nav_service").bind("mouseenter focus", function(){
			var svId = $(this);
			clearTimeout(toSv2);
			toSv1 = setTimeout(function(){

				// Slide down kontakt box
				svId.find(".tgBoxDiv").slideDown("normal");
			}, 250);

		}).bind("mouseleave", function(){
			var svId = $(this);
			clearTimeout(toSv1);
			toSv2 = setTimeout(function(){

				// Slide up kontakt box
				svId.find(".TgBoxHeadline").next(".tgBoxDiv").slideUp("normal");
			}, 250);

		});

		// Disables click functionality in service/kontakt headline
		$("#nav_service .TgBoxHeadline").bind("click", function(){

			return false;
		});
	}
}
/****************************************************************************************
 * class flyoutNavigation
 *
 * @version 18.05.2009 17:13 
 ****************************************************************************************/
if($.browser.msie && $.browser.version<7) $.browser.msie6 = true;
var flyoutNavigation = { start:function () {

	var a, b, c, d, e;
	var f = false;
	var g = false;
	var fallBack = $("#ifJsDisabled");

	if (fallBack) { fallBack.attr("rel", "alternate stylesheet"); fallBack.attr("disabled", "disabled"); }
	if ($.browser.msie6) { $(".navLevel2").append("<!--[if lte IE 6.5]><iframe src='/Adesign/trans.gif'></iframe><![endif]-->"); }

	$(".navLevel1 > li").siblings().find("a:first:not(.lnDirect)").bind("mouseenter focus", function()
	{
		g = true; a = $(this); b = a.next();
		var h = $(this).offset();
		var k = $(this).position();
		var m = $(window).scrollTop();
		var n = $("#pageMargins").outerHeight();
		var o = $(window).height();
		var p = b.height();
		var q = $("#footer").height();
		var r = n - q;
		if(r < o && n <= o) { var s = h.top + p + q; }
		else if(r < o && n > o) { var s = h.top + p + (q-(n-o)); }
		else if (r > o && m < (r-o)) { var s = h.top + p - m; }
		else if (r > o && m >= (r-o)) { var s = h.top + p + (q-(n-o)); }
			
		if(o > s) {
			b.css({top:k.top-3});
			if ($.browser.msie6) { b.css({top:k.top-2}); }
		}
		else {
			snk = s - o;
			
			b.css({top:(k.top-snk)});
		}
		c = setTimeout(function() {
			$(".navLevel2").hide();
			$(".navLevel1 a:not(.lnDirect)").removeClass("IPNavPath");

			a.addClass("IPNavPath");

			b.show();
			f = false;
		}, 250);
		})
		.bind("mouseleave", function(){
			g = false;
			var a = $(this);
			var b = a.next();
			clearTimeout(c);
			d = setTimeout(function(){
				if(f == false){
					a.removeClass("IPNavPath");
					b.hide();
				}
			}, 300);
		});
		$(".navLevel1 > li").siblings().find("a:first:not(.lnDirect)").next().bind("mouseenter focus", function(){
			f = true;
			clearTimeout(c);
			clearTimeout(d);
			clearTimeout(e);
			$(this).show();
		})
		.bind("mouseleave", function(){
			f = false;
			b = $(this);
			e = setTimeout(function(){
				if(g == false){	
				
					b.hide();
					$(".navLevel1 a:not(.lnDirect)").removeClass("IPNavPath");
				}
			}, 500);
		});
	}
}
jQuery(	function($) { FroschMenue.start(); } );
jQuery(	function($) { flyoutNavigation.start(); } );

/****************************************************************************************
 * Popup Fenster
 ****************************************************************************************/
function popUp(strURL,strType,strHeight,strWidth) {
			var strOptions="";
				if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
				if (strType=="benutzer") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth;
				if (strType=="showall") strOptions="toolbar,menubar,scrollbars,resizable,location,status,height="+strHeight+",width="+strWidth;
				if (strType=="elastic") strOptions="menubar,scrollbars,resizable,height="+strHeight+",width="+strWidth;
				
				if ( window.screen ) {
				    var ah = screen.availHeight - 30;
				    var aw = screen.availWidth - 10;
		
				    var xc = ( aw - strWidth ) / 2;
				    var yc = ( ah - strHeight ) / 2;
				
				strOptions += ",left=" + xc + ",screenX=" + xc;
				strOptions += ",top=" + yc + ",screenY=" + yc;
				}
				// Fenster öffnen	
				fenster = window.open(strURL, 'newWin', strOptions);
				fenster.focus();
				}
				
/****************************************************************************************
 * Table Ruler + Overviews + Tooltip + Filter
 ****************************************************************************************/	
$(document).ready(function(){ 
  $(".ruler tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
  /*$(".ruler tr:even").addClass("alt"); alternierende Hintergrundfarbe bei Zeilen*/
  
  $('.desti-hover').hover(function(){
	$(this).css('zIndex',2).find('.hover').show();},function()
	{$(this).css('zIndex',0).find('.hover').hide();
	});
	
  $("map > area").tooltip({opacity:0.9,positionLeft:true,showURL:false,left:5,showBody:" | ",track:false,fade:250});
  
  $(".selektor >  a").click(function(e){
	  $(".selektor >  a").removeClass("active");
	  $(this).addClass("active");
	  var divdisplay = "."+e.target.id;
	  $("div.filter").hide();
	  $(divdisplay).fadeIn();
	  //alert(e.target.id);
	  return false;
	  });	
	
});

/****************************************************************************************
 * Tooltip
 ****************************************************************************************/
$(function() {
$('.tooltip').tooltip({ 
opacity: 0.9, 
positionLeft: false,
showURL: false,
left: 5,
showBody: " | ",
track: true
 });
});

/****************************************************************************************
 * Google analytics
 ****************************************************************************************/
$(document).ready(function() {var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");$.getScript(gaJsHost + "google-analytics.com/ga.js",function() {var pageTracker = _gat._getTracker('UA-235824-1');pageTracker._initData();
pageTracker._trackPageview();});
 
/****************************************************************************************
 * Fancybox Galerien
 ****************************************************************************************/

	$("a.fancy_photo").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'titlePosition' : 'over',
		'padding'       :  0
	});

	$("a.fancy_galerie").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'titlePosition' : 'over',
		'padding'       :  0,
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' : ' + title + '</span>';
		}
	});

// iframes
	$("a.fancy_iframe").each(function(){ 
				var ref_value = $(this).attr('rev');
				var dWidth = 900;
				var dHeight = 450;
				try {var dWidth = parseInt(ref_value.match(/width:\s*[0-9]+/i)[0].replace(/[^0-9]/g,''))} catch (e) {};
				try {var dHeight = parseInt(ref_value.match(/height:\s*[0-9]+/i)[0].replace(/[^0-9]/g,''))} catch (e) {};
		$(this).fancybox(
		{	'showNavArrows': false,'transitionOut': 'none','type': 'iframe','scrolling': 'auto', 'padding':0, 'titlePosition': 'over','width': dWidth,'height': dHeight
		});
	});

/*Postbox MyFrosch*/
		$(".postbox").fancybox({
			'width'				: 550,
			'height'			: 330,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'overlayOpacity'	: '0.6',
			'titlePosition'  	: 'over'
		});
		
/*Fotogalerie MyFrosch*/
	  $("a[rel=wasistneu]").fancybox({
		  'transitionIn'		: 'none',
		  'transitionOut'		: 'none',
		  'titlePosition' 	: 'over',
		  'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			  return '<span id="fancybox-title-over">Bild ' +  (currentIndex + 1) + ' / ' + currentArray.length + ': ' + title + '</span>';
		  }
	  });


 });

