/*-------------------------------------------------------------------- 
 * javascript method: "pxToEm"
 * by:
   Scott Jehl (scott@filamentgroup.com) 
   http://www.filamentgroup.com
 *
 * Copyright (c) 2007 Filament Group
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Description: Extends the native Number and String objects with pxToEm method.
	 								pxToEm converts a pixel value to ems depending on inherited font size.  
 * Options:  	 								
 		Scope: string or jQuery Element for font-size scoping
 		reverse: Boolean, true reverses the conversion to em-px
 * Dependencies: jQuery library						  
 * Usage Example: myPixelValue.pxToEm(); or myPixelValue.pxToEm({'scope':'#navigation', reverse: true});
 * Version: 1.0, 08.02.2007
 * Changelog:
 *  08.02.2007 initial Version 1.0
--------------------------------------------------------------------*/



	Number.prototype.pxToEm = String.prototype.pxToEm = function(settings){
			//set defaults
			settings = jQuery.extend({
				scope: 'body',
				reverse: false
			}, settings);
			
			var pxVal = (this == '') ? 0 : this;
			if(pxVal.constructor == String) pxVal = parseInt(pxVal);
			
			var scopeVal = parseInt(jQuery(settings.scope).css("font-size"));
			var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em';
			return result;
	};
