(function( $ ) {

	var defaults = {
		'r': '4px'
	}
	
	var options = $.extend(defaults, options);
	
	var methods = {

		init : function( rds ) {
			var rd;
			if ( rds && typeof rds === 'number' ) {
				rd = rds + "px";
			} else {
				rd = options.r;
			}

			this.each(function() {
				$(this).css({
					'-moz-border-radius': 		rd, // Firefox
					'-webkit-border-radius': 	rd, // Safari, Chrome
					'border-radius': 			rd
				});
			});
		},
		top : function( rds ) {
			var rd;
			if ( rds && typeof rds === 'number' ) {
				rd = rds + "px";
			} else {
				rd = options.r;
			}
			
			this.each(function() {
				$(this).css({
					'-moz-border-radius': 		rd + ' ' + rd + ' 0 0',
					'-webkit-border-radius': 	rd + ' ' + rd + ' 0 0',
					'border-radius': 			rd + ' ' + rd + ' 0 0'
				});
			});
		},
		right : function( rds ) {
			var rd;
			if ( rds && typeof rds === 'number' ) {
				rd = rds + "px";
			} else {
				rd = options.r;
			}
			
			this.each(function() {
				$(this).css({
					'-moz-border-radius': 		'0 ' + rd + ' ' + rd + ' 0',
					'-webkit-border-radius': 	'0 ' + rd + ' ' + rd + ' 0',
					'border-radius': 			'0 ' + rd + ' ' + rd + ' 0'
				});
			});
		},
		bottom : function( rds ) {
			var rd;
			if ( rds && typeof rds === 'number' ) {
				rd = rds + "px";
			} else {
				rd = options.r;
			}
			
			this.each(function() {
				$(this).css({
					'-moz-border-radius': 		'0 0 ' + rd + ' ' + rd,
					'-webkit-border-radius': 	'0 0 ' + rd + ' ' + rd,
					'border-radius': 			'0 0 ' + rd + ' ' + rd
				});
			});
		},
		left : function( rds ) {
			var rd;
			if ( rds && typeof rds === 'number' ) {
				rd = rds + "px";
			} else {
				rd = options.r;
			}
			
			this.each(function() {
				$(this).css({
					'-moz-border-radius': 		rd + ' 0 0 ' + rd,
					'-webkit-border-radius': 	rd + ' 0 0 ' + rd,
					'border-radius': 			rd + ' 0 0 ' + rd
				});
			});
		}
	};
	
	$.fn.roundmycorner = function( method ) {
		 // Method calling logic
		if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			return methods.init.apply( this, arguments );
		} else if ( typeof method === 'number' ) {
			return methods.init.apply( this, arguments );
		} else {
			$.error( 'Method ' +  method + ' does not exist on jQuery.roundmycorner' );
		}
	};

})(jQuery);
