var CurrentMessage = new String
var toolBoxTop = 112

function init(menuPos) {
    // MENU SURLIGNE
    if (menuPos > 0) {
        var curMenu
        curMenu = document.getElementById("mnu_lateral").getElementsByTagName("a").item(menuPos - 1)

        var menuStyle = "link_mnusel_lateral"
        if (curMenu.className.indexOf("last") > 0)
        { menuStyle += " last" }

        curMenu.className = menuStyle
    }
    window.name = "RAMA"

    // PRECHARGEMENT DES IMAGES
    var imgs = new Array()
    imgs[0] = new Image()
    imgs[0].src = "../images/partenaires/part_aqui_over.jpg"
    imgs[1] = new Image()
    imgs[1].src = "../images/partenaires/part_DRAC_over.jpg"
    imgs[2] = new Image()
    imgs[2].src = "../images/partenaires/part_cg_over.jpg"
    imgs[3] = new Image()
    imgs[3].src = "../images/liens_menu/link_actions_hover.jpg"
    imgs[4] = new Image()
    imgs[4].src = "../images/liens_menu/link_actu_hover.jpg"
    imgs[5] = new Image()
    imgs[5].src = "../images/liens_menu/link_rama_hover.jpg"
    imgs[6] = new Image()
    imgs[6].src = "../images/liens_menu/link_ress_hover.jpg"
    imgs[7] = new Image()
    imgs[7].src = "../images/partenaires/part_fdf_over.jpg"
    imgs[8] = new Image()
    imgs[8].src = "../images/partenaires/part_hulot_over.jpg"

    setupLinks()



    // MESSAGE
    if (CurrentMessage != "")
    { alert(CurrentMessage) }


    //Header
    document.getElementById("bandeau").style.cursor = "pointer"
    document.getElementById("bandeau").onclick = function () {
        window.location = "http://www.le-rama.org/"
    }
    
}


function setupLinks() {
    document.getElementById("outils").style.top = toolBoxTop


    // CONFIGURATION DES LIENS	
    var i
    for (i = 0; i < document.getElementsByTagName("a").length; i++) {
        var objA
        objA = document.getElementsByTagName("a").item(i)
        objA.onmouseover = showLink
        objA.onmouseout = hideLink
    }

    // STATUS
    window.status = document.getElementById("StatusText").innerText
    window.defaultStatus = document.getElementById("StatusText").innerText
    winOnLoad()
}


function showLink(e) {
    try {
        window.event.srcElement.title
    }
    catch (ex) { }
//    if (!e)
//    { window.status = window.event.srcElement.title }
//    else
//    { window.status = e.target.attributes["title"].value }

    return true;
}

function hideLink() {
    window.status = document.getElementById("StatusText").innerText
    return true;
}


function affImg() {
//    document.getElementById("img_Ill").src = "file://" + document.getElementById("inpFImg").value
//    document.getElementById("img_Ill").style.display = "block"
//    document.getElementById("img_Ill").style.height = "50px"
}


function DescriptLink(idL) {
    window.open("../inc/pages/liens.aspx?LnkId=" + idL, "_blank", "width=500,height=200,status=0,toolbar=0, menubar=0, location=no, titlebar=no, scrollbars=yes, resizable=no, channelmode=no")
}


// BLOCS DEFILANTS
var obj = new Array()

function setupScroll(curCont, cpt, cont1, cont2) {
    var objCont = document.getElementById(curCont)
    obj[cpt] = new Array()

    obj[cpt][0] = document.getElementById(cont1)									// premier bloc défilant
    obj[cpt][1] = document.getElementById(cont2)									// second  bloc défilant
    obj[cpt][2] = 0																// position 1
    obj[cpt][3] = document.getElementById(cont1).offsetHeight					// position 2
    obj[cpt][4] = document.getElementById(cont1).offsetHeight					// Hauteur du bloc
    obj[cpt][5] = 1																// Bloc courant
    obj[cpt][7] = objCont.offsetHeight											// Hauteur du conteneur

    if (!document.all) {
        obj[cpt][3] = 0;
        obj[cpt][6] = window.setInterval("scrollBlocsMoz(" + cpt + ")", 70 + (1 * cpt)); // Timer 40
    }
    else {
        obj[cpt][6] = window.setInterval("scrollBlocs(" + cpt + ")", 70 + (1 * cpt));
    }
}

function scrollBlocs(cpt) {
    obj[cpt][0].style.top = obj[cpt][2] + "px";
    obj[cpt][1].style.top = obj[cpt][3] + "px";

    obj[cpt][2] += -1;
    obj[cpt][3] += -1;

    if (Math.abs(obj[cpt][2]) > obj[cpt][4] && obj[cpt][5] == 1)
    { obj[cpt][5] = 2; obj[cpt][2] = obj[cpt][4] + obj[cpt][3]; }

    if (Math.abs(obj[cpt][3]) > (2 * obj[cpt][4]) - obj[cpt][7] && obj[cpt][5] == 2)
    { obj[cpt][5] = 1; obj[cpt][3] = obj[cpt][4] + obj[cpt][2] }

}
function scrollBlocsMoz(cpt) {
    obj[cpt][0].style.top = obj[cpt][2] + "px";
    obj[cpt][1].style.top = obj[cpt][3] + "px";

    obj[cpt][2] += -1;
    obj[cpt][3] += -1;

    if (Math.abs(obj[cpt][2]) > obj[cpt][4] && obj[cpt][5] == 1)
    { obj[cpt][5] = 2; obj[cpt][2] = obj[cpt][4] - 1 }

    if (Math.abs(obj[cpt][3]) > (2 * obj[cpt][4]) && obj[cpt][5] == 2)
    { obj[cpt][5] = 1; obj[cpt][3] = -1 }
}





// Higlights


function Common_hightLight(obj, type) {
    if (type == "over")
    { obj.style.backgroundColor = "#FFF" }
    else
    { obj.style.backgroundColor = "" }
}


// FLOATING
var slideTime = 1500, topMargin;
function winOnLoad() {
    topMargin = 112 //xPageY('outils');
    winOnResize(); // set initial position
    xAddEventListener(window, 'resize', winOnResize, false);
    xAddEventListener(window, 'scroll', winOnScroll, false);
    return;
}
function winOnResize() {
    xMoveTo('outils', 665, topMargin);
    xShow('outils');
    winOnScroll(); // initial slide
}
function winOnScroll() {
    xSlideTo('outils', 665, xScrollTop() + topMargin, slideTime);
}