// jQuery Cookie Plugin
// http://plugins.jquery.com/project/cookie

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//Sound Controls
var currentPlayer = false;
var mutePlayer = false;
function soundOff(){
  if(currentPlayer != false && currentPlayer != undefined){
    if (typeof(currentPlayer.sendEvent) == 'function'){
      currentPlayer.sendEvent('MUTE', true);
    }
  }
  mutePlayer = true;
  $.cookie("muteSlideShow", "1", { path: '/', expires: 730 });
}

function soundOn(){
  if(currentPlayer != false && currentPlayer != undefined){
    if (typeof(currentPlayer.sendEvent) == 'function') {
      currentPlayer.sendEvent('MUTE', false);
    }
  }
  mutePlayer = false;
  $.cookie("muteSlideShow", "0", { path: '/', expires: 730 });
}

// Framerate Anpassung
function now() {
    return (new Date).getTime();
}
jQuery.fx.prototype.custom = function( from, to, unit ) {
    this.startTime = now();
    this.start = from;
    this.end = to;
    this.unit = unit || this.unit || "px";
    this.now = this.start;
    this.pos = this.state = 0;

    var self = this;
    function t( gotoEnd ) {
        return self.step(gotoEnd);
    }

    t.elem = this.elem;

    if ( t() && jQuery.timers.push(t) && !jQuery.fx.prototype.timerId ) {
        //timerId = setInterval(jQuery.fx.tick, 13);
        jQuery.fx.prototype.timerId = setInterval(jQuery.fx.tick, 50);
    }
}






// Start Teaser ger
function startTeaserSlideShow(){
	if(jQuery.isFunction($('#teaser div.tabs_slideshow_panes').tabs().play)){
  		$('#teaser div.tabs_slideshow_panes').tabs().play();
	}
}



jQuery(function( $ ){
// Freunde Formular Seite --------------------------------------------------------------------------
// eingabe feld f�r den partner bei der doppelmitgliedschaf eine und ausblenden


$().ready(function(){

	if(($("#sound_controls").length == 0) && ($(".tabs_slideshow_panes").length > 0)){
	  $("#topnav ul").prepend("<li id='sound_controls'><span class='on'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class='off' style='display: none'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li>");

	  if($.cookie("muteSlideShow")!=null && $.cookie("muteSlideShow") == 1){
	    soundOff();
  	  $("#sound_controls span.on").hide();
  	  $("#sound_controls span.off").show();
	  }
	  if($.cookie("muteSlideShow")==null){
	    soundOn();
	  }
  }

	$("#sound_controls span.on").hover(
	  function(){
	    $(this).addClass("on-hover");
	  },
	  function(){
	    $(this).removeClass("on-hover");
	  }
	  );

	$("#sound_controls span.off").hover(
    function(){
      $(this).addClass("off-hover");
    },
    function(){
      $(this).removeClass("off-hover");
    }
   );
 	$("#sound_controls span.off, #sound_controls span.off-hover").live("click", function(){
 	  soundOn();
 	  $(this).hide();
 	  $("#sound_controls span.on").show();
 	});

 	$("#sound_controls span.on, #sound_controls span.on-hover").live("click", function(){
 	  soundOff();
 	  $(this).hide();
 	  $("#sound_controls span.off").show();
 	});

	if ($.browser.msie) {
		$("#navmenu-h li").hover(
			function() { $(this).addClass("iehover"); },
			function() { $(this).removeClass("iehover");
		});
	}

	/**
	 * F�gt einen Zeilenumbruch in Men�eintr�ge mit mehr als 20
	 * Zeichen ein, sofern es ein Leerzeichen gibt
	 */
	$('ul.vertical li').each(function(index, item) {
		var text = $(item).children('a').children('span').html();
		var seperate = false;
		var part = '';
		var j = 0;
		if (text.length >= 20) {
			for (i = 0; i < text.length; i++) {
				j++;
				part += text.charAt(i);
				if (j >= 10) {
					seperate = true;
					j = 0;
				}
				if (text.charAt(i) == ' ' && seperate) {
					part += '<br />';
					seperate = false;
				}
			}
			$(item).children('a').children('span').html(part);
		}
	});

	$(document).mouseup(function(e){
			if ($(e.target).parent("a.signin").length == 0) {
					$(".signin").removeClass("menu-open");
					$("div#signin_menu").hide();
			}
	});
});

var hoverIntentSettings = {
	sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
	interval: 200, // number = milliseconds for onMouseOver polling interval
	timeout: 500,
	over: function() {
		$(this).children(".vertical").slideDown("slow");
	},
	out: function() {
		$(this).children(".vertical").slideUp("fast");
	}
}

//Setting up main menu effects
$(".navmenu-item").hoverIntent(hoverIntentSettings);

$(".navmenu-item").each(function(index, item) {
	var linktext = $(item).children('a').html();
	linktext = $(linktext).addClass('shadow');
	$(item).children('a').children('span').after(linktext);
});
$("#submenu li").each(function(index, item) {
	var linktext = $(item).children('a').html();
	linktext = $(linktext).addClass('shadow');
	if (linktext) {
		$(item).children('a').children('span').after(linktext);
	} else {
		linktext = $(item).children('strong').html();
		linktext = $(linktext).addClass('shadow');
		$(item).children('strong').children('span').after(linktext);
	}
});

$("#login .login_zubehoer").children('a').children('span').after('<span class="shadow">'+$("#login .login_zubehoer").children('a').html()+'</span>');
$("#login .login_kunden").children('a').children('span').after('<span class="shadow">'+$("#login .login_kunden").children('a').html()+'</span>');

	// only init the tt_news timeselector js, if the element is present
if ($('.timeselectors').length > 0) {
	newsArchive.init();
}

if ($('div.newsletter_reg').length > 0) {
	$('div.newsletter_reg_bg div.newsletter_reg_input').each(function(index, item) {
		if ($(item).children('p.newsletter_error_txt').length > 0) {
			$(item).children('input').addClass('error');
			$(item).removeClass('newsletter_reg_input');
			$(item).addClass('newsletter_reg_input_error');
		}
	});
	if ($('div.newsletter_reg_bg').children('div.newsletter_error_line').length > 0) {
		$('#newsletter_reg_einverstanden_error').addClass('error_datenschutz');
	}
}

	// initialisieren der hover-Fenster auf der Imagemap (Niederlassungen)
if ($('.alloverlayitems').length > 0) {
	//$('#col2_content_3col .floatbox').css('overflow', 'visible');

	var mapAreas = $('.overlayarea');
	var overlays = $('.alloverlayitems').children('div');
	var overlayItems = new Array();
	var menuElements = $('#niederlassungen_menu ul li a');
	var menuItems = new Array();

		// Overlay-Elemente vorbereiten und in Array anordnen
	$(overlays).each(function(index, item) {
		var id = $(item).attr('id');
		var getme = false;
		var idNum = '';
		for (i=0; i < id.length; i++) {
			if (getme) {
				idNum += id[i];
			}
			if (id[i] == '-') {
				getme = true;
			}
		}
		getme = false;
		overlayItems[idNum] = item;
	});

		// Men�-Elemente vorbereiten und in Array anordnen
	$(menuElements).each(function(index, item) {
		var id = $(item).attr('id');
		var getme = false;
		var idNum = '';
		for (i=0; i < id.length; i++) {
			if (getme) {
				idNum += id[i];
			}
			if (id[i] == '-') {
				getme = true;
			}
		}
		getme = false;
		menuItems[idNum] = item;
	});

	$(mapAreas).each(function(index, item) {
		var id = $(item).attr('id');
		var getme = false;
		var idNum = '';
		for (i=0; i < id.length; i++) {
			if (getme) {
				idNum += id[i];
			}
			if (id[i] == '-') {
				getme = true;
			}
		}

		$('.page').css('position', 'relative');
		$('.page').append('<div id="overlayLayer"></div>');

		var col1W = $('#col1_3col').css('width');
		col1W = parseInt(col1W.substr(0, col1W.length-2));

		$('#overlayLayer').css('position', 'absolute');
		$('#overlayLayer').css('top', '145px');
		$('#overlayLayer').css('left', parseInt(col1W+10)+'px');
		$('#overlayLayer').css('width', $('#col2_3col').css('width'));
		$('#overlayLayer').css('height', $('#col2_3col').css('height'));

		$(item).mouseenter(function() {
				// Falls vorhanden, andere overlays entfernen
			$('div.overlay_window').detach();
			$('#niederlassungen_imagemap_map').children().children().children('img').css('display', 'none');
				// Hover-Hintergrund einblenden
			$(item).children('a').children('img').css('display', 'inline');
				// Overlay-Fenster erzeugen und einblenden
			var overlayWindow = $(overlayItems[idNum]).clone(true).appendTo('#overlayLayer');
			var winH = $(overlayWindow).css('height');
			var winW = $(overlayWindow).css('width');
			var top = $('#item-'+idNum).children('a').css('top');
			var left = $('#item-'+idNum).children('a').css('left');

			winH = parseInt(winH.substr(0, winH.length-2));
			top = parseInt(top.substr(0, top.length-2));

			winW = parseInt(winW.substr(0, winW.length-2));
			left = parseInt(left.substr(0, left.length-2));

			var leftPos = parseInt(left-winW+40);
			var topPos = top-winH+40;

			$(overlayWindow).removeClass('niederlassungen_team_overlay');
			$(overlayWindow).addClass('overlay_window');
			$(overlayWindow).css('left', leftPos+'px');
			$(overlayWindow).css('top', topPos+'px');
			$(overlayWindow).css('z-index', '5');
			$(overlayWindow).css('display', 'block');
			$(overlayWindow).css('position', 'absolute');
				// mouseleave-Event registrieren
			$(overlayWindow).mouseleave(function() {
				$('#item-'+idNum).children('a').children('img').css('display', 'none');
				$('div.overlay_window').detach();
			});
		});

		$(menuItems[idNum]).mouseenter(function() {
				// Falls vorhanden, andere overlays entfernen
			$('div.overlay_window').detach();
			$('#niederlassungen_imagemap_map').children().children().children('img').css('display', 'none');
				// Hover-Hintergrund einblenden
			$(item).children('a').children('img').css('display', 'inline');
				// Overlay-Fenster erzeugen und einblenden
			var overlayWindow = $(overlayItems[idNum]).clone(true).appendTo('#overlayLayer');
			var winH = $(overlayWindow).css('height');
			var winW = $(overlayWindow).css('width');
			var top = $('#item-'+idNum).children('a').css('top');
			var left = $('#item-'+idNum).children('a').css('left');

			winH = parseInt(winH.substr(0, winH.length-2));
			top = parseInt(top.substr(0, top.length-2));

			winW = parseInt(winW.substr(0, winW.length-2));
			left = parseInt(left.substr(0, left.length-2));

			var leftPos = parseInt(left-winW+40);
			var topPos = top-winH+40;

			$(overlayWindow).removeClass('niederlassungen_team_overlay');
			$(overlayWindow).addClass('overlay_window');
			$(overlayWindow).css('left', leftPos+'px');
			$(overlayWindow).css('top', topPos+'px');
			$(overlayWindow).css('z-index', '5');
			$(overlayWindow).css('display', 'block');
			$(overlayWindow).css('position', 'absolute');
				// mouseleave-Event registrieren
			$(overlayWindow).mouseleave(function() {
				$('#item-'+idNum).children('a').children('img').css('display', 'none');
				$('div.overlay_window').detach();
			});
		});
	});
}

$('.friends-form div.partner').hide(); // eingabefeld ausblenden


$("ul.colored_tabs li a").each(function(index, element) {
	$(element).addClass("tabNum"+index);
});
$("div.colored_tabs_panes > div").each(function(index, element) {
	$(element).addClass("tabNum"+index);
});
$("ul.colored_tabs").tabs("div.colored_tabs_panes > div", {
});


$("ul.tabs").tabs("div.panes > div.floatbox", {
});


$("div.news-latest-container div.scrollable").scrollable({
	easing: "swing",
	speed: 1000,
	size: 1
}).circular().navigator(".navi").autoscroll({
	autoplay: true,
	interval: 6000
});


$("div#teaser div.tabs_slideshow_panes").each(function(elementIndex, element){
	var panes = $(element).children();
	var maxH = 0;
	$(panes).each(function(index, item) {
		var header = $(item).children(":header").first();
		var target = $(header).children("a").attr("href");
		var kids = $(item).children('div.tx-flvplayer2-pi1');

		if (kids[0]) {
			var player = $(kids[0]).children('embed')[0];
			if ((typeof player == 'undefined') || $.browser.msie) {
				var player = $(kids[0]).children('object')[0];
			}
		}
		//$(player).before();

    $(panes[index]).find("img").wrap('<a class="teaserOverlayLink" href="'+target+'"></a>');
    $(panes[index]).find(".tx-flvplayer2-pi1").append('<a class="teaserOverlayLink" href="'+target+'">&nbsp;</a>');

		if ($(item).height() > maxH) {
			maxH = $(item).height();
		}
	});
	$(element).css('height', maxH+'px');
});


var teaserPlayer = new Array();

// wait added so the first flash player has enough time to initialize properly
wait(350);


$("#teaser div.tabs_slideshow_panes").tabs("div.tabs_slideshow_panes > div", {
	effect: "fade",
	fadeOutSpeed: 1500,
	fadeInSpeed: 1500,
	rotate: true,
	tabs: '> div',
	onClick: function(event, itemIndex) {

		var items = this.getTabs();

		var kids = $(items[itemIndex]).children('div.tx-flvplayer2-pi1');

		if (kids[0]) {

			var player = $(kids[0]).children('embed')[0];

			if ((typeof player == 'undefined') || $.browser.msie) {
				var player = $(kids[0]).children('object')[0];
			}

      currentPlayer = player;

			if ($(player).hasClass('player_ready')) {
			  wait(250);
			  $('#teaser div.tabs_slideshow_panes').tabs().stop();

			  if(teaserPlayer[itemIndex] == undefined){
				  teaserPlayer[itemIndex] = true;
				  player.addModelListener("STATE", "stateListener");
			  }
			  player.sendEvent('PLAY', 'true');

			}
		}
		if(itemIndex == ($("#teaser div.tabs_slideshow_panes > div").length-1)){
		  $('#teaser div.tabs_slideshow_panes').tabs().stop();
		  //$("#teaser div.tabs_slideshow_panes > div:last").append('<a class="repeat" style="position:absolute;bottom:0px;right:0px;color:red;padding:1em;z-index:20005" href="#" onclick="self.location=self.location;">Nochmal spielen!</a>');
		  setTimeout(function(){window.location.href = location.href}, 5000);

		}

	}
}).slideshow({
	autoplay: false,
	clickable: true,
	interval: 5000,
	autopause: false
});

setTimeout("startTeaserSlideShow()", 5000);


$("#col3 div.tabs_slideshow_panes").tabs("div.tabs_slideshow_panes > div.floatbox_ohne_padding", {
	effect: "fade",
	fadeOutSpeed: 1500,
	fadeInSpeed: 1500,
	rotate: true,
	tabs: "> div.floatbox_ohne_padding"

});/*.slideshow({
	interval: 5000,
	autoplay: true
});*/



// a.teaserOverlayLink should execute the link
$("#teaser div.tabs_slideshow_panes a.teaserOverlayLink").click(function(){
		var target = $(this).attr("href");
		var check = target.search(/^http.*/);
		if(check == -1){
			window.location.href = '/' + target;
		} else {
			window.location.href = target;
		}
})

// Test: issuu-Plugin flash-player overlay?
if ($('.tx-ipissuu-pi1').length > 0) {
	var issuus = $('.tx-ipissuu-pi1');
	$(issuus).each(function(index, item) {
		var height = $(item).css('height');
		var width = $(item).css('width');
		$(item).append('<a href="#" class="issuuOverlayLink">&nbsp;</a>');
	});
}
(function($) {
  //
  // plugin definition
  //
  $.fn.dkdslideshow = function(options) {

    // build main options before element iteration
    var opts = $.extend({}, $.fn.dkdslideshow.defaults, options);
    // iterate and reformat each matched element

    //number of children
    var numberOfSlides = $(this).find(opts.children).length;

    //slides
    var slides = $(this).find(opts.children);

    //current slide
    var currentSlide = 0;

    //
    var isRunning = false;

    //Initialize this
    var $this = this;

    this.play = function(){

                  var slide = slides[currentSlide];
                  var nextSlide = (currentSlide == (numberOfSlides-1))? 0 : (currentSlide+1);

                  slides.eq(currentSlide).slideUp(300, function(){
                                                   slides.eq(nextSlide).slideDown(300);
                                                  }
                                                );
                  currentSlide = nextSlide;

    };

    this.stop = function(){
       if($this.isRunning == true){
         clearInterval(activeInterval);
         $this.isRunning = false;
         slides.eq(currentSlide).stop(true,true).show().css("opacity", 1.0);
       }
    };

    // onMouseOver
    this.mouseover(function(){
        //$this.stop();
        //debug("stopping");

    });
    // onMouseOut
    this.mouseout(function(){
      if($this.isRunning == false){
        //var activeInterval = window.setInterval($this.play, 5000);
        //$this.isRunning = true;
        //debug("playing");
      }
    });

    //starting the slideshow
    if(numberOfSlides > 1){
      var activeInterval = window.setInterval(this.play, 5000);
      $this.isRunning = true;
    }

  }


  function debug($obj) {
    if (window.console && window.console.debug)
      window.console.debug($obj);
  };


  //
  // plugin defaults
  //
  $.fn.dkdslideshow.defaults = {
    interval: 5000,
    autoplay: true,
    stopOnMouseOver: true,
    isRunning: false,
    children: ' > div.floatbox_ohne_padding',
    effect: 'fade'
  };
//
// end of closure
//
})(jQuery);
$("#col3 div.tabs_slideshow_panes").dkdslideshow();

$("#col3 div.tabs_slideshow_panes a").click(function(){
  window.location.href = 'http://' + window.location.host + '/' + $(this).attr("href");
})


	// only apply lightbox, if tt_news single item is present
if ($('.news-single-item').length > 0) {
	$("div.news-single-img a").lightBox({
		imageBtnPrev: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-prev.png",
		imageBtnNext: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-next.png",
		imageBtnClose: "fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-close.png",
		cornerEffect: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox_corner_image.png",
		imageLoading: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-ico-loading.gif"
	});
}
	// or, if a.lightbox is present
if ($('a.lightbox').length > 0) {
	$('a.lightbox').lightBox({
		imageBtnPrev: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-prev.png",
		imageBtnNext: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-next.png",
		imageBtnClose: "fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-btn-close.png",
		cornerEffect: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox_corner_image.png",
		imageLoading: "../../../../../../fileadmin/templates/lauerfischer/images/schaltflaechen/lightbox-ico-loading.gif",
		displayData: false
	});
}

	// bei der auswahl (klick auf input oder das label) einblenden
$('div .doppelmitgliedschaft label').click(
	function () {
	$('div.partner').slideDown('5000');
	$('div.partner ul').show();
	$('div.partner ul li').show();
	$('div.partner input').show();
});

$('div .doppelmitgliedschaft input').click(
	function () {
		$('div.partner').slideDown('5000');
	});

	// bei der auswahl  (klick auf input oder das label) einer andere mitgliedschaft wieder ausblenden
	$('div .select div:not(.doppelmitgliedschaft) label').click(
		function () {
		$('div.partner').slideUp('slow');
	});

	$('div .select div:not(.doppelmitgliedschaft) input').click(
		function () {
		$('div.partner').slideUp('slow');
	});

// bei der firmenmitgliedschaft die einmalige spendenoption ausblenden
	$('div .firmen-mitgliedschaft').click(function(){
		$('div.donation div.einmalig').animate({
			width: 'hide',
			opacity: 'hide'
		}, 700 );
		$('div.donation div.jaehrlich input').hide('slow');
	});

// bei der fAsrdernden mitgliedschaft die einmalige spendenoption ausblenden
	$('div .foerdernde-mitgliedschaft').click(function(){
		$('div.donation div.einmalig').animate({
			width: 'hide',
			opacity: 'hide'
		}, 700 );
		$('div.donation div.jaehrlich input').hide();
	});


// wieder einblenden
	 $('div .persoenliche-mitgliedschaft').click(function(){
			$('div.donation div.einmalig').animate({
				width: 'show',
				opacity: 'show'
				}, 500 );
		$('div.donation div.jaehrlich input.radio').show();
		});

// wieder einblenden
	 $('div .studentenmitgliedschaft input').click(function(){
			$('div.donation div.einmalig').animate({
				width: 'show',
				opacity: 'show'
				}, 500 );
		$('div.donation div.jaehrlich input.radio').show();
		});

// wieder einblenden
	 $('div .doppelmitgliedschaft input').click(function(){
			$('div.donation div.einmalig').animate({
				width: 'show',
				opacity: 'show'
				}, 500 );
		$('div.donation div.jaehrlich input.radio').show();

		});

// Mitarbeiter Vita  --------------------------------------------------------------------------
$('#content.staff div div').hide(); // vita ausblenden

$("#content.staff div span.vita").click(
	function () {
		$('#content div div:visible').slideUp('slow'); // offene vita schlieA?en, wenn diese sichtbar ist
		$(this).next('div:hidden').slideDown('slow'); // die ausgewA�hlte vita Asffnen, wenn diese hidden ist
	},
	function () {}
);


// --------------------------------------------------------------------------
// Allgemeine Funktionen
// --------------------------------------------------------------------------

/**
 * @author grigoriprokhorov
 */
//$.maxZIndex = $.fn.maxZIndex = function(opt) {
$.maxZIndex = function(opt) {
		 /// <summary>
		 /// Returns the max zOrder in the document (no parameter)
		 /// Sets max zOrder by passing a non-zero number
		 /// which gets added to the highest zOrder.
		 /// </summary>
		 /// <param name="opt" type="object">
		 /// inc: increment value,
		 /// group: selector for zIndex elements to find max for
		 /// </param>
		 /// <returns type="jQuery" />
		 var def = { inc: 10, group: "*" };
		 $.extend(def, opt);
		 var zmax = 0;
		 $(def.group).each(function() {
				 var cur = parseInt($(this).css('z-index'));
				 zmax = cur > zmax ? cur : zmax;
		 });
		 if (!this.jquery)
				 return zmax;

		 return this.each(function() {
				 zmax += def.inc;
				 $(this).css("z-index", zmax);
		 });
}
// Exterene Links  --------------------------------------------------------------------------
// Funktion fAzr externe Link / links die in neuen Fenster Asffnen sollen z.B. PDFs - klasse (target) .blank

	$("a.blank").click(
			function () {
			window.open(this.href);
		 return false;
		});


// IE 6 Hintergrund Bilder  --------------------------------------------------------------------------
	// Skript gegen hintergrund bild cache problem beim IE6
	 if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6)
		{
				try
				{
						document.execCommand("BackgroundImageCache", false, true);
				}
				catch (err)
				{
				}
		}

//Teaser noFlash fallback
if(jQuery("#teaser div.tabs_slideshow_panes").length > 0){
  if (!DetectFlashVer(10, 0, 0)){
    wait(300);
    jQuery("#teaser div.tabs_slideshow_panes").tabs().stop();
    setTimeout("playFallbackTeaser()", 5000);
  }
}

// --------------------------------------------------------------------------
//
});

function playFallbackTeaser(){
  jQuery("#teaser div.tabs_slideshow_panes").tabs().play()
}

function createGETArray() {
	HTTP_GET_VARS = new Array();
	strGET = document.location.search.substr(1, document.location.search.length);
	if (strGET != '') {
		gArr = strGET.split('&');
		for (i = 0; i < gArr.length; ++i) {
			v = '';
			vArr = gArr[i].split('=');
			if (vArr.length > 1) {
				v = vArr[1];
			}
			HTTP_GET_VARS[unescape(vArr[0])] = unescape(v);
		}
	}

	return HTTP_GET_VARS;
}

var HTTP_GET_VARS = createGETArray();

function GET(v) {
	if (!HTTP_GET_VARS[v]) {
		return 'undefined';
	}
	return HTTP_GET_VARS[v];
}

function wait(time) {
	var startTime = new Date();
	var start = startTime.getTime();
	var currentTime = new Date();
	while (currentTime.getTime() < start+time) {
		delete currentTime;
		var currentTime = new Date();
	}
	return true;
}

// Callback-Funktionen Beginn

function stateListener(event) {
	//console.log(event.newstate);
	if (event.newstate == 'COMPLETED') {
		wait(500);
		$('#teaser div.tabs_slideshow_panes').tabs().play();

	}

}



// Callback-Funktionen Ende

/**
 * This function is called by each flvplayer, after being completely
 * loaded
 *
 * @param obj
 * @return void
 */
function playerReady(obj) {
	var players = $('.tx-flvplayer2-pi1');
	players.each(function(elementIndex, element) {
			// check, if the player is part of a scrollable element
		if ($(element).parent().parent().hasClass('tabs_slideshow_panes')) {
			var player = $(element).children('embed')[0];
			if (typeof player == 'undefined') {
				var player = $(element).children('object')[0];
			}
			$(player).addClass('player_ready');
		}
	});
}

//Checkbox Bilder bei den service->aufstiegsangebote
$(document).ready(function(){
	if ($(".input_checkbox_bg").length) {
		$(".checkbox_bg > .active").attr('checked', true);
		$(".checkbox_bg > .active").parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_red_active.png") no-repeat scroll 0 0 transparent');
	}

	$('.submit_upgrade_formular_lang').click ( function () {
	    if ($(".checkbox_bg > .active").length) {
	        $('p.infotext').removeClass('nopackageerror');
	        return true;
	    }

	    $('p.infotext').addClass('nopackageerror');
	    return false;
	});

	$(".input_checkbox_bg").click(function(){
		//var currentCheckedBox = $(".input_checkbox_bg:checked").attr('id');

		if (!$(this).hasClass('active')) {
			$(".input_checkbox_bg:checked").each(function (index, element) {
				$(this).attr('checked', false);
				$(this).removeClass('active');
				$(this).parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_red.png") no-repeat scroll 0 0 transparent');
			});

			$(this).attr('checked', true);
			$(this).addClass('active');
			$(this).parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_red_active.png") no-repeat scroll 0 0 transparent');
		} else {
			$(this).attr('checked', false);
			$(this).removeClass('active');
			$(this).parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_red.png") no-repeat scroll 0 0 transparent');
		}
/*
		if(!$(this).is(':checked')){
			$(this).parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_normal.png") no-repeat scroll 10px 14px transparent');
		}else {
			$(this).parent().css('background','url("/fileadmin/templates/lauerfischer/images/checkbox_active.png") no-repeat scroll 10px 14px transparent');
		}
*/


	});

	$(".colorBoxiframe").colorbox({
		width:"570px",
		height:"800px",
		scrolling:false,
		iframe:true,
		arrowKey:false,
		close: " "
		});

	function checkKundNr() {
		var kundenNr = '34b7';
		var kundenNrContainer = $(".upgrade_code").attr('value');
		if(kundenNrContainer == kundenNr){
		    $("div.upgrade_kundenNr").css("display","block");
		    //$(".upgrade_image_danke").attr("src","fileadmin/templates/lauerfischer/images/lf_danke_best.png")
		}
	}
	checkKundNr();

});


