
function find_label() {

	return $("label").filter(function (index) {
                  return $(this).attr("for") == "field26";
                });
}

function checkOui() {

	label = find_label();

	if ($('#wb_Oui').attr("checked") == undefined) {
		$('#field26').hide();
		$(label).hide();
	}
	else {
		$('#field26').show();
		$(label).show();
	}
}


function resize(selectId, size){
    var objSelect = document.getElementById(selectId);
    var maxlength = 0;
    if(objSelect){
        if(size){
                objSelect.style.width = size;
        } else {
                for (var i=0; i< objSelect.options.length; i++){
                        if (objSelect[i].text.length > maxlength){
                                maxlength = objSelect[i].text.length;
                        }
                }
                $(objSelect).width(maxlength * 7);

        }
    } 
}

$(document).ready(function() {
	
	$('#PST_mobile2').click(function(){
		for(i=0;i<23;i++) {
			
			$('#PST_region_'+i).attr('disabled','disabled');
		}
	});
	
	$('#PST_mobile1').click(function(){
		for(i=0;i<23;i++) {
			$('#PST_region_'+i).removeAttr('disabled');
		}
	});
	

	$('.dir ul').attr('style', 'display:none;');

	$('.dir').hover(function() {
		$(this).find('ul').attr('style', 'display:default;');
	}, function() {
		$(this).find('ul').attr('style', 'display:none;');
	});
	
	$('#mainNav ul ul li').hover(function() {
		$(this).attr('style', 'background-color: #1f4569');
	},
	function() {
		$(this).attr('style', 'background-color: #0062ab');
	});
	
	// Tableau une ligne sur deux
    $('body.fiche table tr:even', this).addClass('coul1');
    
    checkOui();
    
    $('#wb_Oui').click(function() {
		checkOui();
	});
	
	 $('#wb_Non').click(function() {
		checkOui();
	});
	
	$('#DEP').click(function(){
			resize($(this).attr("id"));
		});
			
	$('#DEP').blur(function(){
		resize($(this).attr("id"), '140px');
	});
    
});
