var a = 0;
var b = 0;
//$(document).ready(function() {
//	$(".galwrap .gallery:last-child").css({'border-right' : '2px solid white'});
//});
function lasche_rein() {
	b = 0;
	if (a == 0) {
		a = 1;
		$("#effect").effect('slide',{ mode: "show" },500);
		$("#effect_shadow").effect('slide',{ mode: "show"}, 500);
		$("#slidehandle").animate({ left: "124px" },500);
		$("#lasche").animate({width: "181px" }, 500);
	}
}
function lasche_raus () {
	a = 0;
	if (b == 0) {
		b = 1;
		$("#effect").effect('slide',{ mode: "hide" },500);
		$("#effect_shadow").effect('slide',{ mode: "hide"}, 500);
		$("#slidehandle").animate({ left: "0px" },500);
		$("#lasche").animate({width: "57px" }, 500);
	}
}
$(function() {
    $('.rollover').hover(function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	}, function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	});
});
$(document).ready(function() {
	if( $("#visual_fade").length > 0) {
    $("#visual_fade").fadeTo(3000, 0);
  };
	if( $("#effect").length > 0) {
   $("#effect").effect('slide',{ mode: "hide" },0);
  }
	if( $("#effect_shadow").length > 0) {
   $("#effect_shadow").effect('slide',{ mode: "hide"},0);
  }
	if( $("#slidehandle").length > 0) {
    $("#slidehandle").animate({ left: "0px" },0);
  }
	if( $("#lasche").length > 0) { 
   $("#lasche").animate({width: "57px" }, 0);
   $("#lasche").hover(function() {
  		lasche_rein();
  	}, function() {
  		lasche_raus();
  	});
  }
  galleryMehrAls20Bild();		
});
$(function() {
	$('.customscroll').click(function() {
		var a = this.href.lastIndexOf("#");
		var b = this.href.substring(a+1,this.href.length);
		$.scrollTo( $("a[name="+b+"]"), 800, {offset: -338});
	});
});

function galleryMehrAls20Bild(){
   if( $(".galwrap").length > 0) {
     var n = 1;
     for(var i=0;i<$(".galwrap").length;i++){
       if($(".galwrap")[i].childNodes.length > 21){
          $(".galwrap")[i].id="galcontainer"+n;
          n++;
       }
     }
     if(n > 1){
      for(var x=1;x<n;x++){  
        $("#galcontainer"+x).prepend('<div id="gallery-second'+x+'" class="inner-container-gal"></div>');
        $("#galcontainer"+x).prepend('<div id="gallery-first'+x+'" class="inner-container-gal"></div>');        
        $("#galcontainer"+x+" a.gallery").each(function(index){
          if(index < 19){
            $(this).clone().appendTo('#gallery-first'+x);
            $(this).remove();
          }else{
            $(this).clone().appendTo('#gallery-second'+x);
            $(this).remove();
          }
        });
      }
      tb_init($(".inner-container-gal a.gallery"));
     }     
   }
   
}		

