//##ALLCOUNTRY
function showSearchExt()
{ 
  ctrl=document.getElementById('sa');
  if ( ctrl.style.display=='none' ) ctrl.style.display = "";
  else ctrl.style.display = "none";
}
function showForm(val)
{ 
  for (i=1;i<3;i++)
    {
	  if ( i!=val )
	   {
	    ctrl=document.getElementById('search'+i);
	    ctrl.style.display='none';
	    ctrl=document.getElementById('ans'+i);
		ctrl.style.fontWeight='';
	   }	  
	} 
  ctrl=document.getElementById('search'+val);
  ctrl.style.display = '';
  ctrl=document.getElementById('ans'+val);
  ctrl.style.fontWeight='bold';
  Set_Cookie( 'searchForm', val, '', '/', '', '' );
}

function loadCategorieSearch(val,selval)
{  
  setListTaille(val,true,selval);
}

function checkCategorie(val)
{	
  ctrl=document.getElementById('optpiece');
  ctrltaille=document.getElementById('opttaille');
  if ( ctrl )
   {
     (val>=100 && !(val>=200 && val<299) ) ? ctrl.style.display = "" : ctrl.style.display = "none";
   }
  (!val) ? ctrltaille.style.display = "none" : ctrltaille.style.display = ""; 
  setListTaille(val,false,'');
}
function setListTaille(val,flg,selval)
{
  callMakeList('taille',val,'taille_liste.php','select',flg,selval);
}

function callMakeList(idctrl,val,srcphp,type,selected,selectedvalue) 
{	
	var xhr_object = null;

	if (window.XMLHttpRequest) // Firefox
	   xhr_object = new XMLHttpRequest();
	else if (window.ActiveXObject) // Internet Explorer
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
	   xhr_object = null;
	   return;
	}
	
	var data = "q=" + val;   
    url='ajax/'+srcphp;
    
    xhr_object.open("POST", url, true);
	
	xhr_object.onreadystatechange = function() {   	   
		if ( document.getElementById(idctrl) )
		 {		  
		   if(xhr_object.readyState == 4 ) 
			 {  
			   if ( type=='select') 
			    {
                  var options=xhr_object.responseText.split(";");
                  var item,option;
			      ctrl=document.getElementById(idctrl);
			      ctrl.innerHTML="";
			      for (var i=0; i<options.length-1; i++)
			       {			       			         
			         item=options[i].split("=");
			         ctrl.options[i] = new Option(item[1],item[0]);	  
                     if ( selected==true && selectedvalue.length>0 && selectedvalue==item[0] )
                      {
                        ctrl.options[i].selected=true;
                      }                   	         
			       }
			    }
			   else 
			    {
                 document.getElementById(idctrl).innerHTML =  xhr_object.responseText;
                }
             }   
		 }
	}   
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send(data);
}
