
InputWrapper = function ()
{
	
	this.hideOrShowCleaner = function (obj)
	{
		if($(obj).val()=='' || $(obj).val()==$(obj).attr('title'))
		{
			
			$(obj).removeClass("notempty");
		}
		else
		{
			$(obj).addClass("notempty");
			
		}
	}
	this.clearAll = function (type)
	{
	    
	  if(type == 'mobile')
	      {
		  $('div.selectbox-wrapper ul li').eq(0).click();
	      } else if ( type == 'landline')
		  {
		      $('div.selectbox-wrapper ul li').eq(1).click();
		  }
		  else if (type == 'internet')
		      {
			   $('div.selectbox-wrapper ul li').eq(2).click();
		      }
		      else if (type == 'mobileinternet')
			  {
			      $('div.selectbox-wrapper ul li').eq(3).click();
			  }
			  else if (type == 'tv')
			      {
				   $('div.selectbox-wrapper ul li').eq(4).click();
			      }
		

	}
	this.registerEvents = function (selector)
	{
		
		$(selector).focus(function()
		{
			if($(this).val()==$(this).attr('title'))
			{
				$(this).val('');
			}
		});


		$(selector).blur(function()
		{
			if($(this).val()=='')
			{
				$(this).val($(this).attr('title'));
			}
		});


		$(selector).each(function()
		{
			inputWrapper.hideOrShowCleaner(this);
			
			if($(this).val()=='')
			{
				$(this).val($(this).attr('title'));
			}
		});


		$(selector).keyup(function()
		{
			inputWrapper.hideOrShowCleaner(this);
		}).change(function()
		{
			inputWrapper.hideOrShowCleaner(this);
		});
		
		
		
		
		// czyszczenie onSubmit
		$('form').each(function ()
		{
			if($('.inputWrapper', this).is('.inputWrapper'))
			{
				$(this).submit(function ()
				{
					$('.inputWrapper input', this).each(function ()
					{
						if($(this).val()==$(this).attr('title'))
						{
							$(this).val('');
						}
					})
				});
			}
		});
		
	}
}



$(document).ready(function ()
{
	inputWrapper = new InputWrapper();
	
	inputWrapper.registerEvents('input.gray');
	
});







