(function($){

$(function(){
	if (!($.browser.msie && $.browser.version == '6.0')) {
		$('button.button, input.button').each(function(){
			var $this = $(this);
			var htmlClass = $this.attr('class');
			
			var html = '<a href="javascript:void(0);" class="%s" id="%s"><span>%s</span></a>';
			var id = $this.attr('id') + '-custom';
			
			if ($this[0].tagName.toLowerCase() == 'button') {
				var text = $this.text();
			} else {
				var text = $this.attr('value');
			}
			
			html = html.replace('%s', htmlClass).replace('%s', id).replace('%s', text);
			
			if (!$this.hasClass('tight')) {
				html = '<div class="button">' + html + '</div>';
			}
			
			$this.after(html).css('position', 'absolute').css('top', '-10000px').attr('tabindex', -1);
			
			$('#' + id).click(function(){
				if ($this[0].tagName.toLowerCase() == 'input' && $this.attr('type') == 'submit') {
					$this.parents('form:first').submit();
				} else {
					$this.click();
				}
			});
		});
	}
});

})(jQuery);
