// topnavi
var naviTeaserRelation = "";
function executeNaviTeaserHide(){
  $('#naviTeaser').slideUp('fast');
  naviTeaserRelation = "";
}

// Bildrefektion bei Teasern
$(function($) {
  $("img.reflect").reflect({
    height:0.17,
    opacity:0.33
  });
});

// Teaser-Karusell 
$(function(){
  var carouselLength = $('div.carousel .carousel_item').length;
  if (carouselLength > 4) {
    $("div.carousel").carousel({
      dispItems: 4,
      animSpeed: "slow"
    });
  }
});


$(document).ready(function(){
	
  //tooltip bei bildern imageFlow
  $('#ImageFlow img').cluetip({
    splitTitle: '|',
    width: 160,
    dropShadowSteps: 3,
    positionBy: 'mouse',
    topOffset: 5,
    leftOffset: 5
  });
			   
								
  // metanavi
  $("ul#metatop li:last").css('border-style','none');
  $("#metabottom ul li:last").css('border-style','none')
	
  // teaser events
  $("ul.list li:first").css('border-top-style','none');
  $("ul.list li:last").css('border-bottom-style','none');
	
		
  // fahert sprachen aus/ein
  $('ul#metatop li.lang').mouseenter(function () {
    if ($("ul#lang").is(":hidden")) {
      $("ul#lang").slideDown("normal");
    }
  });
  $('ul#metatop li.lang').mouseleave(function () {
    if ($("ul#lang").is(":visible")) {
      $("ul#lang").slideUp("fast");
    }
  });
		
		
  // topnavi
  $("ul#naviTop li:last").css('background-image','none');
  $('ul#naviTop li').mouseenter(function () {
    $(this).prev().css('background-image','none');
  });
  $('ul#naviTop li').mouseleave(function () {
    $(this).prev().css('background-image','url(img/objects/separator_navi.gif)');
  });





  //Animation der NavigationsTeaser
  $("#naviTop li").children("a[rel='hasTeaser']").bind("mouseenter",function(){
    if(naviTeaserRelation != "")window.clearTimeout(naviTeaserHide);
    if(naviTeaserRelation != $(this).attr("rev")){
      naviTeaserRelation = $(this).attr("rev");
      $("#naviTeaser").slideUp("fast", function(){
        $("#naviTeaser .body").children(".teaser").hide();
        $("#naviTeaser .body").children("."+ naviTeaserRelation).show();
        $("#naviTeaser").slideDown("slow",function(){
          //TODO: Abgerundete Ecken f�r die Teaserbilder sind dank des Sliders bisher nicht m�glich. EVTL Corner Plugin wechseln.
          //$("#naviTeaser .filler .teaser .teaserImage").children(".imageHelper").corner("10px cc:white");
          });
      });
    }
  });
  $("#naviTeaser").bind("mouseenter",function(){
    window.clearTimeout(naviTeaserHide);
  });
  $("#naviTeaser").bind("mouseleave",function(){
    naviTeaserHide = window.setTimeout("executeNaviTeaserHide()", 2000);
  });
  $("#naviTop li").children("a[rel='hasTeaser']").bind("mouseleave",function(){
    naviTeaserHide = window.setTimeout("executeNaviTeaserHide()", 2000);
  });
  
	
  //zielgruppenzugang
  $("#slider a.close, #slider .panel p.open").live('click', function(){
    $("#slider a.opener").hide();
    $("#slider div.content_wrapper").fadeOut('slow');
    $("#slider .panel a").show();
    $("#slider .party_content img").animate({
      left:"0"
    }, 1000 );
  });
  $("#slider a.opener").click(function(){
    $("#slider a.opener").hide();
    $("#slider .panel a").hide();
  });
  $("#slider .panel a, #slider .panel p.closed").live('click', function(){
    $("#slider div.content_wrapper").fadeIn('slow');
  });
	
  // container 1
  $("#first_party p a, #first_party .panel p.closed").live('click', function(){
    $('#first_party .panel p.closed').removeClass('closed').addClass('open');
    $("#first_party").animate({
      width:"761px"
    }, 1000 );
    $("#first_party p a").hide();
    $("#sec_party").animate({
      width:"98px"
    }, 1000 );
    $("#sec_party .panel").hide();
    $("#sec_party a.opener").show();
    $("#sec_party a.opener").removeClass('right');
    $("#sec_party a.opener").addClass('left');
    $("#sec_party img").animate({
      left:"-180px"
    }, 1000 );
    $("#third_party").animate({
      width:"98px"
    }, 1000 );
    $("#third_party .panel").hide();
    $("#third_party a.opener").show();
    $("#third_party img").animate({
      left:"-130px"
    }, 1000 );
  });
  $("#first_party a.close, #first_party .panel p.open").live('click', function(){
    $('#first_party .panel p.open').removeClass('open').addClass('closed');
    $("#first_party").animate({
      width:"319px"
    }, 1000 );
    $("#first_party p a").show();
    $("#sec_party").animate({
      width:"319px"
    }, 1000 );
    $("#sec_party .panel").show();
    $("#third_party").animate({
      width:"319px"
    }, 1000 );
    $("#third_party .panel").show();
  });
  $("#first_party a.opener").click(function(){
    $("#first_party").animate({
      width:"761px"
    }, 1000 );
    $("#first_party .panel").show();
    $("#first_party .party_content img").animate({
      left:"0"
    }, 1000 );
    $("#first_party div.content_wrapper").fadeIn('slow');
    $("#sec_party").animate({
      width:"98px"
    }, 1000 );
    $("#sec_party .panel").hide();
    $("#sec_party a.opener").show();
    $("#sec_party a.opener").removeClass('right');
    $("#sec_party a.opener").addClass('left');
    $("#sec_party img").animate({
      left:"-180px"
    }, 1000 );
    $("#sec_party div.content_wrapper").fadeOut('fast');
    $("#third_party").animate({
      width:"98px"
    }, 1000 );
    $("#third_party .panel").hide();
    $("#third_party a.opener").show();
    $("#third_party img").animate({
      left:"-130px"
    }, 1000 );
    $("#third_party div.content_wrapper").fadeOut('fast');
  });
	
  // container 2
  $("#sec_party p a, #sec_party .panel p.closed").live('click', function(){
    $('#sec_party .panel p.closed').removeClass('closed').addClass('open');
    $("#first_party").animate({
      width:"98px"
    }, 1000 );
    $("#first_party .panel").hide();
    $("#first_party a.opener").show();
    $("#first_party img").animate({
      left:"-120px"
    }, 1000 );
    $("#sec_party").animate({
      width:"761px"
    }, 1000 );
    $("#sec_party p a").hide();
    $("#third_party").animate({
      width:"98px"
    }, 1000 );
    $("#third_party .panel").hide();
    $("#third_party a.opener").show();
    $("#third_party img").animate({
      left:"-130px"
    }, 1000 );
  });
  $("#sec_party a.close, #sec_party .panel p.open").live('click', function(){
    $('#sec_party .panel p.open').removeClass('open').addClass('closed');
    $("#first_party").animate({
      width:"319px"
    }, 1000 );
    $("#first_party .panel").show();
    $("#sec_party").animate({
      width:"319px"
    }, 1000 );
    $("#sec_party p a").show();
    $("#third_party").animate({
      width:"319px"
    }, 1000 );
    $("#third_party .panel").show();
  });
  $("#sec_party a.opener").click(function(){
    $("#first_party").animate({
      width:"98px"
    }, 1000 );
    $("#first_party .panel").hide();
    $("#first_party a.opener").show();
    $("#first_party img").animate({
      left:"-120px"
    }, 1000 );
    $("#first_party div.content_wrapper").fadeOut('fast');
    $("#sec_party").animate({
      width:"761px"
    }, 1000 );
    $("#sec_party .panel").show();
    $("#sec_party .party_content img").animate({
      left:"0"
    }, 1000 );
    $("#sec_party div.content_wrapper").fadeIn('slow');
    $("#third_party").animate({
      width:"98px"
    }, 1000 );
    $("#third_party .panel").hide();
    $("#third_party a.opener").show();
    $("#third_party img").animate({
      left:"-130px"
    }, 1000 );
    $("#third_party div.content_wrapper").fadeOut('fast');
  });
	
  // container 3
  $("#third_party p a, #third_party .panel p.closed").live('click', function(){
    $('#third_party .panel p.closed').removeClass('closed').addClass('open');
    $("#first_party").animate({
      width:"98px"
    }, 1000 );
    $("#first_party .panel").hide();
    $("#first_party a.opener").show();
    $("#first_party img").animate({
      left:"-120px"
    }, 1000 );
    $("#sec_party").animate({
      width:"98px"
    }, 1000 );
    $("#sec_party .panel").hide();
    $("#sec_party a.opener").show();
    $("#sec_party a.opener").removeClass('left');
    $("#sec_party a.opener").addClass('right');
    $("#sec_party img").animate({
      left:"-180px"
    }, 1000 );
    $("#third_party").animate({
      width:"761px"
    }, 1000 );
    $("#third_party p a").hide();
  });
  $("#third_party a.close, #third_party .panel p.open").live('click', function(){
    $('#third_party .panel p.open').removeClass('open').addClass('closed');
    $("#first_party").animate({
      width:"319px"
    }, 1000 );
    $("#first_party .panel").show();
    $("#sec_party").animate({
      width:"319px"
    }, 1000 );
    $("#sec_party .panel").show();
    $("#third_party").animate({
      width:"319px"
    }, 1000 );
    $("#sec_party p a").show();
  });
  $("#third_party a.opener").click(function(){
    $("#first_party").animate({
      width:"98px"
    }, 1000 );
    $("#first_party .panel").hide();
    $("#first_party a.opener").show();
    $("#first_party img").animate({
      left:"-120px"
    }, 1000 );
    $("#first_party div.content_wrapper").fadeOut('fast');
    $("#sec_party").animate({
      width:"98px"
    }, 1000 );
    $("#sec_party .panel").hide();
    $("#sec_party a.opener").show();
    $("#sec_party a.opener").removeClass('left');
    $("#sec_party a.opener").addClass('right');
    $("#sec_party img").animate({
      left:"-180px"
    }, 1000 );
    $("#sec_party div.content_wrapper").fadeOut('fast');
    $("#third_party").animate({
      width:"761px"
    }, 1000 );
    $("#third_party .panel").show();
    $("#third_party .party_content img").animate({
      left:"0"
    }, 1000 );
    $("#third_party div.content_wrapper").fadeIn('slow');
  });
	
	
	

	
  /* listeneintraege bei zielgruppen ausfahren */
  $("div.list_item").mouseenter(function(){
    $(this).parent().children('div:first').removeClass('expand').addClass('default');
    $(this).removeClass("default").addClass("expand");
  });
  $("div.list_item").mouseleave(function(){
    $(this).removeClass("expand").addClass("default");
  });
  $("div.content_list").mouseleave(function(){
    $("div:first",this).removeClass("default").addClass("expand");
  });
	

  $("#main_teaser .teaser:first").css('margin-right','0px');
	
	
  // service-teaser
  $("#service div.service-teaser:last").css('margin-right','0px')
	
	
  //$("#service div.service-teaser .low").toggle(
  //  function () {
  //    $(this).parent().children('div:last').animate(  { top:"152px" }, 500  );
  //  },
  // function () {
  //    $(this).parent().children('div:last').animate(  { top:"335px" }, 500  );
  //  }
  //);
	
	
  //$("#service div.service-teaser .high").toggle(
  // function () {
  //    $(this).parent().children('div:last').animate(  { top:"0" }, 500  );
  //  },
  //  function () {
  //    $(this).parent().children('div:last').animate(  { top:"335px" }, 500  );
  //  }
  //);

  var openedTeasers = new Object();
  openedTeasers['facebook'] = 0;
  openedTeasers['twitter'] = 0;
  openedTeasers['flickr'] = 0;
  openedTeasers['news'] = 0;

  // oeffnet service-teaser
  $("#service div.service-teaser .low").click(function() {
    var that = $(this).parent().children('div:last');
    var className = $(this).children('h3').attr('class');

    if (openedTeasers[className] == 0) {
      that.animate({
        top: '192px'
      }, 500);
      openedTeasers[className] = 1;
    } else {
      that.animate({
        top: '435px'
      }, 500);
      openedTeasers[className] = 0;
    }
  });
  $("#service div.service-teaser .high").click(function() {
    var that = $(this).parent().children('div:last');
    var className = $(this).children('h3').attr('class');

    if (openedTeasers[className] == 0) {
      that.animate({
        top: '0'
      }, 500);
      if (className == 'twitter' || className == 'news') {
        $('#tagcloud').fadeOut();
      }
      openedTeasers[className] = 1;
    } else {
      that.animate({
        top: '435px'
      }, 500);
      openedTeasers[className] = 0;

      if (className == 'twitter' || className == 'news') {
        if (openedTeasers['twitter'] == 0 && openedTeasers['news'] == 0) {
          $('#tagcloud').fadeIn();
        }
      }
    }
  });
  // schliesst service-teaser
  $("#service div.service-teaser div.content a.close").click(function() {
    var that = $(this).parent();
    var className = that.attr('id');

    that.animate({
      top: '435px'
    }, 500);
    openedTeasers[className] = 0;

    if (className == 'twitter' || className == 'news') {
      if (openedTeasers['twitter'] == 0 && openedTeasers['news'] == 0) {
        $('#tagcloud').fadeIn();
      }
    }
  });



  // bildergalerie
  $("a.html").colorbox({
    transition:"elastic",
    width:"560px",
    height:"605px"
  });

		

	
});