
$(document).ready(function($) {

  $('#menu a, h1').each(function(i) {
    width = $(this).width();
    height = $(this).height();
    font_size = $(this).css('font-size');
    color = escape($(this).css('color'));
    $img = $('<img src="/render_typo.php?text='+escape($(this).text())+'&width='+width+'&height='+height+'&size='+font_size+'&fgcol='+color+'"/>');
    $img.css('float', 'none');
    $img.css('border', '0');
    $img.css('width','auto');
    $img.css('height','auto');
    $(this).html($img);
  });
  
  $('.service').mouseover(function(e) {
    $('.service_description').text($(this).find('.servicetext p').text());
  });
  
  $('.service_description').text($('.service:first').find('.servicetext p').text());


  $('.desaturable img').each(function(i) {
    grayscale(this);
  });

  $('.desaturable').mouseover(function(e) {
    $(this).find('img').each(function(i) {
      grayscale.reset(this);
    });
  });

  $('.desaturable').mouseout(function(e) {
    $(this).find('img').each(function(i) {
      grayscale(this);
    });
  });

  $('.desaturable2').hover(function(e) {
    $(this).find('.desaturated_overlay').hide(); //.stop().fadeOut(200);
    $(this).css('color','#cacbcc');
  },function(e) {
    $(this).find('.desaturated_overlay').show(); //.stop().show();
    $(this).css('color','#717173');
  }
  );

  $('#ftp_upload_block').hide();

  $('input:radio[name=file_upload_method]').change(function(e) {
    if ($('input:radio[name=file_upload_method]:checked').val()=="Dropbox")
    {
      $('#form_upload_block').show();
      $('#ftp_upload_block').hide();
    }
    else
    {
      $('#form_upload_block').hide();
      $('#ftp_upload_block').show();
    }
  });

  $('form').has('.request_form').submit(function() {
    if ($('input[name=mockup]').val()!="" && $('input[name=mockup]').val().substr(-3)!="jpg" && $('input[name=mockup]').val().substr(-4)!="jpeg")
    {
      alert("Das Mockup sollte im JPEG-Format sein.");
      return false;
    }
  });

  
  $('a[rel=frontendfacebox]').facebox();


});

