$(function(){
	$.jCss = {
		_styles:{},
		
		_appends:['filter','-ms-filter'],
		
		_jsonToCss:function(obj){
			var str = '';
			$.each(obj,function(key,val){
				str += key+':'+val+';';
			});
			return str;
		},
		
		_concatStyles:function(selector,obj){
			var scope = this;
			$.each(obj,function(key,val){				
				if(key in scope._styles[ selector ]){
					if(jQuery.inArray(key,scope._appends) == -1){
						scope._styles[ selector ][ key ] = val;
					}else{
						scope._styles[ selector ][ key ] += ' '+val;
					}
				}else{
					scope._styles[ selector ][ key ] = val;
				}
			});
		},
		
		_addStyles:function(selector,obj){
			if(selector in this._styles){
				this._concatStyles(selector,obj);
			}else{
				this._styles[ selector ] = obj;
			}
			
			return this;
		},
		
		_addBgGradient:function(selector,topHex,bottomHex){
			if(navigator.userAgent.search("Firefox") != -1){
				var obj = {
					'background-image':'-moz-linear-gradient(top, '+topHex+', '+bottomHex+')'
				}				
				this._addStyles(selector,obj);
			}else{
				var obj = {
					'background-image':'-webkit-gradient(linear,left bottom,left top,color-stop(0, '+bottomHex+'),color-stop(1, '+topHex+'))'
				}				
				this._addStyles(selector,obj);
			}

			obj = {
				'filter':'filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=\''+topHex+'\', endColorstr=\''+bottomHex+'\')',
				'-ms-filter':'"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=\''+topHex+'\', endColorstr=\''+bottomHex+'\')"'
			}				
			this._addStyles(selector,obj);
		},
		
		_addRoundCorners:function(selector,radius){
			var obj = {
				'-moz-border-radius':radius+'px',
				'-webkit-border-radius':radius+'px',
				'-goog-ms-border-radius':radius+'px',
				'border-radius':radius+'px'
			}
			this._addStyles(selector,obj);
		},
		
		_addSideDropShadow:function(selector,hex){
			var obj = {
				'-moz-box-shadow':'3px -3px 3px '+hex,
				'-webkit-box-shadow':'3px -3px 3px '+hex,
				'box-shadow':'3px -3px 3px '+hex,
				'-ms-filter':'"progid:DXImageTransform.Microsoft.Shadow(Strength=3, Direction=45, Color=\''+hex+'\')"',
				'filter':'progid:DXImageTransform.Microsoft.Shadow(Strength = 3, Direction = 45, Color = \''+hex+'\')'
			}
			this._addStyles(selector,obj);			
		},
		
		_renderStyles:function(){
			var css = '<style type="text/css">\n';
			var scope = this;
			$.each(this._styles,function(selector,style){
				css += selector+'{'+scope._jsonToCss(style)+'}\n'
			});
			css += '</style>';
			$('body').append(css);
		}			
	};

});

