function master(layer, imgName, imgSrc, imgSrc2, imgSrc3, imgSrc4)
{
	flip(imgName, imgSrc, imgSrc2, imgSrc3, imgSrc4);
	//	toggleLayer(layer);
	doSlide(layer);
//	loadImages();
}

function doSlide(id) {
    timeToSlide = 20; // in milliseconds
    obj = document.getElementById(id);
    if (obj.style.display == "none") 
	{ // si c hidden on fait le slide
        obj.style.visibility = "hidden";
        obj.style.display = "block";
        height = obj.offsetHeight;
        obj.style.height = "0px";
        obj.style.visibility = "visible";
        pxPerLoop = height / timeToSlide;
        slide(obj, 0, height, pxPerLoop);
    } 
	else if (obj.style.display == "block") 
	{ // si c hidden on fait le slide
		height = obj.offsetHeight;
		obj.style.height = height;
		obj.style.visibility = "visible";
		pxPerLoop = height / timeToSlide;
		close(obj, height, height, pxPerLoop);
	} 
	
}
function close(obj, offset, full, px) {
    if (offset > 0) {
        obj.style.height = offset + "px";
        offset = offset - px;
        setTimeout((function() { close(obj, offset, full, px); }), 1);
    } 
	else 
	{
		obj.style.display = "none"; //Can be usefull in updated divs otherwise
		obj.style.visibility = "hidden";
		obj.style.height = full + "px";
        //just use full+"px"
    }
}
function slide(obj, offset, full, px) {
    if (offset < full) {
        obj.style.height = offset + "px";
        offset = offset + px;
        setTimeout((function() { slide(obj, offset, full, px); }), 1);
    } else 
	{
        obj.style.height = "auto"; //Can be usefull in updated divs otherwise
        //just use full+"px"
    }
}


function flip(imgName, imgSrc, imgSrc2, imgSrc3, imgSrc4)
{
	if (document[imgName].src.match(imgSrc4) == imgSrc4) 
	{
		document[imgName].src = imgSrc2;
	}
	else if (document[imgName].src.match(imgSrc2) == imgSrc2) 
	{
		document[imgName].src = imgSrc3;
	}
}

function mouseover(imgName, imgSrc, imgSrc2, imgSrc3, imgSrc4) 
{
    if (document[imgName].src.match(imgSrc3) == imgSrc3) {
        document[imgName].src = imgSrc4;
    }
    else if (document[imgName].src.match(imgSrc) == imgSrc) {
        document[imgName].src = imgSrc2;
    }
}
function mouseout(imgName, imgSrc, imgSrc2, imgSrc3, imgSrc4) 
{
    if (document[imgName].src.match(imgSrc4) == imgSrc4) {
        document[imgName].src = imgSrc3;
    }
    
    else if (document[imgName].src.match(imgSrc2) == imgSrc2) {
        document[imgName].src = imgSrc;
    }
}
