function select_value(a, b){ 
	if(a!=-1){
		document.getElementById(b).innerHTML=a;
	}else{
		document.getElementById(b).innerHTML="";
	}	
}

function display_menu(sId,sId2){
	var oStyle = document.getElementById(sId).style;
	var oStyle2 = document.getElementById(sId2).style;
		
	if (oStyle.display == "none"){
		oStyle.display = "block";
		oStyle2.display = "none";
	}
	else {
		oStyle.display = "none";
	}
	
	//opacity(sId, 0, 100,300);
}


// Fade Effects
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;
    
    //if the element has an opacity set, get it
    if(document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }

    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
} 

function init_opacity(){
	document.getElementById("menu_presentation").style.opacity=0
}

// fonction qui vide un dropdown

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1; i>=0; i--)
	{
		selectbox.remove(i);
	}
}

// fonction qui cré remplit un dropdwon
function createBesoinDropdown(){
	removeAllOptions(document.getElementById("select_besoin"));
	var option;
	var label;
	var remplir = true;

	
	if(document.getElementById("select_client_type").value=="Particuliers"){
			var option=new Array("Automobile","Multirisque","Santé","Vie");
			var label=new Array("Automobile","Multirisque","Santé","Vie");
	
	}
	else if(document.getElementById("select_client_type").value=="Professionnels"){
			var option=new Array("Automobile","Multirisque");
			var label=new Array("Automobile","Multirisque");
	
	}
	else if(document.getElementById("select_client_type").value=="Entreprises"){
			var option=new Array("Automobile","Multirisque");
			var label=new Array("Automobile","Multirisque");

	}
	else if(document.getElementById("select_client_type").value=="Communauté"){
			var option=new Array("Accidents Corporels","Vie");
			var label=new Array("Accidents Corporels","Vie");	
	}
	else{
		remplir =false;
	}
	if(remplir){
		// on remplit le dropdown
		for(var i=0;i<option.length;++i){
			var optn = document.createElement("OPTION");
			optn.text = label[i];
			optn.value = option[i];
			document.getElementById("select_besoin").options.add(optn);
		}
		
		
		document.getElementById('select_besoin').selectedIndex = 0;
		select_value(document.getElementById("select_besoin").value,'client_besoin_value');
		
		/*for (i=0;i<document.getElementById('select_besoin').length;i++){
			alert(document.getElementById("select_besoin").options(i).value);	
		}*/
		//document.getElementById('select_besoin').options(1).selected = true;
	}
}