/*
    EFFECTS
*/

// Fish-eye style
function zoom_in(e) {
    var icon_obj = (e) ? e.target : obj ;
    if(!icon_obj) { icon_obj = window.event.srcElement;}
    icon_obj.style.width="51px";
    icon_obj.style.height="71px";
    icon_obj.style.marginTop="0px";
    icon_obj.style.marginLeft="2px";
    icon_obj.style.marginRight="2px";
}
function zoom_out(e, i, obj) {
    var icon_obj = (e) ? e.target : obj ;
    if(!icon_obj) { icon_obj = window.event.srcElement;}
    var cflow_steps = [ ["51px","71px", "0px", "2px", "2px"],
                        ["47px","66px", "5px", "4px", "4px"],
                        ["43px","61px","10px", "6px", "6px"],
                        ["39px","56px","15px", "8px", "8px"],
                        ["15px","31px"," 0px"," 0px"," 0px"]];
    if(i<cflow_steps.length){
        icon_obj.style.width =cflow_steps[i][0];
        icon_obj.style.height=cflow_steps[i][1];
        icon_obj.style.marginTop =cflow_steps[i][2];
        icon_obj.style.marginLeft=cflow_steps[i][3];
        icon_obj.style.marginRight=cflow_steps[i][4];
        (function(i,obj){ 
            window.setTimeout( function(){zoom_out(null,i,obj);} , 100); }
        )(++i,icon_obj);
    }
}

// Change l'image pour la page besoi,n s et services
function chgimg(label) {
    document.getElementById("icon").src = "design/iconb_"+label+".png";
}

function visibilite(thingId){
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.display == "none")
		targetElement.style.display = "block" ;
	else
		targetElement.style.display = "none" ;
}


// Affiche et retire un cadre
function show(divid){
  try{
    document.getElementById(divid).style.display = "block";
  }catch(e){
    document.getElementById(divid).style.display = "block" ;
  }
}

function hide(divid){
  try{
    document.getElementById(divid).style.display = "none";
  }catch(e){
     document.getElementById(divid).style.display = "none" 
  }
}

// Bandeau solutions sur la page accueil
eStat_array = function(){};
var obj_in_move = new eStat_array;
var obj_pitch = new eStat_array;
var obj_effect_on = new eStat_array;
var obj_cycle_len = new eStat_array;
var kill_effect = 1;
var pitch = -1;
var len = 0;
var size = 100;
function mov(id,p){
        var obj = document.getElementById(id);
        if(obj == null){
        	kill_move_effect();
        } else {

        if(obj.style.left == "")
            obj.style.left = "0px";
        if(parseInt(obj.style.left) <= parseInt(obj_cycle_len[id]) )
            obj.style.left = parseInt(obj.style.left) - len + "px";
        else
            obj.style.left = parseInt(obj.style.left) + parseInt(obj_pitch[id]) + 'px';
				}
}
function set_valeur(local_len,local_size){
		len = local_len;
		size = local_size;
}
function move_pause(){
		for (var id in obj_in_move)
    obj_effect_on[id] = 0;
}
function move_play(){
		for (var id in obj_in_move)
    obj_effect_on[id] = 1;
}
function set_play_list(id){
		len= len - size;
		obj_in_move[id] = mov;
    obj_pitch[id] = pitch;
    obj_cycle_len[id]=len;
		move_play(id);
}
function start_move(){
    if(kill_effect == 1){
      kill_effect = 0;
      window.setTimeout( function(){ apply_move(); } , 30);
    }
}
function apply_move(){
    for (var id in obj_in_move)
    if(obj_effect_on[id] == 1)
        obj_in_move[id](id);
    if(kill_effect == 0)
        window.setTimeout( function(){ apply_move(); } , 30);
}
function kill_move_effect(){
    kill_effect = 1;
}

