/*
function block(prop, val, style) {
	// this  -> object, the current element
	// prop  -> string, the name the css property
	// val   -> string, the value of the css property
	// style -> object, getComputedStyle or currentStyle (optional)
}
*/

(function($){
	
	function to_camel(prop) {
		return prop.replace(/\-(\w)/g, function(m, c){
			return c.toUpperCase();
		});
	}
	
	function to_hyphen(prop) {
		return prop.replace(/([A-Z])/g,"-$1").toLowerCase();
	}
	
	function toString() {
		var r = '';
		for(var prop in this)
			if(!this[prop].apply && this.hasOwnProperty(prop))
				r += to_hyphen(prop) + ": " + this[prop] + "; \n";
		return r;
	}
	
	$.cssText = function(elem, props, block) {
		
		var hash = { toString: toString	},
			style = (document.defaultView && document.defaultView.getComputedStyle && document.defaultView.getComputedStyle(elem, null)) || elem.currentStyle,
			display = (style && style.getPropertyValue && style.getPropertyValue('display')) || (style && style['display']) || 'none'; 
		
		elem.style.display = 'block';
		
		style = style || (document.defaultView && document.defaultView.getComputedStyle && document.defaultView.getComputedStyle(elem, null)) || elem.currentStyle;
	
		for(var i = 0; props[i]; i++) {
				
			var prop = props[i], 
				camel = to_camel(prop), 
				hyphen = to_hyphen(prop), 
				val = null;
					
			if(prop == 'display') val = display;				
			if(prop == 'float')	val = style['styleFloat'];
			if(prop == 'opacity' && jQuery.browser.msie) val = jQuery.attr(elem.style, prop);
			val = val || (style.getPropertyValue && style.getPropertyValue(hyphen)) || style[camel];
			
			hash[prop] = (block && block.apply(elem, [prop, val, style])) || val;
	
		}
		
		elem.style.display = '';
		
		return hash;
						
	};	
	
})(jQuery);