function UpdateSelect(aValue,aName,FieldName)
 { 
	
  cont = aValue.length;
  
  var Liste = eval('document.forms[0].'+FieldName);
  
  //Flush le contenu du DDL
  for (i=0;i<Liste.options.length;i++)
  {
   Liste.options[i]=null;        
  }
  
  // Pour une raison inconnue, il reste parfois des items dans le select même après
  // l'Avoir vidé, on recommence la routine et ça le vide pour vrai.
  if (Liste.options.length > 0)
	for (i=0;i<Liste.options.length;i++)
	{
		Liste.options[i]=null;        
	}
 
  //Remplir de DropDown
  for (i=0;i<cont;i++)
  {
   // On n'ajoute pas un item si il est vide.
   if (aName[i] != ""){
	var AddOption = new Option(aName[i],aValue[i]);
	Liste.options[i]=AddOption;
   }
  }
 }
 
 function changeCat(selectValue)
 {

	if (selectValue==214)
		UpdateSelect(arrSubCatIDs214, arrSubCat214, 'selectSubCat');
	else if (selectValue==206)
		UpdateSelect(arrSubCatIDs206, arrSubCat206, 'selectSubCat');
	else if (selectValue==207)
		UpdateSelect(arrSubCatIDs207, arrSubCat207, 'selectSubCat');
	else if (selectValue==208)
		UpdateSelect(arrSubCatIDs208, arrSubCat208, 'selectSubCat');
	else if (selectValue==209)
		UpdateSelect(arrSubCatIDs209, arrSubCat209, 'selectSubCat');
	else{
		if (window.location.toString().indexOf("FR-CA") > -1)
			UpdateSelect(Array(-1, -1), Array('Sous-Cat&eacute;gories', ''), 'selectSubCat');
		else
			UpdateSelect(Array(-1, -1), Array('Sub-Categories', ''), 'selectSubCat');
	}	
 }
 
 
 function coveoSubmit()
 {
	//alert("coveoSubmit");
	//////////////////////////////////////////////////////////////////////////////
	var coveoSearchAddress = "/pages/SearchResults.aspx";
	//////////////////////////////////////////////////////////////////////////////
	
	
	// LANGUE
	var coveoLocation = coveoSearchAddress + "?LANG="
	if (window.location.toString().indexOf("FR-CA") > -1)
		coveoLocation += "FR-CA";
	else
		coveoLocation += "EN-CA";
	
	// QUERY
	if (document.forms[0].query.value == "" || document.forms[0].query.value == "Key Word(s)" || document.forms[0].query.value == "Mot(s) clé(s)")
		coveoLocation += "&q=@uri";
	else	
		coveoLocation += "&q=" + document.forms[0].query.value;
	
	// CUSTOM FIELDS
	if (document.forms[0].selectCat.value > -1 && document.forms[0].selectCat.value != "")
		coveoLocation += " and @Category=" + document.forms[0].selectCat.value;
	if (document.forms[0].selectSubCat.value > -1 && document.forms[0].selectSubCat.value != "")
		coveoLocation += " and @SubCategory=" + document.forms[0].selectSubCat.value;
		
	// SYSLANGUAGE FIELD
	if (window.location.toString().indexOf("FR-CA") > -1)
		coveoLocation += " and @syslanguage=french";
	else
		coveoLocation += " and @syslanguage=english";
		
	// REDIRECTION
	window.location=coveoLocation;
 }
 
function noenter(key_event) 
{
  checkCoveoSubmit(key_event);
  //alert("noenter");
  if (document.all) {
    //Probably Internet Explorer 4 and later
    return !(window.event && window.event.keyCode == 13); 
  }else{ 
	// Probably Netscape 6 and later
	return !(key_event.which && key_event.which == 13);
  }
}

function checkCoveoSubmit(key_event)
{
//	alert("checkCoveoSubmit");
	if (document.all) {
		//Probably Internet Explorer 4 and later
		if (event && event.keyCode == 13){
			coveoSubmit();
		}
		else
			return true;
    }
    else { 
        // Probably Netscape 6 and later
        if (key_event.which == 13)
			coveoSubmit();
		else
			return true;
    }	
}
