﻿var gsl_FenFTP = null;
var gsl_FenOwa = null;
var gsl_FenWn = null;
var gsl_FenIntra = null;
var gsl_FenInSite = null;

function survol(obj, src) {
    obj.src = src;
}

function survolTD(obj, style) {
    $(obj).className = style;
}

function openFTP() {
    if (gsl_FenFTP != null)
        gsl_FenFTP.close();
    gsl_FenFTP = window.open("/espaceFTP/monFTP.aspx", "gsl_FenFTP", "width:800px;height:600px;status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,left=0px,top=0px;");
    gsl_FenFTP.focus();
}

function openOwa() {
    if (gsl_FenOwa != null)
        gsl_FenOwa.close();
    gsl_FenOwa = window.open("/owa/exchange/", "gsl_FenOwa", "width:800px;height:600px;status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=1,left=0px,top=0px;");
    gsl_FenOwa.focus();
}

function openWn() {
    if (gsl_FenWn != null)
        gsl_FenWn.close();
    gsl_FenWn = window.open("/wn/webnative/listdir/", "gsl_FenWn", "width:800px;height:600px;status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=1,left=0px,top=0px;");
    gsl_FenWn.focus();
}

function openIntranet() {
    if (gsl_FenIntra != null)
        gsl_FenIntra.close();
    gsl_FenIntra = window.open("/intra/", "gsl_FenIntra", "width:800px;height:600px;status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=1,left=0px,top=0px;");
    gsl_FenIntra.focus();
}

function openInSite() {
    if (gsl_FenInSite != null)
        gsl_FenInSite.close();
    gsl_FenInSite = window.open("/insite/logInSite.aspx", "gsl_FenInSite", "width:800px;height:600px;status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=1,left=0px,top=0px;");
    gsl_FenInSite.focus();
}

/* fiche domaines */

function fadeOut() {
    $('divCache').style.top = document.body.scrollTop;
    $('divCache').style.height = document.body.scrollHeight;
//    new Effect.Opacity('divCache', { duration: 0.2, from: 0, to: 0.5 });
    $('divCache').style.visibility = 'visible';
}

function fadeIn() {
//    new Effect.Opacity('divCache', { duration: 0.2, from: 0.5, to: 0.0 });
    $('divCache').style.visibility = 'hidden';
}

function AfficheDomaine(url) {
    fadeOut();
    MontreFiche();
    new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport) {
            $('divFiche').update(transport.responseText);
        },
        onFailure: function(transport) {
            alert(transport.statusText);
        },
        onCreate: function(transport) {
            //$('divFiche').update('<img id="imgLoad" src="/imgs/loading.gif" width="320" height="320" alt="chargement en cours....">');
        }
    });
}

function MontreFiche() {
    var offsetX = document.body.clientWidth;
    var offsetY = document.body.clientHeight;
    var scrollX = document.body.scrollLeft;
    var scrollY = document.body.scrollHeight;

    var NewPosX = 0;
    var NewPosY = 0;
    var InfoBulleX = 780;
    var InfoBulleY = 634;

    if (offsetX - InfoBulleX >= 0) {
        NewPosX = (offsetX - InfoBulleX) / 2;
    }
    if (offsetY - InfoBulleY >= 0) {
        NewPosY = (offsetY - InfoBulleY) / 2;
        window.scroll(0, (offsetY - InfoBulleY) / 2);
    }

    $('divLoading').style.top = NewPosY;
    $('divLoading').style.left = NewPosX;
    $('divLoading').style.visibility = "visible";
    $('divFiche').style.top = NewPosY;
    $('divFiche').style.left = NewPosX;
    $('divFiche').style.visibility = "visible";
    window.onresize = MontreFiche;
}

function HideFiche() {
    $('divFiche').style.visibility = 'hidden';
    $('divLoading').style.visibility = "hidden";
    fadeIn();
    $('divFiche').update();
    window.scroll(0, 0);
    window.onresize = null;
}

function GoToDomaine(flash) {
    $('FL_domaine').movie = "/flash/" + flash + ".swf";
}

