
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function popWin() {
    /*if (document.all) {
    larg = document.body.clientWidth;
    haut = document.body.clientHeight;
    }
    else {
    larg = screen.width;
    haut = screen.height;
    }*/
    
    if (centerX == 0) {
        if (ns4) centerX = (window.innerWidth - 16 - popWidth) / 2
        else centerX = (document.body.offsetWidth - 20 - popWidth) / 2;
        alert(centerX)
    }

    if (document.getElementById)// && readCookie("popup") == null) 
    {

        var ppl = "popLayer"; var objppl = findObj(ppl);
        if (objppl == null) { return; } // if the layer does not exist, do nothing.
        var args = arguments

        var movetoX = args[0];
        if (movetoX == -1) {
            movetoX = centerX;
        }
        //movetoX=parseInt(args[0]);
        movetoY = parseInt(args[1]), movespeed = parseInt(args[2]);

        var cycle = 10, pxl = "";
        if (!document.layers) { objppl = objppl.style; }
        if (objppl.tmofn != null) { clearTimeout(objppl.tmofn); }
        var pplcoordX = parseInt(objppl.left), pplcoordY = parseInt(objppl.top);
        var xX = movetoX, yY = movetoY;
        if ((pplcoordX != movetoX) || (pplcoordY != movetoY)) {
            if (movetoX - pplcoordX > movespeed || movetoY - pplcoordY > movespeed) {
                var moveX = ((movetoX - pplcoordX) / movespeed), moveY = ((movetoY - pplcoordY) / movespeed);
                moveX = (moveX > 0) ? Math.ceil(moveX) : Math.floor(moveX); movetoX = pplcoordX + moveX;
                moveY = (moveY > 0) ? Math.ceil(moveY) : Math.floor(moveY); movetoY = pplcoordY + moveY;
                if ((parseInt(navigator.appVersion) > 4 || navigator.userAgent.indexOf("MSIE") > -1) && (!window.opera)) { pxl = "px"; }
            
                if (moveX != 0) { eval("objppl.left='" + movetoX + pxl + "'"); }
                if (moveY != 0) { eval("objppl.top = '" + movetoY + pxl + "'"); }
                var sFunction = "popWin(" + xX + "," + yY + "," + movespeed + ")";
                objppl.tmofn = setTimeout(sFunction, cycle);
            }
        }
        else {
            createCookie("popup", "1", 1);
        }

    }

}
function eraseCookie(name) {
    createCookie(name, "", -1);
}

function findObj(theObj, theDoc) {
    var p, i, foundObj;
    if (!theDoc) theDoc = document;
    if ((p = theObj.indexOf("?")) > 0 && parent.frames.length) {
        theDoc = parent.frames[theObj.substring(p + 1)].document;
        theObj = theObj.substring(0, p);
    }
    if (!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
    for (i = 0; !foundObj && i < theDoc.forms.length; i++)
        foundObj = theDoc.forms[i][theObj];
    for (i = 0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
        foundObj = findObj(theObj, theDoc.layers[i].document);
    if (!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
    return foundObj;
}
function hideLayer(layername) {
    layer = findObj(layername);
    if (layer.style) { layer = layer.style; }
    layer.visibility = 'hidden';
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init == true) with (navigator) {
        if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
            document.MM_pgW = innerWidth; document.MM_pgH = innerHeight; onresize = MM_reloadPage;
        }
    }
    else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();
}

function gotoshow() {
    if (newwindow)
        window.open(slidelinks[whichlink])
    else
        window.location = slidelinks[whichlink]
}