/*  #####################################################
**  Domain:    www.tourismus.saarland.de
**  Datei:     basic.js
**  Funktion:  grundlegender JavaScript Code für alle Unterseiten

**  Erstellt:  04.03.2009

**  Autor:     Axel Güldner
**  copyright: infomax websolutions GmbH
##################################################### */

function hideActiveOne(){
  $(document).unbind('mousedown', hideActiveOne);
  $("#topnavi").children(".first").children(".active").removeClass("active").fadeOut("fast");
  //Einblenden der selectboxen im IE
  if($.browser.msie && jQuery.browser.version < 7) $("body").find("select").each(function(){
    $(this).removeClass("none");
  });
}
function hideActiveTwo(){
  $("#topnavi").children(".first").children(".second").children(".second").children(".active").removeClass("active").slideUp("slow");
}

$(document).ready(function(){
  //Animation der Topnavigation
  //Aufklappen der zweiten Ebene
  var navHide1 = "";
  var animFlag1 = false;
  $("#topnavi").children(".first").bind("mouseenter",function(){
    //Ausblenden der selectboxen im IE
    if($.browser.msie && jQuery.browser.version < 7) $("body").find("select").each(function(){
      $(this).addClass("none");
    });
    window.clearTimeout(navHide1);
    if(animFlag1 == false && $(this).children(".second").size() > 0){
      animFlag1 = true;
      $(this).parent().children(".first").children(".second").removeClass("active");
      $(this).children(".second").addClass("active").fadeIn("fast", function(){
        animFlag1 = false;
      });
      $(this).parent().children(".first").children(".second:not(.active)").fadeOut("fast");
    }
    $(document).bind('mousedown', hideActiveOne);
  });
  $("#topnavi").children(".first").bind("mouseleave",function(){
    navHide1 = window.setTimeout("hideActiveOne()", 2000);
  });

  //Animation der Topnavigation
  //Aufklappen der dritten Ebene
  var navHide2 = "";
  var animFlag2 = false;
  $("#topnavi").children(".first").children(".second").children(".second").bind("mouseenter",function(){
    window.clearTimeout(navHide2);
    if(animFlag2 == false && $(this).children(".third").size() > 0){
      animFlag2 = true;
      $(this).parent().children(".second").children(".third").removeClass("active");
      $(this).children(".third").addClass("active").slideDown(1000, function(){
        animFlag2 = false;
      });
      $(this).parent().children(".second").children(".third:not(.active)").slideUp(1000);
    }
  });
  $("#topnavi").children(".first").children(".second").children(".second").bind("mouseleave",function(){
    navHide2 = window.setTimeout("hideActiveTwo()", 1000);
  });



  //Animation der Imageteaser bei Mousover
  $("#CONT_contentarea").find(".imageTeaser").not('.museum').bind("mouseenter", function(){
    $(this).children(".side0").fadeOut();
    $(this).children(".side1").fadeIn();
  });
  $("#CONT_contentarea").find(".imageTeaser").not('.museum').bind("mouseleave", function(){
    $(this).children(".side1").fadeOut();
    $(this).children(".side0").fadeIn();
  });


  //Animation der Topteaser bei Mousover
  $("#topteaserleiste ul:not(.controller)").children("li").children("a").bind("mouseenter",function(){
    var newActive = $(this).attr("rel")-1;
    var newParent = $(this).parent().parent().attr("class").substr(4)
    $("#topteaserleiste .text"+newParent).children("li:eq("+newActive+")").show();
  });
  $("#topteaserleiste ul:not(.controller)").children("li").children("a").bind("mouseleave",function(){
    var newActive = $(this).attr("rel")-1;
    var newParent = $(this).parent().parent().attr("class").substr(4)
    $("#topteaserleiste .text"+newParent).children("li:eq("+newActive+")").hide();
  });
  //Animation der Topteaser bei Mouseclick auf Controller
  $("#topteaserleiste ul.controller").children("li").children("a").click(function(){
    $(this).parent().parent().children("li").children(".active").removeClass("active");
    $(this).addClass("active");
    var newActive = $(this).attr("rel");
    $("#topteaserleiste ul:not(.side"+newActive+"):not(.controller)").fadeOut();
    $("#topteaserleiste ul.side"+newActive).fadeIn();
    $("#topteaserleiste ul.text"+newActive).fadeIn();
  });


  //Datepicker für Quartiersuche
  Date.format = 'dd.mm.yyyy';
  $("#quartiersucheFR1").datePicker({
    saarlandstyle:imxSaarlandstyle
  });
  $("#quartiersucheFR1").dpSetStartDate(currentCalenderDate);
  $("#quartiersucheFR1").dpSetSelected(currentCalenderDate);
  
  $("#offerBookingArrival").datePicker({
    saarlandstyle:imxSaarlandstyle
  });
  $("#offerBookingArrival").dpSetStartDate(currentCalenderDate);
  $("#offerBookingArrival").dpSetSelected(currentOfferDate[1]);
  $("#offerBookingDeparture").datePicker({
    saarlandstyle:imxSaarlandstyle
  });
  $("#offerBookingDeparture").dpSetStartDate(currentOfferDate[0]);
  $("#offerBookingDeparture").dpSetSelected(currentOfferDate[2]);

  //Sicherstellen das für Abreise nur ein Datum höher als Anreise gewählt werden kann
  $("#offerBookingArrival").change(function(){
    $(this).compareDates("#offerBookingDeparture");
  });


  //Autcomplete Formfields
  //$(".autocomplete").valueset("../portal/autocomplete.php");
  //JavaScript Dropdowns
  //$(".valueset").valueset();

  //ColorBox: Einstellungen
  $("a[rel=colorboxGallery],a[rel=colorboxGalleryWebcam1],a[rel=colorboxGalleryWebcam2],a[rel=colorboxGalleryWebcam3]").colorbox({
    transition:"elastic",
    opacity:0.8,
    current : "Bild {current} von {total}",
    previous : "zurück",
    next : "weiter",
    close : "Schließen"
  });
  $("a[rel=colorboxFrontdoorIframes]").colorbox({
    width:"600px",
    height:"580px",
    iframe:true
  });
  $("a[rel=quizOverlay]").colorbox({
    width:"802px",
    height:"634px",
    iframe:true
  });
  $("a[rel=colorboxHtml]").colorbox({
    width:"500px",
    height:"270px",
    iframe:true
  });

  $("a[rel=panorama]").colorbox({
    width:"820px",
    height:"715px",
    iframe:true
  });

  $("a[rel=offerQuality]").colorbox({
    width:"820px",
    height:"690px",
    iframe:true
  });
  
  //cleveres FullPage Example auf bestehende Input-Values
  var activeInputValue = "";
  $("body").find("input:not(.dp-applied):not([name=searchType]):not(.ignoreHoverBlur)").each(function(){
    $(this).focus(function(){
      activeInputValue = $(this).val();
      $(this).val("");
    });
    $(this).blur(function(){
      if($(this).val() == "")$(this).val(activeInputValue);
      activeInputValue = "";
    });
  });
  $("body").find("textarea").each(function(){
    $(this).focus(function(){
      activeInputValue = $(this).val();
      $(this).val("");
    });
    $(this).blur(function(){
      if($(this).val() == "")$(this).val(activeInputValue);
      activeInputValue = "";
    });
  });

});



$(window).load(function(){

  });

