

function slide_show_preload() { 

	document.getElementById(diaporama_image).src = CFG_HTTP_ROOT + 'img/preload.gif';	
	
	tmp_img_loaded = new Array();
	tmp_img = new Array();
	tmp_img_loaded_count = 0
	
	for(a = 0; a < diaporama_array.length; a++){
		array_img =diaporama_array[a].split('|');
		
		tmp_img[a] = new Image(); 
		tmp_img[a].src  = array_img[0];
		tmp_img_loaded[a] = false
	}										  
	slide_show_checkload()

}




function slide_show_checkload() {
	if (tmp_img_loaded_count == diaporama_array.length) { 
		slide_show(0);
		return false;
	}
	for (i = 0; i <= diaporama_array.length; i++) {
		if (tmp_img_loaded[i] == false && tmp_img[i].complete) {
			tmp_img_loaded[i] = true;
			tmp_img_loaded_count++;
		}
	}
	timerID = setTimeout("slide_show_checkload()",10) 
}


function slide_show(id){
	
	array_img =diaporama_array[id].split('|');
	document.getElementById(diaporama_image).src = array_img[0];
	document.getElementById(diaporama_titre).innerHTML = array_img[1];
	document.getElementById(diaporama_titre).style.width = array_img[3]+'px';
	document.getElementById(diaporama_image).onclick=function(){
		document.location.replace(array_img[2]);
	}
	
      $("#slide_show").fadeIn("slow", function () {
			setTimeout("slide_show_fade_out("+id+")",diaporama_vitesse);
      });

	

	
}	


function slide_show_fade_out(id){
	
      $("#slide_show").fadeOut("slow", function () {
			slide_show_timout(id)
      });

	

}

function slide_show_timout(id){
	id = (id == diaporama_array.length - 1) ? 0 : id+1;
	slide_show(id);
	
}




function changeSize() {

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
}else{
 var ieversion = 0
}



  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;

  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  	if( (ieversion <= 6) &&  (ieversion != 0)) {
		myWidth = myWidth - 30;
	}
	
	
	if(ieversion != 0){
		myHeight = myHeight;
		myWidth = myWidth;
	}

if (document.getElementById('sous_menu').style.display == 'block'){
  MainWidth = myWidth - 180;
  document.getElementById('main').style.left =  '150px';
}else{
  MainWidth = myWidth - 30
}
  
  MainHeight = myHeight - 100
  
  document.getElementById('main').style.height = MainHeight + 'px';
  document.getElementById('main').style.width = MainWidth + 'px';
  
  
  
  
  /*** WORK INFORMATIONS ***/
  if($('#work_information')){
	var infos_hauteur = parseInt($('#work_information').innerHeight())
	var infos_top = parseInt($('#work_information').css('top'))
	
	var works_hauteur = parseInt($('#main_work').innerHeight())
	var works_top = parseInt($('#main').css('top'))
	
	var MinPos = works_hauteur + works_top -15;
	var MaxPos = works_hauteur + works_top
	
	if( MainHeight < Number(MinPos)){
		
		var newTop = Number(Number(MainHeight) - Number(infos_hauteur) -15);
		$('#work_information').css('top', newTop+'px')

		}else if(MainHeight > MaxPos) {
		var newTop = works_hauteur;
		$('#work_information').css('top', newTop+'px')
	}
  }
  
}




http://localhost:8888/monsieur_l_agent/media/works/ma_works_13_media_3.jpg













function prepareMouseOverImage(image_out_id, image_over, HexColor_out, HexColor_over){
  var myCanvas=document.createElement("canvas");

	if (myCanvas.getContext) {  
		image = document.getElementById(image_out_id)
		image.onload=function(){
			this.normalImage = ChangeColor(this, HexColor_out);
			this.mouseOverImage = ChangeColor(this, HexColor_over);
			
			this.onmouseover=function(){
				this.src=this.mouseOverImage;
				this.style.cursor='pointer';
			}
			
			this.onmouseout=function(){
				this.src=this.normalImage;
				this.style.cursor='	pointer';
			}
			this.src=this.normalImage;
			this.style.display = 'block';
		};
	}else{
		image_src = document.getElementById(image_out_id).src;


			document.getElementById(image_out_id).onmouseover=function(){
				this.src= image_over;
			}
			
			document.getElementById(image_out_id).onmouseout=function(){
				this.src=image_src;
			}
			
			document.getElementById(image_out_id).style.display = 'block';
		
	}
}




function ChangeColor(image, HexColor)
{
	
  currentColor = Colors.ColorFromHex(HexColor);
  
  var red = currentColor.Red();
  var green= currentColor.Green();
  var blue = currentColor.Blue();
  
  
  
  var myCanvas=document.createElement("canvas");
  var myCanvasContext=myCanvas.getContext('2d');

  var imgWidth=image.width;
  var imgHeight=image.height;
  // You'll get some string error if you fail to specify the dimensions
  myCanvas.width= imgWidth;
  myCanvas.height=imgHeight;
//  alert(imgWidth);
  myCanvasContext.drawImage(image,0,0);
  // this function cannot be called if the image is not rom the same domain.  You'll get security error
  var imageData=myCanvasContext.getImageData(0,0, imgWidth, imgHeight);
  for (i=0; i<imageData.height; i++)
  {
    for (j=0; j<imageData.width; j++)
    {
	  var index=(i*4)*imageData.width+(j*4);
	  var alpha=imageData.data[index+3];	 
   	  imageData.data[index]= red;	  
   	  imageData.data[index+1]=green;
   	  imageData.data[index+2]=blue;
   	  imageData.data[index+3]=alpha;	  	  
	}
  }
  myCanvasContext.putImageData(imageData,0,0,0,0, imageData.width, imageData.height);
 // myCanvasContext.drawIMage(imageData,0,0);//,0,0, imageData.width, imageData.height);  

	return myCanvas.toDataURL();
}






