var timeoutID_popup;

function affiche_img_popup(src_, id, w, h, w_src)
{
	clearTimeout(timeoutID_popup);
	timeoutID_popup = setTimeout("affiche_div_photo('"+src_+"', '"+id+"', '"+w+"', '"+h+"', '"+w_src+"')",10);
}

function clear_time_out() {
	clearTimeout(timeoutID_popup);
}
function set_time_out_close_popup() {
	clearTimeout(timeoutID_popup);
	document.getElementById("dv_m").style.display ="none";
}
function pop_close()
{
	timeoutID_popup = setTimeout("set_time_out_close_popup()",200);	
}


function affiche_div_photo(src_, id, w, h, w_src) {

    clearTimeout(timeoutID_popup);
			 
    el = document.getElementById("tableau_image_"+id);
    var pos = donne_position(el);
    var posX = pos["x"];
    var posY = pos["y"];

    var the_left = posX ;//s+parseInt(w_src)+10;
    var the_top = posY ;//- document.getElementById("dv_m").offsetHeight/2 + el.offsetHeight/2;

    var nav = detecte_nav();
    if (nav == "IE6") {
        pos = donne_position(document.getElementById("page"));
        var parent_left = pos["x"];//-200;
        var parent_top = pos["y"];
        the_left = the_left + 13;//- parent_left; //- document.getElementById("main").offsetWidth/16
        the_top = the_top ;//- parent_top;
    }

    document.getElementById("dv_m").style.left=the_left+"px";
    document.getElementById("dv_m").style.top=the_top+"px";

	document.getElementById("dv_m").style.display ="block";
	document.getElementById("dv_m").innerHTML = "<img src='"+src_+"' style='width:"+w+"px;height:"+h+"px;cursor:pointer;float:left;margin:3px;'/>";
}

// ************************ Photos les unes apres les autres ******************************* //

function affiche_image(element, liste_images, w, h, w_div, h_div) {
	
	var el = document.getElementById(element);
	element_name = element;
	
	var array_image=liste_images.split(',');
	var array_w_image=w.split(',');
	var array_h_image=h.split(',');
	var array_el_image=Array();
	
	for (var i=0; i<array_image.length;i++) {
		var mt = (h_div - array_h_image[i])/2;
		var ml = (w_div - array_w_image[i])/2;
		
		var img = new Image();
		img.src=array_image[i];
		img.style.opacity = 0;
		img.style.display = "none";
		img.style.width = array_w_image[i]+'px';
		img.style.height = array_h_image[i]+'px';
		img.style.marginTop = mt+'px';
		img.style.marginLeft = ml+'px';
		array_el_image[array_el_image.length]=img;
		el.appendChild(img);
	}
	ds_cc_image(element, array_el_image, 0);
};

function ds_cc_image(element, array_image, image_en_cours) {
	if (!image_en_cours>0) image_en_cours=0;
	
	var img = array_image[image_en_cours];
	img.style.display = 'block';
	img.style.opacity = 1;
	var rd = (Math.random()*300)+1400;
	var imgEffect = img.effect('opacity', {duration: parseInt(rd)});
	imgEffect.start(1).chain(function() {
		imgEffect.start(0).chain(function() {
			if (image_en_cours < array_image.length - 1) {												
				image_en_cours++;	
			} else {
				image_en_cours=0;
			}
			try {
				img.style.display = "none";
			}
			catch(ex) {}
			ds_cc_image(element, array_image, image_en_cours);
		});
	});
}

function change_detail_produit_image(el, src, w, h, w_t, h_t) {
	document.getElementById(el).src = src
	document.getElementById(el).style.width=w;
	document.getElementById(el).style.height=h;
	var m_l = (w_t-w)/2;
	document.getElementById(el).style.marginLeft=m_l;
	//var m_t = (h_t-h)/2;
	//document.getElementById(el).style.marginTop=m_t;
}