﻿(
	function ($) {

		var defaultOptions = {
			horizontalMargin: 5
		};

		$.fn.simpleTransform = function (customOptions) {
			var options = $.extend({}, defaultOptions, customOptions);
			return this.filter('input:text, input:password, textarea, select').each(
				function () {
					var $this = $(this);
					if (!$this.hasClass('st-done')) {
						$this
							.addClass('st-done')
							.css({ 'margin': 0, 'padding': 0, 'border': 'none', 'background-color': 'transparent', 'outline': 'none', 'resize': 'none' });
						var width = $this.innerWidth();
						var variance = 0;
						if ($this.is('select')) {
							$this.css('margin', '-1px');
							variance = 2;
						}
						$this
							.width((width + variance) - (options.horizontalMargin * 2))
							.wrap('<div class="st-wrapper" style="width: ' + width + 'px;"></div>')
							.parent()
							.prepend('<div class="st-box"><div class="st-top-outer st-outer st-box"><div class="st-top-inner st-inner st-box"></div></div></div>')
							.append('<div class="st-bottom-wrapper st-box"><div class="st-bottom-outer st-outer st-box"><div class="st-bottom-inner st-inner st-box"></div></div></div>');
						$this.wrap('<div class="st-edge"><div class="st-middle-outer st-outer st-edge"><div class="st-middle-inner st-inner"></div></div></div>');
					}
				}
			);
		}

	}
)(jQuery);
