﻿function addOnloadEvent5(fnc, nm) {
    
    document.getElementById(nm).style.marginTop = '-97px';
    //style = "margin-top:-97px;"
    if (typeof window.addEventListener != "undefined")
        window.addEventListener("load", fnc, false);
    else if (typeof window.attachEvent != "undefined") {
        window.attachEvent("onload", fnc);
    }
    else {
        if (window.onload != null) {
            var oldOnload = window.onload;
            window.onload = function(e) {
                oldOnload(e);
                window[fnc]();
            };
        }
        else
            window.onload = fnc;
    }
}

function Move_IMG5(im, vr_F) {



//    setInterval('Partenza[NM] = 2;', 2000);


    Partenza[vr_F] = 1;
    Orientamento[vr_F] = 1;
    Giro[vr_F] = 1;
    // alert("prima img")

    // alert("img")
    F_I[vr_F] = "";
    // alert("dopo set")
    // alert('InT_M(\'' + im + '\',\'' + String(vr_F) + '\')')
    F_I[vr_F] = setInterval('InT_M5(\'' + im + '\',\'' + String(vr_F) + '\')', 30);
    // alert("opo int")
}

function InT_M5(im, NM) {

    //alert(Partenza[NM])

    if (Partenza[NM] < 40) {
        Partenza[NM] = Partenza[NM] + 1;
        return;
    }  
    
    

    var IMG = document.getElementById(im);
    //alert(IMG)
    //alert(IMG.style.marginTop.replace('px', ''))
    //  alert("int")
    if (Orientamento[NM] == 1) {
        var Top = Number(IMG.style.marginTop.replace('px', '')) + 1;
        if (Giro[NM] == 1) {
            if (Top >= -17) { Orientamento[NM] = 2; Giro[NM] = 2; }
        }
        else {
            if (Top >= -108) { clearInterval(F_I[NM]); }
        }
        IMG.style.marginTop = String(Number(IMG.style.marginTop.replace('px', '')) + 1) + 'px';
    }
    else {
        var Top = Number(IMG.style.marginTop.replace('px', '')) - 1;
        if (Top <= -130) { Orientamento[NM] = 1; Giro[NM] = 3; }
        IMG.style.marginTop = String(Number(IMG.style.marginTop.replace('px', '')) - 1) + 'px';
    }
}
