/**********************************************
 * Copyright (c) 2009 Christian Paulus - http://www.quesaco.org
 * Dual licensed under the MIT and GPL licenses.
 **********************************************/

// $LastChangedBy: cpaulus $
// $LastChangedDate: 2011-01-09 12:23:22 +0100 (Sun, 09 Jan 2011) $


(function($) {

	// attendre document chargé 
	$(document).ready(function() {
		
		// prendre l'objet déclaré 
		chrec = (window.chrec);
		
		chrec.debug = chrec.debug && window.console;
		chrec.debug && console.debug('Init chrec Ok');
			
		chrec.id = $('#recherche');
		chrec.icon = 'url('+chrec.icon+')';
		
		$.fn.extend({
			chrec_bg: function(bg){
				$(this).css('backgroundImage', bg);
			},
			chrec_show: function(){
				// si champ vide
				if(!$(this).val()) {
					// afficher la petite loupe
					chrec.id.chrec_bg(chrec.icon);
					//chrec.debug && console.debug(chrec.icon);
				}
			}
		});

		// afficher la petite loupe
		chrec.id.chrec_show();
		
		// si focus, cacher la loupe
		chrec.id.focus(function () {
			$(this).chrec_bg('none');
		});
		
		// si sort du focus
		chrec.id.blur(function () {
			$(this).chrec_show();
		});
		
		
		// si bords arrondis
		if(chrec.rounded == 'on') {
			// ajouter la hauteur des div nécessaires
			$('#divrecherche').height( $('#divrecherche').height() + 2);
		}

	});
	
})(jQuery);
