
var courriel = 'chemit.gerard-laposte.net';

var links = [
{id:0,alt:"Accéder au site des photopgrahies", coords:"103,556,256,581", dispatch:'enterSite()'},
{id:1,alt:"Résolution des problèmes techniques", coords:"269,556,401,581", dispatch:'problemes()'},
{id:2,alt:"Contacter l'auteur par courriel" ,coords:"415,556,490,581", dispatch:'contact()'}
        ];

Object.extend(window, {

    onload : function() {
        // create mapHandler
        this.mapHandler = new MapHandler({
            linkDispatch:true,
            load:function() {
                this['loadMap']($('imageId'), links, 1);
                this._init = true;
                if (isIE) this['markFirst']();
            },
            borderName:'border',
            mapName:'mapImage',
            cssMark:'mark',
            cssClean:'clean'
        });

        // load it
        this.mapHandler.load();

        // authorized after loading, resize event for window (on firefox it could be launched before onload ?)
        this.onresize = this.mapHandler.load.bind(this);
    },

    detectBestSize : function () {
        //console.info("avail " + screen.availWidth + ',' + screen.availHeight);
        return screen.availWidth < 1280 || (screen.availHeight + 54) < 1024 ? 600 : 800;
    },

    getImagePos : function () {
        return Position.cumulativeOffset($('imageId'));
    },

    enterSite: function() {
        var timestamp = new Date().getTime();
        // must block another demand
        // bug with firefox : if the action has focus and regain it after alert, it invoke this a second time
        if (window._timestamp && timestamp - window._timestamp < 100) return;
        var size = detectBestSize();
        var txt = "resizable=no,location=yes";
        if (!isIE) txt += ",toolbar=yes";
        alert("Les images visibles sur le site sont la propriété exclusive de l'auteur et ne sont pas libres de droit.\n\n" +
              "        Merci de ne pas en faire usage sans avoir obtenu l'accord de l'auteur au préalable.\n\n" +
              "              Vous pouvez le contacter à partir du lien en bas de page.");
        window.open("indexAlbum.html?imageSize=" + size, "", txt);
        window._timestamp = new Date().getTime();
    },

    contact : function() {
        document.location.href = 'mailto:' + courriel.replace('-', '@');
    },
    
    problemes : function() {
        alert("A venir...,\n si vous rencontrez des problèmes pour accéder au site des photographies, contacter l'auteur.");
    }
});


