// JavaScript Document

function init(){
  // - Slider 1 -----------------------------------------
  mySlider1 = new Bs_Slider();
  mySlider1.attachOnChange(bsSliderChange);
  mySlider1.width         = 162;
  mySlider1.height        = 27;
  mySlider1.minVal        = 0;
  mySlider1.maxVal        = 255;
  mySlider1.valueDefault  = 0;
  mySlider1.valueInterval = 1;
  mySlider1.setBackgroundImage('bg.gif', 'no-repeat');
  mySlider1.setSliderIcon('slider.gif', 9, 22);
  mySlider1.useInputField = 0;
  mySlider1.colorbar = new Object();
  mySlider1.colorbar['color']           = 'red';
  mySlider1.colorbar['height']          = 3;
  mySlider1.colorbar['widthDifference'] = -2;
  mySlider1.colorbar['offsetLeft']      = 3;
  mySlider1.colorbar['offsetTop']       = 11;
  mySlider1.draw('sliderDiv1');
	
	
  // - Slider 2 -----------------------------------------
  mySlider2 = new Bs_Slider();
  mySlider2.attachOnChange(bsSliderChange2);
  mySlider2.width         = 162;
  mySlider2.height        = 27;
  mySlider2.minVal        = 0;
  mySlider2.maxVal        = 255;
  mySlider2.valueDefault  = 0;
  mySlider2.valueInterval = 1;
  mySlider2.setBackgroundImage('bg.gif', 'no-repeat');
  mySlider2.setSliderIcon('slider.gif', 9, 22);
  mySlider2.useInputField = 0;
  mySlider2.colorbar = new Object();
  mySlider2.colorbar['color']           = 'green';
  mySlider2.colorbar['height']          = 3;
  mySlider2.colorbar['widthDifference'] = -2;
  mySlider2.colorbar['offsetLeft']      = 3;
  mySlider2.colorbar['offsetTop']       = 11;
  mySlider2.draw('sliderDiv2');
	
	
  // - Slider 3 -----------------------------------------
 mySlider3 = new Bs_Slider();
  mySlider3.attachOnChange(bsSliderChange3);
	mySlider3.fieldName     = 'volume';
  mySlider3.width         = 162;
  mySlider3.height        = 27;
  mySlider3.minVal        = 0;
  mySlider3.maxVal        = 255;
  mySlider3.valueDefault  = 0;
  mySlider3.valueInterval = 1;
  mySlider3.setBackgroundImage('bg.gif', 'no-repeat');
  mySlider3.setSliderIcon('slider.gif', 10, 21);
  mySlider3.useInputField = 0;
  mySlider3.colorbar = new Object();
  mySlider3.colorbar['color']           = 'blue';
  mySlider3.colorbar['height']          = 3;
  mySlider3.colorbar['widthDifference'] = -2;
  mySlider3.colorbar['offsetLeft']      = 3;
  mySlider3.colorbar['offsetTop']       = 11;
  mySlider3.draw('sliderDiv3');
	
}

/**
* @param object sliderObj
* @param int val (the value)
*/
function bsSliderChange(sliderObj, val1, newPos){ //rouge
  document.test.c1.value = val1;
  convers1(val1);
val2= document.test.c2.value ;
val3= document.test.c3.value ;
var coul7="rgb("+val1+","+val2+","+val3+")";//blanc
eval(layerRef+cro1+"spot"+cro2+styleRef+bgd+"='"+coul7+"'");
}
function bsSliderChange2(sliderObj, val2, newPos){ //vert
 val1 =document.test.c1.value  ;
  val3 =document.test.c3.value  ;
document.test.c2.value = val2;
convers2(val2);
var coul1="rgb("+val1+",0,0)";//r
var coul2="rgb(0,"+val2+",0)";//v
var coul7="rgb("+val1+","+val2+","+val3+")";//blanc
eval(layerRef+cro1+"spot"+cro2+styleRef+bgd+"='"+coul7+"'");

}
function bsSliderChange3(sliderObj, val3, newPos){ //bleu
 val1 =document.test.c1.value  ;
  val2 =document.test.c2.value  ;
document.test.c3.value = val3;
convers3(val3);
var coul1="rgb("+val1+",0,0)";//r
var coul2="rgb(0,"+val2+",0)";//v
var coul3="rgb(0,0,"+val3+")";//b
var coul7="rgb("+val1+","+val2+","+val3+")";//blanc
eval(layerRef+cro1+"spot"+cro2+styleRef+bgd+"='"+coul7+"'");
}

function convers1(x){
	nn1r= Math.floor(x/16);
n0r= x-(nn1r*16);//rang0
nn2r= Math.floor(nn1r/16);
n1r= nn1r-(nn2r*16);//rang1
if(n0r>9){if(n0r==10){n0r="A"};if(n0r==11){n0r="B"};if(n0r==12){n0r="C"};
if(n0r==13){n0r="D"};if(n0r==14){n0r="E"};if(n0r==15){n0r="F"};}
if(n1r>9){if(n1r==10){n1r="A"};if(n1r==11){n1r="B"};if(n1r==12){n1r="C"};
if(n1r==13){n1r="D"};if(n1r==14){n1r="E"};if(n1r==15){n1r="F"};}
document.test.c4.value=""+n1r+""+n0r;

}
function convers2(x){
	nn1r= Math.floor(x/16);
n0r= x-(nn1r*16);//rang0
nn2r= Math.floor(nn1r/16);
n1r= nn1r-(nn2r*16);//rang1
if(n0r>9){if(n0r==10){n0r="A"};if(n0r==11){n0r="B"};if(n0r==12){n0r="C"};
if(n0r==13){n0r="D"};if(n0r==14){n0r="E"};if(n0r==15){n0r="F"};}
if(n1r>9){if(n1r==10){n1r="A"};if(n1r==11){n1r="B"};if(n1r==12){n1r="C"};
if(n1r==13){n1r="D"};if(n1r==14){n1r="E"};if(n1r==15){n1r="F"};}

document.test.c5.value=""+n1r+""+n0r;

}
function convers3(x){
	nn1r= Math.floor(x/16);
n0r= x-(nn1r*16);//rang0
nn2r= Math.floor(nn1r/16);
n1r= nn1r-(nn2r*16);//rang1
if(n0r>9){if(n0r==10){n0r="A"};if(n0r==11){n0r="B"};if(n0r==12){n0r="C"};
if(n0r==13){n0r="D"};if(n0r==14){n0r="E"};if(n0r==15){n0r="F"};}
if(n1r>9){if(n1r==10){n1r="A"};if(n1r==11){n1r="B"};if(n1r==12){n1r="C"};
if(n1r==13){n1r="D"};if(n1r==14){n1r="E"};if(n1r==15){n1r="F"};}

document.test.c6.value=""+n1r+""+n0r;
}