// JavaScript Document

function setAutoSearch(){ 
	
	var s = $("#search");
	
	if( ( s.val() =='' ) && ( s.attr('title') != '' ) ){
		s.val( s.attr( 'title' ) ).addClass('defaultInput');
	}

	if( s.val() == s.attr('title') ) {
		s.addClass( 'defaultInput' );
	}
	
	if(s.val() != "" && s.val() != s.attr('title')){
		$("#clear").show().bind('click', function() {
			s.val('');
			$(this).hide();
		});
	}

s.focus(function(){
						   
	if( $(this).val()== $(this).attr('title') ){
		$(this).val('').removeClass('defaultInput');
		$(this).focus();
	}
	
});

s.blur(function(){

	if(!$(this).val().length){
		$(this).val( $(this).attr( 'title' ) ).addClass('defaultInput');
	}
	else {
		if( $(this).val() != $(this).attr("title") ){
			$(this).removeClass('defaultInput');
		}
	}

});

s.keyup(function(){
	if( $(this).hasClass('defaultInput') || !$(this).val().length){
		$("#clear").hide().unbind('click');
	} else{
		$("#clear").show().bind('click', function() {
			s.val('');
			$(this).hide();
		});
	}
});
}
