/* 
-----------------------------------------------------------------------------------------------
   
   -- main_js_kombiniert.js --
   
   In dieser js-Datei sind folgende von Fork angefertigten js-Dateien zusammengefasst: 

   - expandable.js
   - tabnav.js
   - texthide.js
   - scratch.js
   - tooltip.js
   - imgresize.js
   - searchlangfix.js 
   
   Die in dieser Datei nicht enthaltenen js-Dateien stammen von Dritten und wurden von Fork 
   lediglich erwendet bzw. adaptiert und verwendet: Sie wurden in eigenen Dateien belassen.
   
   - jquery-latest.js
   - main_preloadCssImagesJMB.js
   - main_swfobject.js
   - main_sniffer.js
   - main_swfobject2.js
   
   Weitere js-Dateien sind nicht in der Datei enthalten, weil sie nur nach Bedarf geladen werden:
   
   - main_ie6bgfix.js                         <- [if lte IE 6]
   - main_popup.js                            <- ifCat:MAIN_INHALTE/Popup
   
   - main_slideshow/jquery.easing.1.1.1.js    <- ifCat:MAIN_INHALTE/Slideshow
   - main_slideshow/jquery.cycle.all.js       <- ifCat:MAIN_INHALTE/Slideshow
   
--------------------------------------------------------------------------------------------------
*/


/* -------------- main_expandable.js ---------------------------------------------------------- */

  $(document).ready(function(){
   
   
	$("div.expandable div.open").hide();
   
    $("div.expandable div.closed").mouseup(function(){
	  $(this).hide();
	  $(this).next('div.open').show();	
		//event.preventDefault();

    });
	
	$("div.expandable div.closed a").click(function(event){
	  
		event.preventDefault();

    });
	
	
	$("div.expandable div.open span.expandable_hide").mouseup(function(){
	  $(this).parent().hide();
	  $(this).parent().prev('div.closed').show();
    });
	
	$("div.expandable div.open a.expandable_hide").mouseup(function(){
	  $(this).parent().hide();
	  $(this).parent().prev('div.closed').show();
    });
	
  });


/* -------------- main_tabnav.js ------------------------------------------------------------- */

   $(document).ready(function(){
   

   // navigation 
   
   $(".pull_btn_down").css("visibility","visible");
   
   
  
    $(".pull_btn_down").mouseup(function(){	
	 
		if ( $(this).hasClass("pull_btn_up") ) {
			$(this).removeClass("pull_btn_up");
			$(this).parent().parent().parent().children('.pulldown_menu').hide();
		}
		else {
			$(this).parent().parent().next('ul.pulldown_menu').show();
			var px=$(this).parent().parent().position().left;
			var hx=$(this).parent().parent().next('ul.pulldown_menu').position().left;
			var hy=$(this).parent().parent().next('ul.pulldown_menu').position().top;
			$(this).parent().parent().next('ul.pulldown_menu').css("position","absolute");
			$(this).parent().parent().next('ul.pulldown_menu').css("top",hy+"px");
			$(this).parent().parent().next('ul.pulldown_menu').css("left",px+"px");
			$(this).addClass("pull_btn_up");	
		}
    /*	*/		
    });
	
	
	$(".navlev").mouseleave(function(){		
		$(this).children('.pulldown_menu').hide();
		var pbu=$(this).children('.crumbsec').children('.levelbg').children('.pull_btn_up');
		//pbu.addClass("pull_btn_down");
		pbu.removeClass("pull_btn_up");
    });
	
  });


/* -------------- main_texthide.js ------------------------------------------------------------ */

  $(document).ready(function(){
  
  

	$("div#content_toggle").css("display","block");
	$("a.content_hide").css("display","block");
	$("div#content_toggle_top").css("display","block");
   
	var hidden=false;
	$("#content_toggle_top").hide();
    testWidth();
	
	
	
	function testWidth(){
		var tw=$(window).width();
		var minW=950; //MAGIC NUMBER
		if (tw < minW) {
			// to small
			$("#content_toggle").hide();
			if (hidden) {
				$("#content_toggle_top").show();
			}
			else {
				$("#footer .content_hide").show();
			}
		}
		else {
			// wide enough
			$("#content_toggle").show();
			
			$("#content_toggle_top").hide();
			$("#footer .content_hide").hide();
			
			var hwh=$("#headerwrapper").height();
			//alert(hwh);
			$("#content_toggle").css("top",hwh);
			
		}		
	}
	
	$(window).resize(function() {
		testWidth();
	});
	

   
    $("#content_toggle").mouseup(function(){
		if (hidden) {
			hidden=false;
			$(".content").show();
			$("#content_toggle a.ct_show").hide();
			$("#content_toggle a.ct_hide").show();
			$("#footer").show();
			$("div#headergap").removeClass("header_space_gap_temp");
			callToActionscript_BackMode('m', 'back');
		
		} else {
			hidden=true;
			$(".content").hide();
			
			$("#content_toggle a.ct_show").show();
			$("#content_toggle a.ct_hide").hide();
			$("#footer").hide();
			
			
			$("div#headergap").addClass("header_space_gap_temp");
			callToActionscript_FullMode('m', 'full');
		}

    });
	
	
	
	$("#footer .content_hide").mouseup(function(){
		$(".content").hide();
		$("#footer").hide();
		$("#content_toggle_top").show();
		hidden=true;
		$("div#headergap").addClass("header_space_gap_temp");
		callToActionscript_FullMode('m', 'full');
    });
	
	$("#content_toggle_top").mouseup(function(){
		hidden=false;
		$(".content").show();
		$("#footer").show();
		$("#content_toggle_top").hide();
		$("div#headergap").removeClass("header_space_gap_temp");
		callToActionscript_BackMode('m', 'back');
    });
	
		
  });


/* -------------- main_scratch.js ------------------------------------------------------------- */

 $(document).ready(function(){
 
    isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	fixscratch();
   
		function fixscratch() {
			$("#scratchcontainer").css("display","block");
			$("#scratchcontainer").css("width",$(window).width());
			$("#scratchcontainer").css("height",$(window).height());
		}
   
		$(window).resize(function() {		
			fixscratch();
		});
		
		/*
		if (isIE6) {
		
			$(window).scroll(function() {	
				$("#scratchcontainer").css("top", $(window).scrollTop() + "px"); 
				
			});
		
		}
		*/
 });


/* -------------- main_tooltip.js ------------------------------------------------------------- */

$(document).ready(function(){


	function SuchenUndErsetzen(QuellText, SuchText, ErsatzText)
        {   
            if ((QuellText == null) || (SuchText == null))           { return null; }
            if ((QuellText.length == 0) || (SuchText.length == 0))   { return QuellText; }

            
            if ((ErsatzText == null) || (ErsatzText.length == 0))    { ErsatzText = ""; }

            var LaengeSuchText = SuchText.length;
            var LaengeErsatzText = ErsatzText.length;
            var Pos = QuellText.indexOf(SuchText, 0);

            while (Pos >= 0)
            {
                QuellText = QuellText.substring(0, Pos) + ErsatzText + QuellText.substring(Pos + LaengeSuchText);
                Pos = QuellText.indexOf(SuchText, Pos + LaengeErsatzText);
            }
            return QuellText;
    } 
	
	function boldText(q) {
	
		var bopen=false;
		var h;
		
		
		while (true) {
			var a= q.indexOf("#");
			
			if (a == -1) {
				break;
			}
			else if (a == 0) {
				q = "<strong>" + q.substr(1);
				bopen=true;
				
			}
			else {
			
				if (bopen) {
					h = q.substr(0,a);
					q = h + "</strong>" + q.substr(a+1);
					bopen=false;
				}
				else {
					h = q.substr(0,a);
					q = h + "<strong>" + q.substr(a+1);
					bopen=true;
				}
			}
		}
		
		return q;
	}

	var yOffset=10;
	var xOffset=15;
	var ts="";
  // =========================================================================================================== //
	
	$("a.tooltip").mouseover(function(){
		$("#tooltip").css("display","block");
		var con=$(this).attr("title");
		ts=con;
		$(this).attr("title","");
		var hh=SuchenUndErsetzen(con,"//","<br />");
		hh = boldText(hh);
		$("#tooltip .ttwrap_inner").html(hh);
		$("#scratchcontainer").css("display","block");
		$("#scratchcontainer").css("width",$(window).width());
		$("#scratchcontainer").css("height",$(window).height());
    });
	
	$("a.tooltip").mouseout(function(){
		$("#tooltip").css("display","none");
		$(this).attr("title",ts);
    });
	
	$("a.tooltip").mousemove(function(e){			
		var ttx=(e.pageY - yOffset) + "px";
		var tty=(e.pageX + xOffset) + "px";
	    $("#tooltip").css("top",ttx);
		$("#tooltip").css("left",tty);			
	});	
	
	// =========================================================================================================== //
	
	$("a.eventlink").mouseover(function(){
		$("#tooltip").css("display","block");
		var con=$(this).attr("title");
		ts=con;
		$(this).attr("title","");
		var hh=SuchenUndErsetzen(con,"//","<br />");
		hh = boldText(hh);
		$("#tooltip .ttwrap_inner").html(hh);
		$("#scratchcontainer").css("display","block");
		$("#scratchcontainer").css("width",$(window).width());
		$("#scratchcontainer").css("height",$(window).height());
    });
	
	$("a.eventlink").mouseout(function(){
		$("#tooltip").css("display","none");
		$(this).attr("title",ts);
    });
	
	$("a.eventlink").mousemove(function(e){			
		var ttx=(e.pageY - yOffset) + "px";
		var tty=(e.pageX + xOffset) + "px";
	    $("#tooltip").css("top",ttx);
		$("#tooltip").css("left",tty);			
	});	
	
	// =========================================================================================================== //
	
	$("a.lbox_item").mouseover(function(){
		$("#tooltip").css("display","block");
		var con=$(this).attr("title");
		ts=con;
		$(this).attr("title","");
		var hh=SuchenUndErsetzen(con,"//","<br />");
		hh = boldText(hh);
		$("#tooltip .ttwrap_inner").html(hh);
		$("#scratchcontainer").css("display","block");
		$("#scratchcontainer").css("width",$(window).width());
		$("#scratchcontainer").css("height",$(window).height());
    });
	
	$("a.lbox_item").mouseout(function(){
		$("#tooltip").css("display","none");
		$(this).attr("title",ts);
    });
	
	$("a.lbox_item").mousemove(function(e){			
		var ttx=(e.pageY - yOffset) + "px";
		var tty=(e.pageX + xOffset) + "px";
	    $("#tooltip").css("top",ttx);
		$("#tooltip").css("left",tty);			
	});	
	
	
	// =========================================================================================================== //
	
	$("img.slideshow_info").mouseover(function(){
		$("#tooltip").css("display","block");
		var con=$(this).attr("title");
		ts=con;
		$(this).attr("title","");
		var hh=SuchenUndErsetzen(con,"//","<br />");
		hh = boldText(hh);
		$("#tooltip .ttwrap_inner").html(hh);
		$("#scratchcontainer").css("display","block");
		$("#scratchcontainer").css("width",$(window).width());
		$("#scratchcontainer").css("height",$(window).height());
    });
	
	$("img.slideshow_info").mouseout(function(){
		$("#tooltip").css("display","none");
		$(this).attr("title",ts);
    });
	
	$("img.slideshow_info").mousemove(function(e){			
		var ttx=(e.pageY - yOffset) + "px";
		var tty=(e.pageX + xOffset) + "px";
	    $("#tooltip").css("top",ttx);
		$("#tooltip").css("left",tty);			
	});		
	
	// =========================================================================================================== //
	
	
	$("div#tabbar_buttons a").mouseover(function(){
		$("#tooltip").css("display","block");
		var con=$(this).attr("title");
		ts=con;
		$(this).attr("title","");
		var hh=SuchenUndErsetzen(con,"//","<br />");
		hh = boldText(hh);
		$("#tooltip .ttwrap_inner").html(hh);
		
		
		$("#scratchcontainer").css("display","block");
		$("#scratchcontainer").css("width",$(window).width());
		$("#scratchcontainer").css("height",$(window).height());
    });
	
	$("div#tabbar_buttons a").mouseout(function(){
		$("#tooltip").css("display","none");
		$(this).attr("title",ts);
    });
	
	$("div#tabbar_buttons a").mousemove(function(e){			
		var ttx=(e.pageY - yOffset) + "px";
		var tty=(e.pageX + xOffset) + "px";
	    $("#tooltip").css("top",ttx);
		$("#tooltip").css("left",tty);			
	});		
	
	
  });


/* -------------- main_imgresize.js ----------------------------------------------------------- */

$(document).ready(function(){  

	
	$("a.zoomin").css("display","block");
	$("div.zoomout").hide();
   
	$("div.ctntimg a.zoomin").click(function(event){			   
		
		//hide small image
		$(this).parent().prev("img").hide();
		
		//get image url
		var bigimage = $(this).attr("href");	
		
		
		if ($(this).parent().parent().hasClass("halfwidth")) {
		
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("halfwidth");
			$(this).parent().parent().addClass("fullwidth");
			
			if ($(this).parent().parent().hasClass("halffloat_left")) {
				$(this).parent().parent().removeClass("halffloat_left");
				$(this).parent().parent().addClass("halffloat_left_full");
			}
			
			if ($(this).parent().parent().hasClass("halffloat_right")) {
				$(this).parent().parent().removeClass("halffloat_right");
				$(this).parent().parent().addClass("halffloat_right_full");
			}
		}
		
		
		if ($(this).parent().parent().hasClass("q1width")) {
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("q1width");
			$(this).parent().parent().addClass("fullwidth");
			$(this).parent().parent().addClass("q1full");
			
		}
		
		
		if ($(this).parent().parent().hasClass("q3width")) {
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("q3width");
			$(this).parent().parent().addClass("fullwidth");
			$(this).parent().parent().addClass("q3full");
			
			if ($(this).parent().parent().hasClass("q3float_left")) {
				$(this).parent().parent().removeClass("q3float_left");
				$(this).parent().parent().addClass("q3float_left_full");
			}
			
			if ($(this).parent().parent().hasClass("q3float_right")) {
				$(this).parent().parent().removeClass("q3float_right");
				$(this).parent().parent().addClass("q3float_right_full");
			}
			
		}
		
		
		
		
		
		
		
		// toggle functions
		
		$(this).hide();
		$(this).next("div.zoomout").show();
		
		event.preventDefault();
    });
	
	$("div.ctntimg div.zoomout").mouseover(function(event){	});
	
	$("div.ctntimg div.zoomout").click(function(event){		
		
		
		//remove big image
		$(this).parent().prev("img.bigimg").remove();
		
		//show small image
		$(this).parent().prev("img").show();
		
		if ($(this).parent().parent().hasClass("q1full")) {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().removeClass("q1full");
			$(this).parent().parent().addClass("q1width");
		}
		
		else if ($(this).parent().parent().hasClass("q3full")) {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().removeClass("q3full");
			$(this).parent().parent().addClass("q3width");
			$(this).parent().parent().addClass("q3float");
			
			if ($(this).parent().parent().hasClass("q3float_left_full")) {
				$(this).parent().parent().removeClass("q3float_left_full");
				$(this).parent().parent().addClass("q3float_left");
				$(this).parent().parent().addClass("q3left");
			}
			
			if ($(this).parent().parent().hasClass("q3float_right_full")) {
				$(this).parent().parent().removeClass("q3float_right_full");
				$(this).parent().parent().addClass("q3float_right");
				$(this).parent().parent().addClass("q3right");
			}
			
		}
		
		else {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().addClass("halfwidth");
			
			if ($(this).parent().parent().hasClass("halffloat_left_full")) {
				$(this).parent().parent().removeClass("halffloat_left_full");
				$(this).parent().parent().addClass("halffloat_left");
			}
			
			if ($(this).parent().parent().hasClass("halffloat_right_full")) {
				$(this).parent().parent().removeClass("halffloat_right_full");
				$(this).parent().parent().addClass("halffloat_right");
			}
		}
		
		// toggle functions
		
		$(this).hide();
		$(this).prev("a.zoomin").show();
		
		event.preventDefault();


    });
	
	
});


/* -------------- main_searchlangfix.js ------------------------------------------------------- */

$(document).ready(function() {
	isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	fixlang();
	
	
	$(window).resize(function() {		
			fixlang();
			
	});

	function fixlang(){
		//this cures a resize bug in firefox
		var lw=$(".langmenu").width();
		var np=($(window).width()) - lw - 69;
		
		if (isIE6 == false) {$(".langmenu").css("left", np+"px");}
				
	}

});

/* -------------------------------------------------------------------------------------------- */
