$(document).ready(function(){ 

  $($.date_input.initialize);             
   
  jQuery.each($(".chkbxln, #datebox"), function(){
    $(this).focus(function(){ 
      $(this).attr("value", "");
      $(this).css('color','#333');
    });               
  });  
  $("textarea").click(function(){ 
    $("textarea").html("");
    $(this).css('color','#333');
  });  		
	
	$('ul#imagechng, ul#imagechng2').innerfade({
  	speed: 2000,
  	timeout: 8000,
  	type: 'sequence',
  	containerheight: '0px'
  });
  
  $("#thumbs img").each(function(){
    $(this).click(function(){
      var src = $(this).attr('src');
      if ($("#bigimg3").length > 0){ 
        $('#bigimg3').clone().appendTo('#content').attr('id','bigimg2').css({ position: 'absolute', top: '105px', left: '99px', width: '350px', height: '263px', marginLeft: '-15px', marginTop: '-15px'}); 
        $('#bigimg3').remove();             
        $("#content").prepend('<img src="'+src+'" id="bigimg3" alt="" />');
        $("#bigimg3").css('opacity','0.0');
        $('#bigimg3').animate({opacity: 1.0}, 200, function(){
          $('#bigimg2').remove();
        });            
      } else {
        $('#bigimg').clone().appendTo('#content').attr('id','bigimg2').css({ position: 'absolute', top: '59px', left: '99px', width: '350px', height: '263px', marginLeft: '-15px', marginTop: '-15px'}); 
        $('#bigimg').remove();             
        $("#content").prepend('<img src="'+src+'" id="bigimg" alt="" />');
        $("#content").prepend('<img src="img/lupe.gif" id="lupe" alt="" />');
        $("#content").prepend('<img src="img/close.gif" id="close" alt="" />');
        $("#bigimg, #lupe, #close").css('opacity','0.0');
        $('#bigimg, #lupe, #close').animate({opacity: 1.0}, 200, function(){
          $('#bigimg2').remove();
        });
      }
    });
  });
  
  $('#bigimg, #lupe').live('click', function() {
    if($('#bigimg').is(":animated")) return;
    if($('#bigimg').css('width')=='800px') {
       $(this).animate({
         width: '350px',
         height: '263px',
         marginLeft: '-15px',
         marginTop: '-15px'
       }, 200, function(){
         $('#lupe, #close').css('zIndex','100');
       });
    } else {
      $('#lupe, #close').css('zIndex','0');
      $('#bigimg').animate({
         width: '800px',
         height: '600px',
         marginLeft: '-225px',
         marginTop: '-160px'
       }, 200);
    }
  });
  
  $('#bigimg3, #lupe2').live('click', function() {
    if($('#bigimg3').is(":animated")) return;
    if($('#bigimg3').css('width')=='800px') {
       $(this).animate({
         width: '350px',
         height: '263px',
         marginLeft: '-15px',
         marginTop: '-15px'
       }, 200, function(){
         $('#lupe2').show();
       });
    } else {
      $('#lupe2').hide();
      $('#bigimg3').animate({
         width: '800px',
         height: '600px',
         marginLeft: '-225px',
         marginTop: '-160px'
       }, 200);
    }
  });
  
  $('#close').live('click', function() {
    $('#bigimg, #bigimg2, #lupe, #close').animate({opacity: 0.0}, 200, function(){
        $('#bigimg, #bigimg2, #lupe, #close').remove();
      });    
  });
  
  $(".sliderheader").each(function(){
    $(this).css({cursor:'pointer'});
    $(this).next([".slider"]).css({display:'none'});
  });

  $(".sliderheader").click(function(){           
    if($(this).next([".slider"]).is(":animated")) return;
    var act = $(this).next([".slider"]);
    var pact = $(this);             
    if($(this).next([".slider"]).is(":visible")) {
      $(act).slideUp(500); 
      $(pact).css({background:'url(img/pfeil1.png) no-repeat 12px 7px'}); 
    } else {
      $(".sliderheader").not(pact).each(function(){
        $(this).next([".slider"]).slideUp(500);
        $(this).css({background:'url(img/pfeil1.png) no-repeat 12px 7px'}); 
      });   
      $(act).slideDown(500);
      $(pact).css({background:'url(img/pfeil2.png) no-repeat 12px 6px'});  
    }         
  }); 
	
});

