/* Author: Josh Luther 
   Author: Karl Oscar Weber
*/



$(function(){
    
 $('input[title]').each(function() {
  if($(this).val() === '') {
   $(this).val($(this).attr('title')); 
  }
  });
  
  $('input[title]').focus(function() {
   if($(this).val() === $(this).attr('title')) {
    $(this).val('').addClass('focused'); 
   }
  });
  
  $('input[title]').blur(function() {
   if($(this).val() === '') {
    $(this).val($(this).attr('title')).removeClass('focused'); 
   }
  });
 
 // ajax form
$(".form form").submit(function(){

    var str = $(this).serialize();
    
   $.ajax({
       type: "POST",
       url: "mailer.php",
       data: str,
       success: function(msg){
    
            $(".form form").ajaxComplete(function(event, request, settings){
            
                if(msg == 'ok') // Message Sent? Show the 'Thank You' message and hide the form
                {
                    result = 'Thank you!';
                    $(".form").fadeOut();
                } else {
                    result = msg;
                }
                
                $('.output').html(result);
                
            });
    
        }

    });
    
    return false;
    
});

});




















