String.prototype.trim = function () {
  return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

$(document).ready(function(){

	
	
	// Setup fancy animation for top tab thing
	$('#super_head_graphic').mouseover(function(){
			$(this).animate( { top: '0px' }, 100 );
		}).mouseout(function(){
			$(this).animate( { top: '-30px' }, 100 );			
		});
	
	
	/*----------------------------
	Share this stuff
	*/
$('#share_this_to').val("Their E-mail");
$('#share_this_from').val("Your E-mail");
	$('#share_this_to').focus(function() { 
		this.select();
	
	});
	
	$('#share_this_from').focus(function() { 
		this.select();
	
	});
$('#this_reset_form').click(function() { 
	$('#share_this_stuff_container_thankyou').hide();
	$('#share_this_stuff_container_thankyou success').hide();
	$('#share_this_stuff_container_thankyou failure').hide();
	$('#share_this_stuff_container').show();
	return false;
});	
	
	$('#share_this').click(function() {
		q = new Array();
		$('#search_form_tag input').each(function(i) { 
			q[i] = $(this).val(); 
		});
		from_email = $('#share_this_from').val();
		to_email = $('#share_this_to').val();
		 
		
		
		
		var data_string = "q1=" + q[0] + "&q2=" + q[1] + "&q3=" + q[2] + "&to_email=" + to_email + "&from_email=" + from_email;
		//alert(data_string);
		$.ajax({
   			type: "POST",
			url: "actions/send.php",
			data: data_string,
			success: function(msg){
				$('#share_this_stuff_container').hide();
				$('#share_this_stuff_container_thankyou').show();
				$('#share_this_stuff_container_thankyou #failure').hide();
				$('#share_this_stuff_container_thankyou #success').show();
				
								
			},
			error: function(msg){ 
				$('#share_this_stuff_container').hide();
				$('#share_this_stuff_container_thankyou').show();
				$('#share_this_stuff_container_thankyou #success').hide();
				$('#share_this_stuff_container_thankyou #failure').show();

			}
		 });
		return false;
	
	});
	

	
	
	
	
	
	
});//end docready
