$(document).ready(function() {
	// PNG Fix für IE6
   	$(document).pngFix(); 
   	
	// shadow for subnav
	$("div.sublinks")
		.wrap('<div class="cb"></div>')
		.after('<div class="bb"><div></div></div>')
		.wrap('<div class="i1"><div class="i2"></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)
	          title = '<p>' + title + '</p>';
	       else
	          title = '';
	       return '<span id="fancybox-title-inside">' + title + 'Bild ' +  (currentIndex + 1) + ' von ' + currentArray.length + '</span>';
	      },
	   'centerOnScroll'   : true
	});
	
	// Fancybox (Skizze im Rundgang)
	$(".fbs").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false
	});
	
	// Dropdown menus for IE
	$("#nav li").mouseover(function() {
		$(this).addClass("sfhover");
	});
	$("#nav li").mouseout(function() {
		$(this).removeClass("sfhover");
	});
});

// schatten für bildboxen (erst wenn die bilder geladen sind)
window.onload = function() {
	// Einzelnes Bild
	$("img.frame").each(function() {
		var box = this.width + 12;
		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" />');
	});
}
