$(document).ready(function() {

	//grab all the anchor tag with rel set to shareit
	$('a[rel=shareit]').click(function() {		
		
		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var top = $(this).offset().top - 116;
		
		//get the left and find the center value
		var left = $(this).offset().left + ($(this).width() /2) - ($('#shareit-box').width() / 2);		
		
		
		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height);
		
		//display the box
		$('#shareit-box').show();
		
		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});
		
		//assign the url to the textfield
		$('#shareit-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');
		

		
	});

	//onmouse out hide the shareit box
	$('a[rel=shareit-close]').click(function () {
		$('#shareit-field').val('');
		$('#shareit-box').hide();
	});
	
});
