
var courriel = 'gchemit.empreintes@gmail.com';

//var links = [
//{id:0,alt:"Accéder au site", coords:"207,713,445,770", dispatch:'enterSite()'},
//{id:1,alt:"Résolution des problèmes techniques", coords:"480,713,675,770", dispatch:'problemes()'},
//{id:2,alt:"Contacter l'auteur par courriel" ,coords:"706,713,844,770", dispatch:'contact()'}
//        ];
var links = [
{id:0,alt:"Accéder au site", coords :"780,320,1008,365", dispatch:'enterSite()'},
{id:1,alt:"Contacter l'auteur par courriel" ,coords:"876,370,1008,415", dispatch:'contact()'}
        ];
try {
console = initConsole(window);
} catch(ex) {
    //if (console) console.info("ERROR on clean " + $H(ex).inspect());
}

Object.extend(window, {

    onload : function() {
        initConsole(window);
        
        // create mapHandler
        this.mapHandler = new MapHandler({
            linkDispatch:true,
            load:function() {
                this['loadMap']($('imageId'), links, 1,[1024,780]);
                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 ?  "1024x780" : "1280x1024";
//        return screen.availWidth < 1280 || (screen.availHeight + 54) < 1024 ? "1280x1024" : "1024x780";
    },

    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?windowSize=" + size, "", txt);
        window._timestamp = new Date().getTime();
    },

    contact : function() {
        document.location.href = 'mailto:' + courriel.replace('-', '@');
    },
    
    problemes : function() {
        alert("Si vous rencontrez des problèmes pour accéder au site, contacter l'auteur.");
    }
});



