// JavaScript Document




$(document).ready(function(){
  /*
  $('#g1').mbGallery({overlayBackground:'#f0f0f0', overlayOpacity:.8, 
      containment:".ImageGalleryTreml",
      cssURL:"http://www.pflanzen-treml.de/css/gallery/",
      skin:"white",
      exifData:false, //todo

      galleryTitle:"Sonstiges",
      imageSelector: ".imgFull",
      thumbnailSelector: ".imgThumb",
      titleSelector: ".imgTitle",
      descSelector: ".imgDesc",

      minWidth: 300,
      minHeight: 200,
      maxWidth: 0,
      maxHeight: 0,
      fullScreen:true,
      addRaster:false,
      startFrom: 0,//"random"
      fadeTime: 500,
      slideTimer: 6000,
      autoSlide: true,

      onOpen:function(){},
      onBeforeClose:function(){},
      onClose:function(){},
      onChangePhoto:function(){}
 
  });
  */
  if ($("#g1").length > 0) {
    $('#g1').mbGallery({overlayBackground:'#f0f0f0', overlayOpacity:.8, galleryTitle:"Sonstiges", slideTimer: 4000 });
  }
  $("#GotoPlantArticle, #GotoSeedArticle").hover(
    function() {$(this).css({"backgroundColor":"#ccc"})},
    function() {$(this).css({"backgroundColor":"transparent"})}
  );
  
  $(".Article").hover(
    function() {$(this).css({"backgroundColor":"#ECEEEE", "borderColor":"none", "borderColor":"#e6e6e6"}).find("div").css({"color":"#333"})},
    function() {$(this).css({"backgroundColor":"#e6e6e6", "borderColor":"#ccc", "borderStyle":"solid"}).find("div").css({"color":"black"})}
  );
  

  $("#ShowcaPasswd").click(function() {
  
    var pwd = $("#caPasswd").val();
    
    if ($("#caPasswd").attr("type") == "password") { 
      $("#caPasswd").replaceWith("<input maxlength='"+$("#caPasswd").attr("maxlength")+"' value='"+pwd+"' type='text' name='"+$("#caPasswd").attr("name")+"' id='caPasswd' />");
    }
    else {
      $("#caPasswd").replaceWith("<input maxlength='"+$("#caPasswd").attr("maxlength")+"' value='"+pwd+"' type='password' name='"+$("#caPasswd").attr("name")+"' id='caPasswd' />");
    }
  
  })

  $("#ShowcaPasswdContinue").click(function() {
  
    var pwd = $("#caPasswdContinue").val();
    
    if ($("#caPasswdContinue").attr("type") == "password") { 
     
      $("#caPasswdContinue").replaceWith("<input maxlength='"+$("#caPasswdContinue").attr("maxlength")+"' value='"+pwd+"' type='text' name='"+$("#caPasswdContinue").attr("name")+"' id='caPasswdContinue' />");
    }
    else {
      $("#caPasswdContinue").replaceWith("<input maxlength='"+$("#caPasswdContinue").attr("maxlength")+"' value='"+pwd+"' type='password' name='"+$("#caPasswdContinue").attr("name")+"' id='caPasswdContinue' />");
    }
  
  })




  $(".neuePflanzenArtikel").hover(
            function() {
              $(this).css({"backgroundColor":"#ccc", "border":"1px solid green"});
            },
            function() {
              $(this).css({"backgroundColor":"transparent", "border":"1px solid #ccc"});
            }
  );


 /* Buecher Startseite */
  $("#Startseite #Buecher .Content .Books").hover(
    
    function(){
      var infotext = "";
      
      if ($(this).attr("id") == "Book02") infotext = "Heilkraft aus dem Garten <span style='font-size:10px;'>f&uuml;r nur</span> <span style='font-size:16px;'>&euro; 7,95</span>";
      if ($(this).attr("id") == "Book01") infotext = "Kr&auml;uter aus dem Garten <span style='font-size:10px;'>f&uuml;r nur</span> <span style='font-size:16px;'>&euro; 12,95</span>";
      if ($(this).attr("id") == "Book03") infotext = "Geheimnisse im Kr&auml;utergarten <span style='font-size:10px;'>f&uuml;r nur</span> <span style='font-size:16px;'>&euro; 8,80</span>";
      if ($(this).attr("id") == "Book04") infotext = "Heilkraft aus Heilpflanzen <span style='font-size:10px;'>f&uuml;r nur</span> <span style='font-size:16px;'>&euro; 4,90</span>";
      if ($(this).attr("id") == "Book05") infotext = "Exotische Kr&auml;uter <span style='font-size:10px;'>f&uuml;r nur</span> <span style='font-size:16px;'>&euro; 14,95</span>";
      $("#Startseite #Buecher .Content #ArticleInfo").html(infotext).fadeIn(1000, function() { $(this).show(); } );
      //$("#Startseite #Buecher .Content #ArticleInfo");
    },
    function(){
      $("#Startseite #Buecher .Content #ArticleInfo").hide();//fadeOut("fast", function() { $(this).html(""); } );
      //$("#Startseite #Buecher .Content #ArticleInfo");
    }
  );
  

  $("#ContentTop .lm").animate({"opacity": 0.4
                                }, 1500);


  /* FROHES FEST AND SILVESTER */
  var arrImageSource = ["http://www.pflanzen-treml.de/pics/frohesfest/advent.png", "http://www.pflanzen-treml.de/pics/frohesfest/silvester.png"];
  var arrText = ["Die Familie Treml w&uuml;nscht Ihnen ein frohes Fest und ...", "...  ein gutes neues Jahr!"];
  
  (function () {
  
     var Pic = {
         count: 0,
         act: "",
         total: 0,
         next: 0,
         prev: 0
     }
     
     var arrImg = $(arrImageSource);
     var objActPic = new Image();
     var hrefPrev = document.createElement('a');
     var hrefNext = document.createElement('a');
  
  
  
     jQuery.SLShow = function(obj) {
  
         SLObj = this;
  
         this.init = function () {
  
             Pic.total = $(arrImageSource).length;
  
             this.setActPicPos();
             this.PreloadImages();
  
             this.LoadActPic();
  
  
             
         };
  
  
         this.setActPicPos = function () {
  
             /*Pic.act = Number(location.hash.replace("#", ""));*/
             Pic.prev = Pic.act;
  
             if ((arrImageSource.length-1 == Pic.act) ) {
                 Pic.act = 0;
             }
             else Pic.act++;
  
             Pic.next = Pic.act + 1;
  
             if ((arrImageSource.length-1 < Pic.next) ) {
                 Pic.next = 0;/*arrImageSource.length-1;*/
             }
  
  
         };
  
  
         this.LoadActPic = function () {
  
             $(objActPic).load( function () {
                 ImgPosX = objActPic.offsetLeft;
                 ImgPosY = objActPic.offsetTop;
                 ImgHeight = objActPic.offsetHeight;
                 ImgWidth = objActPic.offsetWidth;
                 $(objActPic).css({"width": ImgWidth+"px", "height": ImgHeight+"px"});
             });
  
             objActPic.src = arrImg[Pic.act];
  
             $(obj).append(objActPic);
             TextMarkUp = "<p>"+arrText[Pic.act]+"</p>";
             $(obj).append(TextMarkUp);
             $(obj).find("p").css("opacity", "0.9");
             $(obj).fadeIn(function() {
                 $(obj).find("p").fadeIn();
             });
  
         }
  
  
         this.setPicIndex = function () {
  
             this.setActPicPos();
  
  
         };
         
         this.PreloadImages = function () {
  
             var PrevPic = new Image();
             var NextPic = new Image();
  
             this.setPicIndex();
  
             NextPic.src = arrImg[Pic.next];
             PrevPic.src = arrImg[Pic.prev];
  
             $(obj).fadeOut(function () {
                 $(obj).html("");
                 SLObj.LoadActPic();
             });
             
         };
  
  
         this.getPic = function () {
  
             this.PreloadImages();
  
         };
  
         /*$(window).hashchange(jQuery.proxy(this.getPic, this));*/
         window.setInterval("SLObj.getPic()", 4000);
  
     };
  
  
  
  
     jQuery.fn.picSlideshow = function () {
  
        var conObj = new jQuery.SLShow(this);
        conObj.init();
  
     }
  })();
  
  
  
  jQuery(function () {
    $("#sls-box").picSlideshow();
  });

/* Ende der FUNKTION */
});



