/*
 * jquery.placeholder - A plugin for select fields
 * Written by Ben McFarlin (ben dot mcfarlin AT blinkcorp DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 11/23/2009
 * there is no placeholder support in ie or firefox so we must add it
 *
 * @author Ben McFarlin
 * @version 1.0.0
 */
(function($) {
	$.fn.placeholder = function(settings) {
		var config = {};
		if (settings) $.extend(config, settings);

		return this.each(function(i, self) {
			switch($(self).tagName()){
				case 'input':
				case 'textarea':
					if(jQuery.browser.msie || jQuery.browser.mozilla){
						$(self).after($('<span>').addClass('placeholder-text').css({position:'absolute',display:'inline-block','margin-left':'4px','margin-top':'2px','text-indent':($(self).val() == '')?'0':'-10000px',top:$(self).position().top,left:$(self).position().left,color:'#a1a1a1'}).html($(self).attr('placeholder')));
			      $(self).focus(function(){$(self).next().css('text-indent', '-10000px');});
			      $(self).blur(function(){if($(self).val() == '') {$(self).next().css('text-indent', '0');}});
						$(self).next().click(function(){$(self).focus();});
					}
				break;
				case 'select':
					//$(self).prepend($('<option>').attr('value','').html($(self).attr('placeholder')));
					$(self).html($('<option>').attr('value','').html($(self).attr('placeholder')).outerHTML() + $(self).html());
					//$(self).children(':first').before($('<option>').attr('value', '').html($(self).attr('placeholder')));
					$(self).css('color', ($(self).val() == '')?'#919191':'#313131').children('option').each(function(i, option){$(option).css('color', ($(option).attr('value') == '')?'#919191':'#313131');});
					$(self).change(function(){$(self).css('color', ($(self).val() == '')?'#919191':'#313131');});
					trace($(self).children(':selected').length);
				break;
			}
			return $(self);
			// ok you need to get the placeholder text
			// then create the div
			// then append it after the element
			// position it
		});

		function trace(s){
			if(window.console) window.console.log(s);
		}
	};
 })(jQuery);




