/*jshint asi: false, bitwise: true, boss: false, curly: true, debug: false, devel: false, eqeqeq: true, evil: false, forin: true, immed: true, laxbreak: false, newcap: true, noarg: true, noempty: true, nonew: true, nomen: true, onevar: true, plusplus: true, regexp: false, undef: true, sub: false, strict: true, white: false*/
/*global jQuery, console, baseUrl, window, document */
(function ($) {
	"use strict";
	var input;
	
	// Inputs
	window.input	=
	input		=	{
		"placeHolder":	function ( ) {
			var $this		=	$(this),
			    placeholder		=	$this.data("placeholder"),
			    $placeholder	=	placeholder ? $("<div/>").addClass("placeHolder").text(placeholder).append($("<span/>").addClass("arrow")) : false;
			
			$this.bind("focus", function ( ) {
				$this.removeClass("invalid");
			});
			
			if (placeholder) {
				if (!$this.val()) {
					$this.val(placeholder);
				}
				
				$this.bind("focus", function ( ) {
					var left	=	$this.offset().left + $this.outerWidth(true);
					
					$placeholder.appendTo("body");
					
					// Collision detection
					if ((left + $placeholder.outerWidth(true)) > $(window).width()) {
						$placeholder.addClass("collision");
						left	=	$this.offset().left - $placeholder.outerWidth(true);
					} else {
						$placeholder.removeClass("collision");
					}
					
					$placeholder.css({
						"top":		$this.offset().top,
						"left":		left
					});
					
					$placeholder.fadeIn(300);
					
					if ($this.val() === placeholder) {
						$this.val("");
					}
				});
				
				$this.bind("blur", function ( ) {
					$placeholder.fadeOut(300);
					if (!$this.val()) {
						$this.val(placeholder);
					}
				});
			}
		},
		"resize":	function ( ) {
			var $this		=	$(this),
			    mustResize		=	$(this).data("resize");
			
			if (mustResize !== false) {
				$(this).width(TOOLS.width100pc.apply(this));
			}
		},
		"required":	function ( ) {
			var $this		=	$(this),
			    nodeName		=	this.nodeName.toLowerCase(),
			    type		=	$this.attr("type"),
			    isRequired		=	$this.data("required"),
			    isTextInput		=	(nodeName === "input" && type === "text"),
			    isCheckbox		=	(nodeName === "input" && type === "checkbox"),
			    isRadio		=	(nodeName === "input" && type === "radio"),
			    isSelect		=	(nodeName === "select"),
			    isTextarea		=	(nodeName === "textarea");
			
			if (isRequired) {
				
			}
		}
	};
}(jQuery));

