/**
 * @author karlmetzler
 */

$(function(){
	$('.cat_thumb, img.thumb').each(function(){
	
		$(this)
	
	          .css({
	              "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg)',
	              "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg)'
	          })
	          .hover(function() {
	              $(this).css({
	                  "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)',
	                  "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)'
	              })
	          }, function() {
	              $(this).css({
	                  "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1)',
	                  "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1)'
	              })
	          });
		
	});
	
	$('#mail_list_submit').click(function(){
		//console.info($(this).parent().attr('action'));
		
		// basic form validation 
		if($('#first_name').val() == '') { return false; }
		if($('#last_name').val() == '' ) { return false; }
		if($('#email').val() == '') { return false; }
		var posturl = $(this).parent().attr('action');
		$.post(
			posturl,
			{
				'first_name':$('#first_name').val(),
				'last_name' : $('#last_name').val(),
				'email' : $('#email').val()
			},
			function(r){
				console.info(r);
			}
		);
		return false; 
	});
	
	$('.close').click(function(){
		var el = $(this).parent();
		$(el).slideUp('slow');
	});

});

