/**
 * jQuery Placeholder - jQuery plugin 2.1.1
 * 
 * Copyright (c) 2009 Alexander Zhukov - mellanxollik@mail.ru
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 * To enable, simply set attribute "placeholder" for default value.
 *
 * Example: <input type="text" class="someClassForInput" placeholder="Default value" />
 *
 * Also you can change default text CSS. Class is named "jqueryPlaceholder". One .css is provided with plugin.
 *
 */
$(function(){
	if ($.browser.safari) return;
	$("input[placeholder]").each(function(){ //Processing placeholders for input.texts
		if($(this).val() == '' || $(this).val() == $(this).attr('placeholder')){
			$(this).val($(this).attr('placeholder')).addClass('jqueryPlaceholder');
		}
		$(this).focus(function(){if($(this).val() == $(this).attr('placeholder')){
			$(this).val('').removeClass('jqueryPlaceholder');
		}});
		$(this).blur(function(){if($(this).val() == ''){
			$(this).val($(this).attr('placeholder')).addClass('jqueryPlaceholder');
	   	}});
	});
	$("textarea[placeholder]").each(function(){ //Processing placeholders for textareas
		$(this).html($(this).attr('placeholder')).addClass('jqueryPlaceholder');
		$(this).focus(function(){if(this.value == $(this).attr('placeholder')){$(this).removeClass('jqueryPlaceholder');this.value = '';}});
		$(this).blur(function(){if(this.value == ''){$(this).addClass('jqueryPlaceholder');this.value = $(this).attr('placeholder');}});
	});
	$("form").each(function(){ //Processing "clear on submit" methods
		$(this).submit(function(){
			$(this).find("input").each(function(){
				if($(this).val() == $(this).attr('placeholder')){$(this).val('');}
			});
			$(this).find("textarea").each(function(){
				if(this.value == $(this).attr('placeholder')){this.value = '';}
			});
		});				
	});
});
