var q_default_value = "SUCHE";

$(document).ready(function() {
   sozene.init();
});

var sozene = {
   
   visuals: [],
   visuals_ident: 0,
   visuals_play: true,
   visuals_timeout: 5000,
   
   init: function() {
      sozene.searchForm(q_default_value);
      sozene.setSpacerHeight();
   },
   
   searchForm: function(default_value) {
      $("#q").val(q_default_value);
      $("input#q").click(function() {
         if ($("#q").val() == default_value) $("#q").val("");
      });
      $("input#q").blur(function() {
         if ($("#q").val() == "") $("#q").val(default_value);
      });
      $("form#search a").click(function() {
         $("form#search").submit();
         return false;
      });
   },
   
   setSpacerHeight: function() {
      var left = $("div#left").height();
      var right = $("div#right").height();
      var spacer = $("div#right div.spacer").height();
      if (left > right) $("div#right div.spacer").css("height", (left-(right-spacer))+"px");
   },
   
   setHomeVisuals: function() {
      
      $("div.visual div.content").each(function(i) {
         sozene.visuals[i] = $("div.visual div.content")[i];
      });
      
      $(sozene.visuals[0]).show();
      
      $("div.visual div.bottom img.control").click(function() {
         if (sozene.visuals_play) {
            sozene.visuals_play = false;
            $(this).attr("src", "/fileadmin/gfx/visuals/control_play.jpg");
         } else {
            sozene.visuals_play = true;
            $(this).attr("src", "/fileadmin/gfx/visuals/control_pause.jpg");
            window.setTimeout("sozene._playVisuals()", sozene.visuals_timeout);
         }
      });
      
      window.setTimeout("sozene._playVisuals()", sozene.visuals_timeout);
      
   },
   
   _playVisuals: function() {
      if (sozene.visuals_play) {
         $(sozene.visuals[sozene.visuals_ident]).fadeOut(1000);
         sozene.visuals_ident = (sozene.visuals_ident == 4 ? 0 : sozene.visuals_ident+1);
         $(sozene.visuals[sozene.visuals_ident]).fadeIn(1000);
         window.setTimeout("sozene._playVisuals("+sozene.visuals_ident+")", sozene.visuals_timeout);
      }
   },
   
   setArticleImages: function() {
      
      var content = $("div.images div.carousel div.showcase div.content");
      var prev = $("div.images div.carousel div.control img.prev");
      var next = $("div.images div.carousel div.control img.next");
      var page_act = $("div.images div.carousel div.control span.act");
      var page_max = $("div.images div.carousel div.control span.max");
      
      var count = $("div.images div.carousel div.showcase div.content img").size();
      $("div.images div.carousel div.showcase div.content").css("width", count*130+"px");
      
      var act = 1;
      page_act.html(act);
      var max = Math.ceil(count/2);
      page_max.html(max);
      
      var lock = false;
      
      prev.click(function() {
         if (!lock && act > 1) {
            lock = true;
            content.animate({left: "+=260px"}, function() {
               act--;
               page_act.html(act);
               if (act == 1) prev.attr("src", "/fileadmin/gfx/images/btn_prev.jpg");
               if (act < max) next.attr("src", "/fileadmin/gfx/images/btn_next_active.jpg");
               lock = false;
            });
         }
      });
      
      next.click(function() {
         if (!lock && act < max) {
            lock = true;
            content.animate({left: "-=260px"}, function() {
               act++;
               page_act.html(act);
               if (act > 1) prev.attr("src", "/fileadmin/gfx/images/btn_prev_active.jpg");
               if (act == max) next.attr("src", "/fileadmin/gfx/images/btn_next.jpg");
               lock = false;
            });
         }
      });
      
      var image = "image_1";
      
      $("div.images div.carousel div.showcase div.content img").click(function() {
         selected = $(this).attr("class");
         if (selected != image) {
            $("div.images div.image."+image).fadeOut(function() {
               $("div.images div.image."+selected).fadeIn();
               image = selected;
            });
         }
      });
      
   }
   
}

// TYPO3
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}

