$(function() {
  $('div.controls a .hover').css('opacity', 0);
  
  // work widget
  $('#controls li a').hover(function() {

    // Stuff that happens when you hover on + the stop()
    $('.hover', this).stop().animate({
      'opacity': 1
      }, 700, 'easeOutSine')

    },function() {

      // Stuff that happens when you unhover + the stop()
      $('.hover', this).stop().animate({
        'opacity': 0
        }, 500, 'easeOutExpo')

      })

  $('#controls a.control').click(function() {
    var img = $(this).attr('rel');
    // background image
    imgSrc = 'url(/img/work_widget/' +  img + '_shot.jpg)';
    // header image
    hedSrc = 'url(/img/work_widget/' + img + '_header.gif)';
    // get header text and work type
    workType = $(this).find('span').attr('title');
    hedText = $(this).attr('title');
    
    // set bg's and text
    $('div.shot-panel').css('backgroundImage', imgSrc);
    $('h3.work-header').css('backgroundImage', hedSrc);
    $('h3.work-header').html(hedText);
    $('p.work-type').html(workType);
    
  });
  
   $('a[rel*=facebox]').facebox({ 
     loading_image : 'loading.gif', 
     close_image : 'closelabel.gif',
     opacity: 0.6
   })
  
  // fancybox popup
  // $("a.popup").fancybox({
  //   'hideOnContentClick'  : false,
  //   'zoomSpeedIn'          : 600,
  //   'zoomSpeedOut'       : 500,
  //   'easingIn'           : 'easeOutBack',
  //   'easingOut'            : 'easeInBack',
  //   'frameWidth'          : 800,
  //   'frameHeight'         : 920,
  //   'overlayOpacity'      : 0.5,
  //   'centerOnScoll'       : true
  // });
  
  // contact form
  $('a.submit').click(function() {
    $.ajax({
          type: "POST",
          url: "/contact.php",
          data: "name=" + $('#name').val() + "&organisation=" + $('#organisation').val() + "&email=" + $('#email').val() + "&telephone=" + $('#telephone').val() + "&enquiry=" + $('#enquiry').val() + "&contact_form=" + $('#contact_form').val(),
          success: function(msg){
            $('#contact-form').html(msg);
          }
      });
  });
   

});
