function selzero(id,sel) 
	{
	var liste = $('input[rechav='+sel+']').each(function () 
		{
		$(this).val('');
		rechav(this);
		});
	document.getElementById(id).value='';
	}

function seladd(idt,ids)
	{
	var sel = document.getElementById(ids);
	//if(sel.selectedIndex==0) return ;

	var t = document.getElementById(idt).value;
	var val = sel.options[sel.selectedIndex].text;

	t = t.replace(val+'\n','');;
	t = val + "\n" + t;

	document.getElementById(idt).value = t;
	}

function seladd_all(idt,ids)
	{
	var sel = document.getElementById(ids);
	var t = $('#'+idt).val();

	$(sel).children('option').each(function()
		{
		var val=$(this).val();
		t = t.replace(val+'\n','');;
		t = val + "\n" + t;
		});
	$('#'+idt).val(t);
	}

function seldel(idt,ids)
	{
	var sel = document.getElementById(ids);
	if(sel.selectedIndex==0) return ;

	var t = document.getElementById(idt).value;
	var val = sel.options[sel.selectedIndex].text;

	t = t.replace(val + '\n' ,'');

	document.getElementById(idt).value = t;
	}

$(document).ready(
	function ()
		{
		// gestion des onglets

		$('#tab1').show();
		$("#tabs > ul > li:first-child").addClass("first");
		$("#tabs > ul > li:last-child").addClass("last");
		$("#tabs > ul > li")
			.bind("mouseenter", function () { $(this).addClass("active"); })
			.bind("mouseleave", function () { $(this).removeClass("active"); });

		$('#tabs > ul > li > a').click(
			function()
				{
				$('#tabs div.boite').hide();
				$($(this).attr('href')).show();
				return false;
				}
			);

		// rollhover automatique

		$('#tabs > .boite img')
				.bind('mouseenter',
					function() { $(this).attr('src',($(this).attr('src').replace('-roll','').replace('.png','-roll.png'))); }
					)
				.bind('mouseleave',
					function() { $(this).attr('src',($(this).attr('src').replace('-roll',''))); }
					);

		$.get('dep.cgi','',function(data) {
			var i;
			var rows  = data.split('\n');
			var sel   = document.getElementById('se_dep');
			var color = sel.style.backbroundColor;

			sel.style.backbroundColor = 'gray' ;
			for(i in rows)
				{
				rows[i]=rows[i].replace(/\r/g,'');
				sel.options[sel.options.length] = new Option(rows[i],rows[i],false,false);
				}
			sel.style.backbroundColor = color ;
			} ,'text');


		$.get('vil.cgi','',function(data) {
			var i;
			var rows  = data.split('\n');
			var sel   = document.getElementById('se_vil');
			var color = sel.style.backbroundColor;

			sel.style.backbroundColor = 'gray' ;
			for(i in rows)
				{
				rows[i]=rows[i].replace(/\r/g,'');
				sel.options[sel.options.length] = new Option(rows[i],rows[i],false,false);
				}
			sel.style.backbroundColor = color ;
			} ,'text');


		$.get('rub.cgi','',function(data) {
			var i;
			var rows  = data.split('\n');
			var sel   = document.getElementById('se_rub');
			var color = sel.style.backbroundColor;

			sel.style.backbroundColor = 'gray' ;
			for(i in rows)
				{
				rows[i]=rows[i].replace(/\r/g,'');
				sel.options[sel.options.length] = new Option(rows[i],rows[i],false,false);
				}
			sel.style.backbroundColor = color ;
			$('#comptage').show('slow');
			} ,'text');


		}

	);
	
