/**
 * Ouvre une fentre centre sur l'cran. Si la taille de la fentre n'est pas
 * spcifie elle occupera tout l'cran. Si les parametres scrollable et
 * resizable ne sont pas specifis ils auront pour valeur false par dfaut. Si
 * la taille spcifie dpasse celle de l'cran elle est ramene automatiquement
 *  celle de l'cran.
 *
 * @param page       URL du document  ouvrir
 * @param title      Titre de la fentre
 * @param width      Largeur de la fentre
 * @param height     Hauteur de la fentre
 * @param scrollable Indique si les barres de defilements doivent tre affiches
 * @param resizable  Indique si la fentre peut tre redimensionne
 */
function openWindow(page, title, width, height, scrollable, resizable) {

    var maxWidth  = screen.availWidth;
    var maxHeight = screen.availHeight;

    // valeurs par dfaut
    if (width == null) {
        width = maxWidth;
    }

    if (height == null) {
        height = maxHeight;
    }

    if (scrollable == null) {
        scrollable = false;
    }

    if (resizable == null) {
        resizable = false;
    }

    // ajustement de la taille demande  la taille de l'cran
    if (width > maxWidth) {
        width = maxWidth;
    }

    if (height > maxHeight) {
        height = maxHeight;
    }

    // calcul de la position de la fenetre
    var x = (maxWidth - width) / 2;
    var y = (maxHeight - height) / 2;

    // ouverture de la fentre
    var options = "toolbar=no,location=no,status=no,menubar=no,"
                  + "scrollbars=" + (scrollable ? "yes" : "no") + ","
                  + "resizable=" + (resizable ? "yes" : "no") + ","
                  + "width=" + width + ",height=" + height + ","
                  + "left=" + x + ",top=" + y;
    var openedWindow = window.open(page, "_blank", options);
    openedWindow.name = title;
}

/**
 * Ferme la fentre aprs confirmation.
 *
 * @param message le message de confirmation
 */
function fermer(message) {
    if (confirm(message)) {
        window.close();
    }
}


function openpop(url) {
window.open(url,'popfranquin','height=550,width=667,resizable=no,scrollbars=yes,status=0,titlebar=0,toolbar=0,left='+((screen.width/2)-334)+',top='+((screen.height/2)-260)+'');
}

function openbillet(url) {
openWindow(url,'billeterie', 550, 500, true, false);
}

function openpointdoc(url) {
openWindow(url,'', 680, 480, true, true);
}

function opencartes(url) {
openWindow(url,'cartespostales', 550, 500, true, false);
}

function openstnd(url,name) {
window.open(url,name,'width=600,height=500,resizable=yes,scrollbars=yes,status=0,titlebar=0,adressbar=yes,toolbar=yes, location=1,left='+((screen.width/2)-300)+',top='+((screen.height/2)-250)+'');
}






// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 600;
defaultHeight = 600;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage2(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=#FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

// ===============================


// ===============================
// Script from : http://www.howtocreate.co.uk/perfectPopups.html

//really not important (the first two should be small for Opera's sake)
PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//kinda important
var AutoClose = true;

//don't touch
function popImage(imageURL,imageTitle){
        var imgWin = window.open('','_blank','scrollbars=no,resizable=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
        if( !imgWin ) { return true; } //popup blockers should not cause errors
        imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
                'function resizeWinTo() {\n'+
                'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
                'var oH = document.images[0].height, oW = document.images[0].width;\n'+
                'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
                'window.doneAlready = true;\n'+ //for Safari and Opera
                'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
                'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
                'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
                'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
                'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
                'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
                'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
                'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
                'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
                'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
                '}\n'+
                '<\/script>'+
                '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
                (document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
                '<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
                (document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
        imgWin.document.close();
        if( imgWin.focus ) { imgWin.focus(); }
        return false;
        }
// ===============================

function mailto() {
document.write('<a href="mailto:?subject=A_page_from_the_site_of_The_World_of_Franquin&body='+location.href+'">');
}

// ===============================
