﻿// File JScript
var fatto = true;

var doc_width = window.screen.availWidth;
var doc_height = window.screen.availHeight - 150;

function wait() {
    for (i=1;fatto;i++) {
    }
}

function changeX(id, X) {
    var object = document.getElementById(id).style;
    object.left = X + "px";
}
function changeY(id, Y) {
    var object = document.getElementById(id).style;
    object.top = Y + "px";
}

function move(id, endX, endY, millisec) {
    //speed for each frame 
    if (millisec!=0) {
        var startX = parseInt(document.getElementById(id).style.left)
        var startY = parseInt(document.getElementById(id).style.top)
        var width = startX - endX
        var height = startY - endY
        if (width<0) width=-width
        if (height<0) height=-height
        
        var speedX = Math.round(millisec / width); 
        var speedY = Math.round(millisec / height); 
        var timer = 0;

        if(startX > endX) { 
            for(i = startX; i >= endX; i--) { 
                setTimeout("changeX('" + id + "'," + i + ")",(timer * speedX)); 
                timer++; 
            } 
        } else if(startX < endX) { 
            for(i = startX; i <= endX; i++) 
                { 
                setTimeout("changeX('" + id + "'," + i + ")",(timer * speedX)); 
                timer++; 
            } 
        } 
        timer = 0;
        if(startY > endY) { 
            for(i = startY; i >= endY; i--) { 
                setTimeout("changeY('" + id + "'," + i + ")",(timer * speedY)); 
                timer++; 
            } 
        } else if(startY < endY) { 
            for(i = startY; i <= endY; i++) 
                { 
                setTimeout("changeY('" + id + "'," + i + ")",(timer * speedY)); 
                timer++; 
            } 
        } 
    } else {
        changeX(id, endX)
        changeY(id, endY)
    }
}
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

// cambia opacità per i diversi browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function show(id) {
    var object = document.getElementById(id).style;
    object.display='block';
}
function hide(id) {
    var object = document.getElementById(id).style;
    object.display='none';
}