/* Optionen fuer Highslide */
hs.graphicsDir = '/de/wGlobal/layout/styles/graphics/';
hs.numberOfImagesToPreload = 0;
hs.showCredits = false;
hs.preserveContent = false;
hs.align = 'center';
hs.allowMultipleInstances = false;
hs.fadeInOut = true;
hs.dimmingOpacity = 0.5;

/* Film in Highslide */
function show_movie(me) {
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: 'Die FAIRRANK group',
    width: 515,
    height: 350
  });
}

/* Anfrage in Highslide (breit) */
function show_request(me) {
  var temp = 'Angebot anfordern';
  if (me.title != '') temp = me.title;
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: temp,
    width: 440,
    height: 705,
    allowHeightReduction: false,
    allowWidthReduction: false
  });
  /* 780,615 = Werte für breite Version, ersetzt durch 2011 Version */
}

/* Anfrage in Highslide (schmal) */
function show_request2(me) {
  var temp = 'Anfrageformular';
  if (me.title != '') temp = me.title;
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: temp,
    width: 440,
    height: 705,
    allowHeightReduction: false,
    allowWidthReduction: false
  });
  /* 335,705 = Werte für schmale Version, ersetzt durch 2011 Version */
}

function show_request3(me) {
  var temp = 'Anfrageformular';
  if (me.title != '') temp = me.title;
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: temp,
    width: 440,
    height: 705,
    allowHeightReduction: false,
    allowWidthReduction: false
  });
}

/* Anfrage in Highslide (schmal) */
function show_request4(me) {
  var temp = 'Anfrageformular';
  if (me.title != '') temp = me.title;
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: temp,
    width: 335,
    height: 705,
    allowHeightReduction: false,
    allowWidthReduction: false
  });
}

/* Webinar in Highslide (inaktiv) */
/*
function show_webinar(me) {
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: 'Webinar-Anmeldung',
    width: 335,
    height: 505,
    allowHeightReduction: false,
    allowWidthReduction: false
  });
}
*/

/* Callback in Highslide (inaktiv) */
/*
function show_callback(me) {
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: 'Call-Back-Service',
    width: 450,
    height: 500
  });
}
*/

/* Tippspiel in Highslide (inaktiv) */
/*
function show_tippspiel(me) {
  return hs.htmlExpand(me, {
    wrapperClassName: 'draggable-header',
    objectType: 'iframe',
    outlineType: 'rounded-white',
    headingText: 'FAIRRANK WM-Tippspiel 2010',
    width: 1020,
    height: 650
  });
}
*/

/* Newsletter in PopUp */
function new_win(){
  window.open("http://ea.ce-intern.com/_s.php?&fid=3766&fpw=52e824750ab7cc361f188417ee48b815","newwindow","width=535,height=390,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,top=5,left=5");
}
function new_win2(){
  window.open("http://ea.ce-intern.com/_s.php?&fid=5946&fpw=e092d8c66537d6f5056d39c6635bdec1","newwindow","width=535,height=390,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,top=5,left=5");
}
function new_win3(){
  window.open("http://ea.ce-intern.com/_s.php?&fid=12192&fpw=097e8cc03fcae35a621210205534956e","newwindow","width=535,height=390,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,top=5,left=5");
}

/* Animation Startseite (inaktiv) */
/*
function animation() {
  $.ajax({
    type: "POST",
    url: "/de/wGlobal/layout/scripts/loadPictures.php",
    async: false,
    success: function(msg) {
      if (msg != 'error') {
        $("#header").append(msg);
        $("img#header_start").animate( { opacity: 0.3 }, 4000 ).delay(500);
        $("ul#scroller img").animate( { opacity: 1 }, 6000 );
        $("ul#scroller").simplyScroll({
          autoMode: 'loop',
          speed: 2,
          pauseOnHover: false
        });
      }
    }

  });
}
*/

/* Aufruf Kontaktformular aus Google-Maps */
/* function callContact(add) {
  $("#contact_me").trigger('click');
  return false;
} */

$(document).ready(function(){

  /* nur ausführen, falls nicht in Editor */
  if ($("#wEditorExtensionArea").length == 0) {

  /* Click-Funktion auf komplettes LI ausweiten (statt nur A-Tag) */
  $("#mainmenu li").click(function() {
    var temp = $(this).find("a:first").attr("href");
    if (temp != "") document.location.href = temp;
  });


  /* Hover-Effect auf komplettes LI */
  $("#mainmenu li.navLevel1").hover(
    function() {
      $(this).css("background-color","#FFFFFF");
      $(this).find("a:first").css("color","#399441");
    },
    function() {
      $(this).css("background-color","transparent");
      $(this).find("a:first").css("color","#393939");
    }
  );

  /* Accordion für Team-Seite */
  if ($("div.accordion").length > 0) {
    $("div.accordion").accordion({
      active: false,
      autoHeight: false,
      header: 'div.department',
      animated: false,
      collapsible: true
    });
  }

  /* Click-Funktion für CallBack (inaktiv) */
  $("#callback").click(function() {
      $(this).find("a:first").trigger("click");
  });

  /* Click-Funktion für CallBack / Anfrage rechts */
  $("div.contact_container").click(function() {
      $(this).find("div.contact_image a:first").trigger("click");
      $(this).find("div.contact_image2 a:first").trigger("click");
      event.stopPropagation();
  });

  /* Click-Funktion für Textboxen rechts */
  $("#sidebar div.text").each(function() {
    if ($(this).find("a.more:first").length > 0) {
     if ($(this).find("a.more:first").attr("target") == "_blank") {
      $(this).click(function() {
        window.open($(this).find("a.more:first").attr("href"));
        return false;
      });
     } else {
      $(this).click(function() {
        document.location.href = $(this).find("a.more:first").attr("href");
      });
     }
     $(this).css("cursor","pointer");
    }
  });

  /* Click-Funktion für Kundenstimmen */
  $("#sidebar .ref_desc").each(function() {
    if ($(this).find("a.ref_more:first").length > 0) {
      $(this).parents(".ref_element:first").click(function() {
        document.location.href = $(this).find("a.ref_more:first").attr("href");
      });
      $(this).parents(".ref_element:first").css("cursor","pointer");
    }
  });

  /* Click-Funktion für News */
  $("#sidebar .news_desc").each(function() {
    if ($(this).find("a.more:first").length > 0) {
      $(this).parents(".news_element:first").click(function() {
        document.location.href = $(this).find("a.more:first").attr("href");
      });
      $(this).parents(".news_element:first").css("cursor","pointer");
    }
  });

  /* Click-Funktion für Zertifikate */
  $("#sidebar .elementContainer").each(function() {
    if ($(this).find("div.col1_30 a:first").length > 0) {
      if ($(this).find("div.col1_30 a:first").attr("target") != "_blank") {
        $(this).click(function() {
          document.location.href = $(this).find("div.col1_30 a:first").attr("href");
        });
        $(this).css("cursor","pointer");
      }
    }
  });


  /* Click-Funktion für Graue Box */
  $("div.bcol1,div.bcol2,div.bcol3,div.bcol_full").each(function() {
    if ($(this).find("div.bheader a:first").length > 0) {
      $(this).click(function() {
        document.location.href = $(this).find("div.bheader a:first").attr("href");
      });
      $(this).css("cursor","pointer");
    }
  });
  $("div.colored_header").each(function() {
    if ($(this).find("div.bcheader a:first").length > 0) {
      $(this).click(function() {
        document.location.href = $(this).find("div.bcheader a:first").attr("href");
      });
      $(this).css("cursor","pointer");
    }
  });

  /* Animation Startseite (inaktiv) */
  /* if ($("#header").length > 0) {
    setTimeout ( "animation()", 2000 );
  } */

  /* Tooltips aktivieren (inaktiv) */
  $("a.tooltip").cluetip({
     dropShadowSteps: 2,
     clickThrough: true,
     ajaxCache: true,
     positionBy: 'mouse'
  });
  $("a.tooltip").click(function() {
    return false;
  });
  $("a.tooltip").dblclick(function() {
    document.location.href = $(this).attr("href");
  });

  /* Sterne als Listen-Bullets (Test) */
  $("li span.star_red").each(function() {
    $(this).parents("li:first").append('<div class="star_red" />').addClass('special');
    $(this).replaceWith($(this).html());
  });

  $("li.navLevel2,li.navLevel2Open,li.navLevel2OpenSelected").hover(
    function() { $(this).find("ul.navLevel3").show(); },
    function() { $(this).find("ul.navLevel3").hide(); }
  );

  }

  /* alles weitere wird immer ausgeführt */

  /* diverse Anpassungen CSS */
  $("#content .ref_element:last,#content .news_element:last").css("background","none").css("padding-bottom","0");
  $("#sidebar a.newsletter").parent("div:first").css("margin-bottom","28px").siblings("div.elementList:first").css("margin-bottom","0px");
  $("#content hr").each(function() {
    $(this).wrap("<div>").parent("div:first").addClass("hr").find("hr").hide();
  });

  /* Fix für A/B-Test (inaktiv) */
  /* $("#content a.highslide").each(function() {
    $(this).find("noscript").replaceWith("");
    if ($.trim($(this).html()) == "Anfrage") {
      $(this).removeClass("highslide").addClass("highslide_next");
    }
  }); */

});

/* Unload für Google Maps */
if ($("#map_canvas").length > 0) {
  $(window).unload(function() {
    GUnload();
  });
}
