

var precAffiche=null;

//si il a déjà clické pour quizz
var clicke=false;
	
function afficheChecks(nom){
	if (precAffiche!=null){
		$(precAffiche).style.display="none";
	}
	$('check_'+nom).style.display="block";
	
	ajoutv=0;
	ajouth=0;
	if (nom=='bureau'){
		$('check_'+nom).style.top=130+ajoutv+"px";
		$('check_'+nom).style.left=20+ajouth+"px";
	}
	if (nom=='cuisine'){
		$('check_'+nom).style.top=120+ajoutv+"px";
		$('check_'+nom).style.left=20+ajouth+"px";
	}
	if (nom=='salon'){
		$('check_'+nom).style.top=110+ajoutv+"px";
		$('check_'+nom).style.left=450+ajouth+"px";
	}
	if (nom=='lingerie'){
		$('check_'+nom).style.top=290+ajoutv+"px";
		$('check_'+nom).style.left=210+ajouth+"px";
	}
	if (nom=='chambre'){
		$('check_'+nom).style.top=290+ajoutv+"px";
		$('check_'+nom).style.left=520+ajouth+"px";
	}
	if (nom=='salle_de_bain'){
		$('check_'+nom).style.top=80+ajoutv+"px";
		$('check_'+nom).style.left=530+ajouth+"px";
	}
	precAffiche='check_'+nom;
}

function chgCB(){
  if(document.getElementById('newCB')!=undefined){
  CHKB = document.getElementById('newCB').getElementsByTagName('input');
  for(i=0; i < CHKB.length; i++){
    if(CHKB[i].type == "checkbox"){
      IMG = document.createElement('img');
      CHKB[i].parentNode.insertBefore(IMG, CHKB[i]);
      IMG.src = a2.src;
      if(CHKB[i].checked  == true) IMG.src = a1.src ;
      if(CHKB[i].disabled == true) IMG.src = a2.src;
      else{ // Changing state's behaviours are only applied if the box is clickable
        CHKB[i].onchange = function(){
        	if (!clicke){
	          IMG = this.parentNode.getElementsByTagName('img')[0];
	          if(this.checked == true) IMG.src = a1.src
	          else IMG.src = a2.src
			}
        }
        if(!window.sidebar){
          CHKB[i].parentNode.onclick = function(){
	          if (!clicke){
	            CHK = this.getElementsByTagName('input')[0];
	            CHK.checked = (CHK.checked == true) ? false : true;
	            CHK.onchange()
	           }
	          }
        }
      }
      CHKB[i].style.visibility = 'hidden';
      CHKB[i].style.position   = 'absolute';
    }
  }
  }
}



function chgRB(){
			
  if(document.getElementById('newRB')!=undefined){
  CHKB = document.getElementById('newRB').getElementsByTagName('input');
  for(i=0; i < CHKB.length; i++){
  
    if(CHKB[i].type == "radio"){
      IMG = document.createElement('img');
      CHKB[i].parentNode.insertBefore(IMG, CHKB[i]);
      IMG.src = a2.src;

      IMG.id = 'img'+CHKB[i].id;
      IMG.relation = CHKB[i].name;

      if(CHKB[i].checked  == true) IMG.src = a1.src;
      if(CHKB[i].disabled == true) IMG.src = a2.src;
      else{ // Changing state's behaviours are only applied if the box is clickable
        CHKB[i].onchange = function(){
          IMG = document.getElementById('newRB').getElementsByTagName('img');
          for(i=0; i < IMG.length; i++){
            if(IMG[i].relation != this.name) continue;
            if(IMG[i].src.indexOf(a2.src) != -1) continue;
            if(IMG[i].id == 'img'+this.id){
	            IMG[i].src = a1.src;
            }
            else
            { 
            	IMG[i].src = a2.src
            }
            
          }

        }
        if(!window.sidebar){
          CHKB[i].parentNode.onclick = function(){
            CHK = this.getElementsByTagName('input')[0];
            CHK.checked = (CHK.checked == true) ? false : true;
            CHK.onchange()
          }
        }
      }
      CHKB[i].style.visibility = 'hidden';
      CHKB[i].style.position   = 'absolute';
    }
  }
  
	
  }
}



function chgRB2(){
			
  if(document.getElementById('newRB2')!=undefined){
  CHKB = document.getElementById('newRB2').getElementsByTagName('input');
  for(i=0; i < CHKB.length; i++){
  
    if(CHKB[i].type == "radio"){
      IMG = document.createElement('img');
      CHKB[i].parentNode.insertBefore(IMG, CHKB[i]);
      IMG.src = a4.src;

      IMG.id = 'img'+CHKB[i].id;
      IMG.relation = CHKB[i].name;

      if(CHKB[i].checked  == true) IMG.src = a3.src;
      if(CHKB[i].disabled == true) IMG.src = a4.src;
      else{ // Changing state's behaviours are only applied if the box is clickable
        CHKB[i].onchange = function(){
          IMG = document.getElementById('newRB2').getElementsByTagName('img');
          for(i=0; i < IMG.length; i++){
            if(IMG[i].relation != this.name) continue;
            if(IMG[i].src.indexOf(a4.src) != -1) continue;
            if(IMG[i].id == 'img'+this.id){
	            IMG[i].src = a3.src;
            }
            else
            { 
            	IMG[i].src = a4.src
            }
            
          }

        }
        if(!window.sidebar){
          CHKB[i].parentNode.onclick = function(){
            CHK = this.getElementsByTagName('input')[0];
            CHK.checked = (CHK.checked == true) ? false : true;
            CHK.onchange()
          }
        }
      }
      CHKB[i].style.visibility = 'hidden';
      CHKB[i].style.position   = 'absolute';
    }
  }
  
	
  }
}

function chgRB3(){
			
  if(document.getElementById('newRB3')!=undefined){
  CHKB = document.getElementById('newRB3').getElementsByTagName('input');
  for(i=0; i < CHKB.length; i++){
  
    if(CHKB[i].type == "radio"){
      IMG = document.createElement('img');
      CHKB[i].parentNode.insertBefore(IMG, CHKB[i]);
      IMG.src = a6.src;

      IMG.id = 'img'+CHKB[i].id;
      IMG.relation = CHKB[i].name;

      if(CHKB[i].checked  == true) IMG.src = a5.src;
      if(CHKB[i].disabled == true) IMG.src = a6.src;
      else{ // Changing state's behaviours are only applied if the box is clickable
        CHKB[i].onchange = function(){
          IMG = document.getElementById('newRB3').getElementsByTagName('img');
          for(i=0; i < IMG.length; i++){
            if(IMG[i].relation != this.name) continue;
            if(IMG[i].src.indexOf(a6.src) != -1) continue;
            if(IMG[i].id == 'img'+this.id){
	            IMG[i].src = a5.src;
            }
            else
            { 
            	IMG[i].src = a6.src
            }
            
          }

        }
        if(!window.sidebar){
          CHKB[i].parentNode.onclick = function(){
            CHK = this.getElementsByTagName('input')[0];
            CHK.checked = (CHK.checked == true) ? false : true;
            CHK.onchange()
          }
        }
      }
      CHKB[i].style.visibility = 'hidden';
      CHKB[i].style.position   = 'absolute';
    }
  }
  
	
  }
}
