$('#wrapper').mouseenter(function(){  
  $('#d1').animate({
    "opacity":"1"
  },"slow");
  $('#d2').animate({
    "opacity":"0.2"
  },"slow");
  $('#d3').animate({
    "opacity":"0.2"
  },"slow");
  $('#d4').animate({
    "opacity":"0.2"
  },"slow");
});

$('#d1').mouseenter(function(){
  $('#d1').animate({
    opacity:"1",
    width:"480"
  },200);
  $('#d2').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d3').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d4').animate({
    opacity:"0.2",
    width:"160"
  },200);
});

$('#d2').mouseenter(function(){
  $('#d2').animate({
    opacity:"1",
    width:"480"
  },200);
  $('#d1').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d3').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d4').animate({
    opacity:"0.2",
    width:"160"
  },200);
});

$('#d3').mouseenter(function(){
  $('#d3').animate({
    opacity:"1",
    width:"480"
  },200);
  $('#d1').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d2').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d4').animate({
    opacity:"0.2",
    width:"160"
  },200);
});

$('#d4').mouseenter(function(){
  $('#d4').animate({
    opacity:"1",
    width:"480"
  },200);
  $('#d1').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d2').animate({
    opacity:"0.2",
    width:"160"
  },200);
  $('#d3').animate({
    opacity:"0.2",
    width:"160"
  },200);
});

$('#navi-startseite').click(function(){
  $('#impressum').fadeOut('fast',function(){
    $('#kontakt').fadeOut('fast',function(){
      $('#download').fadeOut('fast',function(){
        $('#referenzen').fadeOut('fast',function(){
          $('#startseite').fadeIn('slow',function(){});
        });
      });
    });
  });
});

$('#navi-impressum').click(function(){
  $('#startseite').fadeOut('fast',function(){
    $('#kontakt').fadeOut('fast',function(){
      $('#download').fadeOut('fast',function(){
        $('#referenzen').fadeOut('fast',function(){
          $('#impressum').fadeIn('slow',function(){});
        });
      });
    });
  });
});

$('#navi-referenzen').click(function(){
  $('#startseite').fadeOut('fast',function(){
    $('#kontakt').fadeOut('fast',function(){
      $('#download').fadeOut('fast',function(){
        $('#impressum').fadeOut('fast',function(){
          $('#referenzen').fadeIn('slow',function(){});
        });
      });
    });
  });
});

$('#navi-kontakt').click(function(){
  $('#startseite').fadeOut('fast',function(){
    $('#referenzen').fadeOut('fast',function(){
      $('#download').fadeOut('fast',function(){
        $('#impressum').fadeOut('fast',function(){
          $('#kontakt').fadeIn('slow',function(){});
        });
      });
    });
  });
});

$('#navi-download').click(function(){
  $('#startseite').fadeOut('fast',function(){
    $('#referenzen').fadeOut('fast',function(){
      $('#kontakt').fadeOut('fast',function(){
        $('#impressum').fadeOut('fast',function(){
          $('#download').fadeIn('slow',function(){});
        });
      });
    });
  });
});

$("a[rel=bilder]").fancybox({
  'transitionIn':'elastic',
  'transitionOut':'elastic',
  'overlayColor':'#000',
  'overlayOpacity':0.7,
  'titlePosition':'over',
  'cyclic':'true',
  'titleFormat':function(title,currentArray,currentIndex,currentOpts){
    return'<span id="fancybox-title-over">Bild '+(currentIndex+1)+' / '+currentArray.length+(title.length?'   '+title:'')+'</span>';
  }
});

$.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return $(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};

(function($){
  var cache=[];
  $.preLoadImages=function(){
    var args_len=arguments.length;
    for(var i=args_len;i--;){
      var cacheImage=document.createElement('img');
      cacheImage.src=arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

$("#ref01").hover(function() {
  $(this).attr("src","/files/ref01_small.jpg");
}, function() {
  $(this).attr("src","/files/ref01_small_grey.jpg");
});
$("#ref02").hover(function() {
  $(this).attr("src","/files/ref02_small.jpg");
}, function() {
  $(this).attr("src","/files/ref02_small_grey.jpg");
});
$("#ref03").hover(function() {
  $(this).attr("src","/files/ref03_small.jpg");
}, function() {
  $(this).attr("src","/files/ref03_small_grey.jpg");
});
$("#ref04").hover(function() {
  $(this).attr("src","/files/ref04_small.jpg");
}, function() {
  $(this).attr("src","/files/ref04_small_grey.jpg");
});
$("#ref05").hover(function() {
  $(this).attr("src","/files/ref05_small.jpg");
}, function() {
  $(this).attr("src","/files/ref05_small_grey.jpg");
});
$("#ref06").hover(function() {
  $(this).attr("src","/files/ref06_small.jpg");
}, function() {
  $(this).attr("src","/files/ref06_small_grey.jpg");
});
$("#ref07").hover(function() {
  $(this).attr("src","/files/ref07_small.jpg");
}, function() {
  $(this).attr("src","/files/ref07_small_grey.jpg");
});
$("#ref09").hover(function() {
  $(this).attr("src","/files/ref09_small.jpg");
}, function() {
  $(this).attr("src","/files/ref09_small_grey.jpg");
});

$(document).mouseenter(function(){
  jQuery.preLoadImages("files/ref01.jpg","files/ref02.jpg","files/ref03.jpg","files/ref04.jpg","files/ref05.jpg","files/ref06.jpg","files/ref07.jpg","files/ref09.jpg");
});

