//
// 
//  jquery.mnk-utils.js
//
//  Created by  on 2010-12-12.
//  Copyright (c) 2010 murat n konar. All rights reserved.
//


(function($){
	
	// --------------------------------------------  
	// calculate the center (in doc coords) of the 
	// first matched element
	// --------------------------------------------  
	$.fn.calcCenter = function() {  
		$element = $(this[0])
		var element_offset = $element.offset()
		var element_center = {x:element_offset['left'] + $element.outerWidth()/2, y:element_offset['top'] + $element.outerHeight()/2}
		
		return element_center
	};  


	// --------------------------------------------  
	// calculate the right coordinate (in doc coords)
	// of the first matched element
	// --------------------------------------------  
	$.fn.calcCoords = function() {  
		$element = $(this[0])
				
		var element_offset 	= $element.offset()
		var left 			= element_offset['left']
		var top 			= element_offset['top']
		var right 			= left + $element.outerWidth()
		var bottom 			= top + $element.outerHeight()
		
		var element_coords = {'left':left, 'right':right, 'top':top, 'bottom':bottom, 'width': right-left, 'height':bottom-top}
		
		return element_coords
	};  


})(jQuery);



