function replaceAll( text, busca, reemplaza ){
  while (text.toString().indexOf(busca) != -1)
      text = text.toString().replace(busca,reemplaza);
  return text;
}

$(function() {
	$.path = '/';
	
	$('.searchinput').live("focus.placeholder", function(event) {
 		if ($(this).val() === $(this).attr("rel"))
 			$(this).val("");
 	});

 	$('.searchinput').live("blur.placeholder", function(event) {
 		if ($(this).val() === "")
 			$(this).val($(this).attr("rel"));
 	});

 	$('.searchform form').submit(function(e){
 		var input = $(this).find('.searchinput');
 		
 		if(input.val() == "" || input.val() == input.attr('rel')) return false;
 			location.href = $.path + 'buscar/' + replaceAll(input.val()," ", "_") + "/";
 		
 		return false;
 	});
 	
});

