function onBefore() {
   var witty = $(this).children('img').width()-30;
   var posty = $(this).children('img').offset();
   var yeft = posty.left;
   var galy = $(this).offset();
   var galyYeft  = galy.left;
   var sum = yeft - galyYeft ;
   $('.info').css({width:witty+'px', left:sum+'px'});
    }


$(document).ready(function(){
	$('<div id="loady" style="margin-top:100px;"><img src="animLoader.gif" /></div>').appendTo("#container");
	$('#gallery').cycle({ 
    fx:'fade', 
    speed: 1000, 
    timeout:2500
    
    
   
        
       
    
    
    });
    
    
   
   
     $(".piece").parent().hover(
      function () {
        $(this).children('.piece').stop().animate({opacity:"0.1"}, 500);
        $(".info").fadeIn(500);
      }, 
      function () {
        $(this).children('.piece').animate({opacity:"1"}, 500);
         $(".info").fadeOut(500);
         $(".info").css({display:'none'});
      }
    );

    
   
  	
    $(".rollover").hover(
      function () {
        $(this).animate({opacity:"0.4"}, 200);
      }, 
      function () {
         $(this).animate({opacity:"1"}, 200);
      }
    );
    
    
     $("#worky").click(function() {
 	  $("#nav").fadeIn();
 	
 	
 	
 });
 
 
 



     //form validation
  
  $("input,textarea").focus(function () {
  	$(this).val("");
  
	 	

            });


$("#frog").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({target: "#thanks"});
				$("#frog").css({display:'none'});
				$("#thanks").fadeIn('slow');
			}
});

        





    




});


		 $(window ).load(function() {
 
 	$("#loady").fadeOut('slow', function() {$("#gallery").fadeIn(); $(this).remove();}); 
 	var bitty = $("#gallery").children().children('img').width()-30;
 	var gofset = $("#gallery div").offset();
 	var gofsetL = gofset.left;
    var noset = $("#gallery").children().children('img').offset();
    var nosetL = noset.left;
    var som = nosetL - gofsetL;
    $(".info").css({left:som+'px', width:bitty+'px'});
 	
 	
 	
 });

