window.onload = function() { 
document.onselectstart = function() {return false;} // ie 
document.onmousedown = function() {return false;} // mozilla 
}

/* Debut du script de 'drag and drop' */
var drag = {
  
		//zindex:50, 
	
    add_element: function(inst)
    {
        inst.setAttribute("drag_active", false);
				inst.onmousedown = function(e) {
            drag.drag_init(this, e);           
        }
				inst.onmouseup = function(e) {
            drag.drag_end(this, e);            
        }
        inst.onmouseout = function(e) {
        		drag.drag_do(this, e);
        }
        inst.onmousemove = function(e) {
				    drag.drag_do(this, e);
        }
    },
//div_zoomed_frame   div_detail
    drag_init: function(inst, event)
    {
        event = drag.event(event);
        //inst.style.position = "absolute";				
				inst.setAttribute("drag_active", true);
        inst.setAttribute("_x", event.clientX - inst.offsetLeft);
        inst.setAttribute("_y", event.clientY - inst.offsetTop);
    },

    drag_end: function(inst)
    {
				inst.setAttribute("drag_active", false);
						inst.style.MozOpacity = "1.0";
						inst.style.filter = "alpha(opacity=100)";
    },

    drag_do: function(inst, event)
    {
        event = drag.event(event);
        var active = inst.getAttribute("drag_active");
				if (active == true || active == "true"){
            inst.style.left = (event.clientX - inst.getAttribute("_x")) + "px";
            inst.style.top = (event.clientY - inst.getAttribute("_y")) + "px";
						inst.style.MozOpacity = "0.4";
						inst.style.filter = "alpha(opacity=40)";
            //inst.style.zIndex = ++drag.zindex;
        }
    },

    event: function(e)
    {
        return (e == null) ? window.event : e;
    }
};
/* Fin du script de 'drag and drop' */

/* Début de la boîte de détail du produit */ 

function changeStyle(item){
	document.getElementById(item).className = "div_item_hover";
}

function resetStyle(item){
	document.getElementById(item).className = "div_item";
}

function clearImage(id_item, a_infoItem){
	if ((document.getElementById("img_detail").src) != ("/data/image_library/catalogue/"+a_infoItem[2])){
		document.getElementById("img_detail").src="/data/image_library/catalogue/transparentpixel.gif";
		document.getElementById("img_detail_zoomed").src="/data/image_library/catalogue/transparentpixel.gif";
		}
	showDetail(id_item, a_infoItem);
}

function showDetail(id_item, a_infoItem){		
	document.getElementById("img_detail_zoomed").src="/data/image_library/catalogue/"+a_infoItem[2];
	document.getElementById("img_detail").src="/data/image_library/catalogue/zoom/zoom_"+a_infoItem[2];	
	
	if (a_infoItem[3] == '---'){
		str_info = '<strong>'+a_infoItem[0]+'</strong><br/>'+a_infoItem[1];	
	}
	else
	{
		str_info = '<strong>'+a_infoItem[0]+'</strong><br/>'+a_infoItem[1]+'<br/>'+
							 "<br/><strong>Product number: "+a_infoItem[3]+"</strong><br/>";
	}
	document.getElementById("div_info").innerHTML=str_info;

	if (document.getElementById("div_zoomed_frame").style.visibility == "visible"){
		document.getElementById("div_detail").style.visibility = "hidden";
		}
	else {
		document.getElementById("div_detail").style.visibility = "visible";
		}
	drag.add_element(document.getElementById("div_detail"));
}

function showZoomImage(){	
	inst = document.getElementById("div_zoomed_frame");
	last = document.getElementById("div_detail");
	inst.style.left = last.style.left;
	inst.style.top = last.style.top;
	
	last.style.visibility = "hidden";
	inst.style.visibility = "visible";
	drag.add_element(inst);
}

function closeDivDetail(){
	document.getElementById("div_detail").style.visibility = "hidden";
	//document.getElementById("img_detail").src="/data/image_library/catalogue/transparentpixel.gif";
}

function closeDivZoomed(){
	inst = document.getElementById("div_detail");
	last = document.getElementById("div_zoomed_frame");
	inst.style.left = last.style.left;
	inst.style.top = last.style.top;
	
	last.style.visibility = "hidden";
	inst.style.visibility = "visible";
	//document.getElementById("img_detail_zoomed").src="/data/image_library/catalogue/transparentpixel.gif";
}

/* Fin de la boîte de détail du produit */ 