//Mais c'est totomatik !

var clk=new Array();

function affiche_info_fiche_article(obj,provenance)
{
	if(provenance=='fiche_article')
		var tab=eval('('+obj.responseText+')');
	else
		var tab=obj;
	for(k in tab)
	{
	   //Si c'est un objet
		if($('.obj_'+k).length>0)
		{

			$('.obj_'+k).each(function(){
			
			   var typeObj=$(this).get(0).nodeName;

			   switch(typeObj)
			   {
					case 'DIV':
						$(this).html(tab[k]);
					break;
					case 'SPAN':
						$(this).html(tab[k]);
					break;
					case 'INPUT':
						$(this).val(tab[k]);
					break;
					case 'META':
						$(this).attr({'content':tab[k]});
					break;
					case 'SELECT':
					   //alert('SEL');

					   $(this).find('option').each(function(i){

					      if($(this).attr('value')==tab[k])
					      {
					         $(this).attr('selected','selected');
					      }
					      else
					      {
					         $(this).attr('selected',false);
					      }
						});

					break;
					default:
						$(this).html(tab[k]);
					break;
				}
			});
		}

		if($('.clk_'+k).length>0)
		{
		
		   if(window.execScript)
			{
		   	clk[k]=new Function(tab[k]);
		   }
		   else
		   {
		   	clk[k]=eval("(function(){"+tab[k]+"})");
		   }
		   
			$('.clk_'+k).each(function(){
				$(this).unbind('click');

				//Ajoute le click
				$(this).click(clk[k]);
			});
		}
		
		if($('.blk_'+k).length>0)
		{
		
			$('.blk_'+k).hide();
		
			$('.blk_'+k).each(function(){
			
			   var valeur=$(this).attr('valeur');

				if(!valeur)
				{
				   alert('Missing valeur of "'+k+'"');
				}

			   //Si plusieurs valeurs différentes dans v :
			   values=valeur.split('|');

			   for(iV in values)
			   {

				   var v=values[iV];

					var changement=false;

				   if(v.substring(0,1)=='>')
				   {
						changement=true;

						//Tester le second paramètre
						if(v.substring(1,2)=='=')
						{
					      if(parseInt(tab[k])>=parseInt(v.substring(2)))
					      {
						      $(this).show();
					      }
					      else
							{
						      //$(this).hide();
							}
						}
						else
						{
					      if(parseInt(tab[k])>parseInt(v.substring(1)))
					      {
						      $(this).show();
					      }
					      else
							{
						      //$(this).hide();
							}
						}
				   }

				   //S'il n'y a pas eu encore de changements
					if(!changement)
					{
					   if(v.substring(0,1)=='<')
					   {
							changement=true;

							//Tester le second paramètre
							if(v.substring(1,2)=='=')
							{
						      if(parseInt(tab[k])<=parseInt(v.substring(2)))
						      {
							      $(this).show();
						      }
						      else
								{
							      //$(this).hide();
								}
							}
							else
							{
						      if(parseInt(tab[k])<parseInt(v.substring(1)))
						      {
							      $(this).show();
						      }
						      else
								{
							      //$(this).hide();
								}
							}
					   }
					}

					if(!changement)
					{
					   if(v.substring(0,1)=='=')
					   {

							changement=true;
					      if(parseInt(tab[k])==parseInt(v.substring(1)))
					      {
						      $(this).show();
					      }
					      else
							{
						      //$(this).hide();
							}
					   }
					}

					//Sinon
					if(!changement)
					{

				   	if(v==tab[k])
					   {
					      $(this).show();
					   }
					   else
					   {
					      $(this).hide();
					   }
					}
				}
			});

		}
		
	}
}
