/**
 * Search
 *
 */
$(document).ready(function() {	
	//$("#searchform").validate();
	$("#searchform").submit(function(){
		var param= $("#q").val();
		if(param=="")
		return false;
		else
		return true;
	});
	$("#CloseBloc").click(function(e){
		e.preventDefault();
		//$("#ProdFiche_id").hide("slow");
			var selectedEffect = 'fade';
	var options = {};
	$( "#ProdFiche_id" ).hide( selectedEffect, options, 500, callback );
	});
})
function callback() {
			return false;			
		};

function searchLocation()
{
	q = searchslug($('#searchform #q').val());
	//alert(q );
	document.location.href=''+Croogo.basePath+'search/q:'+encodeURI(q);
}
/**
 * Slug function for search
 * 
 * @version 1.0
 * @author wissem
 * @param {string} str
 * @return string 
 */
function searchslug(str) {
  var from = "ÀÁÂÃÄÅĄÒÓÔÕÖØÈÉÊËĘĚİÌÍÎÏÇĊÙÚÛÜÑŃŒłŁŚŞŻŹŽĞБбàáäâèéëêìíïîòóöôùúüûñç·/_,:;®©";
  var to   = "AAAAAAAOOOOOOEEEEEEIIIIICCUUUUNNELLSSZZZGGGaaaaeeeeiiiioooouuuunc--------";
  for (var i=0, l=from.length ; i<l ; i++) {
    str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
  }
 
  str = str.replace(/^\s+|\s+$/g, '+'); // trim
  str = str.replace(/[^a-zA-z0-9 -]/g, '+') // remove invalid chars
    .replace(/\s+/g, '+') // collapse whitespace and replace by -
    .replace(/-+/g, '+'); // collapse dashes

  return str;
}
