var _bImgZoomed = false;

function PageLoadSpecific()
{
    var img = document.getElementById("UserControl1_imgProductMedium");
    if( img != null )
        img.onclick = OnClickImgZoom;
    
    img = document.getElementById("imgZoom");
    if( img != null )
        img.onclick = OnClickImgZoom;
        
    var body = document.getElementsByTagName("body");
    body[0].onclick = OnClickBody;
}

function OnClickImgZoom( evt )
{
    var img = document.getElementById("UserControl1_imgProductMedium");
    if( img )
    {
        var div = document.getElementById("divProductImgZoom");
        var imgLarge = document.getElementById("imgProductLarge");
        if( div )
        {
            imgLarge.src = img.src.replace("_medium", "_large");            
            
            div.style.position = "absolute";
            div.style.left = getRealLeft( img ) + 'px';
            div.style.top = getRealTop( img ) + 'px';
            div.style.display = "block";
            
            
                   
           
            if(navigator.platform == "MacPPC" && navigator.userAgent.indexOf("MSIE") != -1)
            {
                //IE sur Mac a besoin d'une largeur pour bien afficher l'image en zoom
                var width = imgLarge.offsetWidth;
                div.style.width = width + 'px';  
            }
            /*var children = div.getElementsByTagName("DIV");
            for( var nIdx=0; nIdx < children.length; nIdx++ )
            {
                children[nIdx].style.width = width + 'px';
            }
            
            imgCloseZoom.style.display = "block";*/
            
            //Placer correctement le bouton fermer sur l'image.           
            _bImgZoomed = true;                      
        }
    }
}

function OnClickBody( evt )
{
    var tag = GetEventObject( evt );
    if( _bImgZoomed && tag.id != "UserControl1_imgProductMedium" && tag.id != "imgZoom" )
    {
        var div = document.getElementById("divProductImgZoom");
        div.style.display = "none";
        
        _bImgZoomed = false;      
    }
}