/*  
	Auteur : salima YAHIAOUI
	Date : 11/09/2009
*/
//Au chargement de la page
$(document).ready(function(){
 
	//formulaire recherche
	$("#searchSelect").change(function(){
		$("#CategorieID").val($("#searchSelect :selected").val());
	});	
	// Bouton ok, recherche par univers dans le header
	$("#searchProduct").click(function(){
		searchSwitch();
	});
	
	
	
});

//fonction executee lors d'un click dans le bandeau recherche

function searchSwitch(){
	keyword = $("#Rechercher").val() ;

	keyword = deleteSpecialCaracteres(keyword);
	keyword = noaccent(keyword);
	keyword = noSpecialChar(keyword);

	catalogueID = $("#CatalogueID").val() ;
	if (keyword != 'Rechercher un produit' && keyword != ""){		
		window.location.href = PATHRACINE+"/SwitchSearch?StoreID=1&LangueID=1&CatalogueID=" + catalogueID + "&TypeID=1&search="+keyword+"&CategorieID=10000";

		return true;	
	}
}

function deleteSpecialCaracteres(search){
	search = search.replace('&', '').replace('~', '')
					.replace('\'', '').replace('#', '')
					.replace('{', '').replace('}', '')
					.replace('(', '').replace(')', '')
					.replace('[', '').replace(']', '')
					.replace('^', '').replace('%', '')
					.replace('*', '').replace('¨', '');
	return search;
}

function noaccent(chaine) {
	  temp = chaine.replace(/[àâä@]/gi,"a");
	  temp = temp.replace(/[éèêë]/gi,"e");
	  temp = temp.replace(/[îï]/gi,"i");
	  temp = temp.replace(/[ôö]/gi,"o");
	  temp = temp.replace(/[ùûü]/gi,"u");
	  temp = temp.replace(/[ç]/gi,"c");
	  return temp;
}

function noSpecialChar(chaine) {
	  temp = chaine.replace(/[µ£$¤°§.;,<>+\'\"\!\?€¨^+]/gi," ");
	  return temp;
}

