catwalk_speed = 0;
catwalk_shift_interval = 0;
catwalk_speed_limit = 7;

var aux;
var medidaVisivel = 0;

//medidaVisivel = 439;

function catwalk_over(event, teste) {
    //start moving
    aux = teste;
    if (aux == "3" || aux == "E3") {
        //window.alert(aux);
        medidaVisivel = 684;
    }
    else if (aux == "2" || aux == "E2") {
        //window.alert(aux);
        medidaVisivel = 520;
        //window.alert(aux);
    }
    else {
        medidaVisivel = 439;
    }
    catwalk_shift_interval = setInterval("catwalk_shift()", 10);
}
function catwalk_move(event, aux) {
    //reset speed
    var el = event.srcElement;
    if (!el) {
        //MOZILLA
        el = event.target;
    }
    var offsetCount = 0;
    while (el.id != "catwalkcontainer" + aux.toString()) {
        offsetCount += el.offsetLeft;
        el = el.parentNode;
    }
    var mouseX = event.offsetX + offsetCount;
    if (typeof event.offsetX == "undefined") {
        if (event.target.id.match("catwalkleft" + aux.toString())) {
            mouseX = event.layerX;
        } else {
            if (event.target.id.match("catwalkright" + aux.toString())) {
                mouseX = event.layerX;
            } else {
                mouseX = event.layerX + parseInt(document.getElementById('catwalktable' + aux.toString()).offsetLeft) + 40;
            }
        }
    }
    catwalk_speed = (mouseX - (medidaVisivel / 2)) / (medidaVisivel / 2) * 10; /*catwalk_speed = (mouseX - (717/2)) / (717/2) * 10;*/ /*MEDIDA DE DENTRO (mascara)*/
    if (catwalk_speed > catwalk_speed_limit) catwalk_speed = catwalk_speed_limit;
}
function catwalk_out() {
    //stop movement
    clearInterval(catwalk_shift_interval);
}
function catwalk_shift() {
    //actually move the catwalk
    var actual_speed = Math.abs(catwalk_speed) - 2;
    if (actual_speed < 0) actual_speed = 0;
    if (catwalk_speed < 0) actual_speed = -1 * actual_speed;

    var mytable = document.getElementById('catwalktable' + aux.toString());
    var myleft = document.getElementById('catwalkleft' + aux.toString());
    var myright = document.getElementById('catwalkright' + aux.toString());

    if (parseInt(mytable.offsetLeft) >= 0 && actual_speed < 0) {
        if (!myleft.src.match("stop")) myleft.src = myleft.src.replace("left.gif", "left_stop.gif");
        return;
    } else {
        if (myleft.src.match("stop")) myleft.src = myleft.src.replace("left_stop.gif", "left.gif");
    }
    if (parseInt(mytable.offsetLeft) <= (medidaVisivel - mytable.offsetWidth) && actual_speed > 0) {/*if (parseInt(mytable.offsetLeft)<=(439-mytable.offsetWidth) && actual_speed>0) {*/ /*MEDIDA DE DENTRO (mascara)*/
        if (!myright.src.match("stop")) myright.src = myright.src.replace("right.gif", "right_stop.gif");
        return;
    } else {
        if (myright.src.match("stop")) myright.src = myright.src.replace("right_stop.gif", "right.gif");
    }
    mytable.style.left = (parseInt(mytable.offsetLeft) - actual_speed) + "px";
}

