$(document).ready(function() {
   // PNG Fix für IE6
   $(document).pngFix(); 
   
   // Suchfeld
   $("#searchinput").each(function() {
      var f = $(this).val();
      if (f == "Suchbegriff") {
         $(this).css("color","#a4a4a4");
         $(this).focusin(function() {
            if($(this).val() == f){
               $(this).val("");
               $(this).css("color","#4f4f4f");
            }
         });
         $(this).focusout(function() {
            if($(this).val() == ""){
               $(this).val(f);
               $(this).css("color","#a4a4a4");
            }
         });
      }
   });
      
   // Schatten für Feature-Boxen 
   $("div.feature")
   	.addClass("shadow")
   	.removeClass("feature")
      .wrapInner('<div class="bl"><div class="br"><div class="feature"></div></div></div>')
   	.prepend('<div class="bt"><div></div></div>')
   	.append('<div class="bb"><div></div></div>');
   	
   // Fancybox (single Image)
   $("a.fb").fancybox({
       'titlePosition'     : 'inside',
       'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
           if (title !== '' && title) {
              return '<span id="fancybox-title-inside"><p>' + title + '</p></span>';
           }
           return '';
       },
       'centerOnScroll'   : true
   });
   
   // Fancybox (Gallery)
   $("a[rel=gallery]").fancybox({
       'titlePosition'     : 'inside',
       'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
           if (title !== '') {
              title = '<p>' + title + '</p>';
           }
           return '<span id="fancybox-title-inside">' + title + 'Bild ' +  (currentIndex + 1) + ' von ' + currentArray.length + '</span>';
          },
       'centerOnScroll'   : true
   });
});

// Schatten für Bildboxen (erst wenn die Bilder geladen sind)
window.onload = function() {
   // Box mit mehreren Bildern
   $("div.frame").each(function() {
      $(this).css("width", ($(this).children("img").first().attr("width")+22) + "px");
      $(this).wrapInner("<div></div>");
      $(this).append('<img src="images/shadow_box.png" class="shadow" style="width:100%;height:17px" />');
   });
   
   // Einzelnes Bild
	$("img.frame").each(function() {
		var box = this.width + 22;
		var cssClass = this.className;
		if (!cssClass)
			cssClass = '';
		var el = ($(this).parent().tagName == 'a') ? $(this).parent() : $(this);
		el.wrap('<div class="' + cssClass + '" style="width:' + box + 'px"><div></div></div>');
		$(this).removeClass(cssClass);
		el.after($(this).attr("title"));
		if ($(this).attr("title") == '')
		   $(this).css("margin-bottom", "0px");
		el.parent("div").after('<img src="images/shadow_box.png" class="shadow" style="width:100%;height:17px" />');
	});
}