(function($) {
	$.fn.progressbar = function() {
		var method = 'init';
		var args = $.makeArray(arguments);
		if (args.length > 0) {
			if (typeof args[0] == 'string' || (typeof method == 'object' && args[0].split) )
					method = args.shift();
		}
		if (typeof methods[method] == 'function') {
			return methods[method].apply(this, args);
		throw 'jquery.fn.progressbar() - Invalid method call: '+method;
		}
	};
	function getVariableType(obj) {
		var type = typeof obj;
		if (type == 'object') {
			if (obj.getDate) return 'Date';
			if (obj.split) return 'String';
		}
		return type;
	}
	
	var methods = {
		init: function(options) {
			options = $.extend({}, $.fn.progressbar.defaults, options);
			return $(this).each(function() {
				this.innerHTML = 'initiated';
				var obj = $(this);
				obj.addClass('progressbar');
				obj.html('<div class="progressbar-bar" style="width: '+options.initialProgres+'%;"/>');
			
			
				obj.css({border: 'solid 1px #ddd'});
				obj.find('.progressbar-bar').css({height: '100%', background: '#aaa'});
				
			});
		}, 
		
		setProgress: function(progress) {
			progress = parseInt(progress);
			return $(this).each(function() {
				var obj = $(this);
				obj.find('.progressbar-bar').css({width: progress+'%'});
			});
		}
	};
	
	$.fn.progressbar.defaults = {
		initialProgress: 0
		
	};

})(jQuery);