// modules.garnier.lib.js.jquery-search-1-fr-fr 

var Context = {"W_HOST_PREFIX":"http:\/\/","W_HOST":"www.garnier-thiebaut.fr","UIHOST_PREFIX":"http:\/\/","UIHOST":"www.garnier-thiebaut.fr","UIBASEURL":"http:\/\/www.garnier-thiebaut.fr","LOG_LEVEL":3000,"DEV_MODE":false,"inDragSession":false,"RICHTEXT_PRESERVE_H1_TAGS":false,"CHROME_BASEURL":false,"CONTROLLER":"http:\/\/www.garnier-thiebaut.fr\/xul_controller.php","LANGS":{"fr":{"label":"Fran\u00e7ais"},"en":{"label":"Anglais"},"de":{"label":"Allemand"}},"W_LANG":"fr","W_UILANG":"fr"};

var K = {"WEBEDIT_MODULE_ACCESSOR":"wemod","COMPONENT_ACCESSOR":"cmp","COMPONENT_ID_ACCESSOR":"cmpref","COMPONENT_LANG_ACCESSOR":"lang","GENERIC_MODULE_NAME":"generic","PARENT_ID_ACCESSOR":"parentref","VALUE_ACCESSOR":"value","LABEL_ACCESSOR":"label","TREE_FILTER":"treeFilter","LANG_ACCESSOR":"lang","FULL_TREE_CONTENT_ACCESSOR":"fullTreeContent","LINKED_COMPONENT_ACCESSOR":"lnkcmp"};
var guideSearch = 
{	
	request: '',
	initialize : function()
	{
		$("div.modules-garnier-search input.rc").hide();
	
		$("div.modules-garnier-search ul.coloris li input:radio").click(function (){
			$("div.modules-garnier-search ul.coloris li[class='current']").each(function (){
				$(this).removeClass('current');
			});
			
			var checked = $(this).is(':checked');
			if(checked)
			{
				$(this).parent().addClass('current');
			}
		});
		
		$("div.modules-garnier-search input").each(function (){
			$(this).click(function(){
				guideSearch.deactivateAll();
				guideSearch.retrieveAll();				
			});
		});		
	},
	retrieveAll : function()
	{
		guideSearch.request = "garnierParam[lang]="+$("div.modules-garnier-search input#garnier_search_lang").val()+"&";
		
		$("div.modules-garnier-search input:checked").each(function (){
			var name = $(this).attr('name');
			var value = $(this).attr('value');
			
			guideSearch.request += name+"="+value+"&";
		});
		
		guideSearch.send();
	},
	activateAll: function()
	{
		$("div.modules-garnier-search input").each(function (){
			$(this).removeAttr('disabled');
		});				
	},
	deactivateAll: function()
	{
		$("div.modules-garnier-search input").each(function (){
			$(this).attr('disabled', 'true');
		});		
	},
	displayLoader: function()
	{
		$("div.modules-garnier-searchresult div.searchresults").html('');
		$("div.modules-garnier-searchresult div.searchresults").html('<div class="loader"><img src="../../media/frontoffice/loadingAnimation.gif" /></div>');				
	},
	send: function()
	{	
		guideSearch.displayLoader();		
		
		$.get('/index.php?module=garnier&action=Search&' + guideSearch.request, null, function(data){	  		
	  		$("div.modules-garnier-searchresult").html(data);
	  		guideSearch.activateAll();
		});
	}
}

$(document).ready(function(){
	guideSearch.initialize();
});


