var pwidth   = 210;
var elements = 2;
var all = elements+3;
var timeout  = 10;
var max = pwidth*3;

function left() {
        if(navigator.userAgent.indexOf("MSIE") != -1){ 
        document.getElementById("gr").src = "images/g_right_a.gif";
        document.getElementById("gl").src = "images/g_left_a.gif";
    var margin = document.getElementById("e").style.marginLeft;
        margin = margin.replace(/px/g, "");
        marginp = Number.marginp;
        var z = elements*pwidth;
        z = parseInt("-"+z);
    if(margin != z){moveleft(pwidth);} 
        margin = margin-pwidth;
    if(margin <= z){document.getElementById("gr").src = "images/g_right.gif";}
    }else{
        /*PLUS*/
        var now = document.getElementById("now").innerHTML;
        now = parseInt(now);
        now = now+1;
        if(now <= elements) {
            document.getElementById("gr").src = "images/g_right_a.gif";
            document.getElementById("gl").src = "images/g_left_a.gif";
            document.getElementById("now").innerHTML = now;
            document.getElementById("st"+now).style.display="none";
            if(now == elements){document.getElementById("gr").src = "images/g_right.gif";}
        }
    }
    /**/
}
function right() { 
        if(navigator.userAgent.indexOf("MSIE") != -1){ 
        document.getElementById("gr").src = "images/g_right_a.gif";
        document.getElementById("gl").src = "images/g_left_a.gif";
    var margin = document.getElementById("e").style.marginLeft;
        margin = margin.replace(/px/g, "");
        marginp = Number.marginp;
        var e = pwidth*elements;
            e = parseInt(e);
        var r = elements*pwidth;
            e = e-r;
    if(margin < e){moveright(0);} 
       margin = parseInt(margin)+pwidth;
       if(margin >= e){document.getElementById("gl").src = "images/g_left.gif";} 
    }else{
        /*MINUS*/
        var now = document.getElementById("now").innerHTML;
        now = parseInt(now);
        if(now >= 0) {
            document.getElementById("gr").src = "images/g_right_a.gif";
            document.getElementById("gl").src = "images/g_left_a.gif";
            document.getElementById("st"+now).style.display="block";
            now = now-1;
            if(now == 0){document.getElementById("gl").src = "images/g_left.gif";}
            document.getElementById("now").innerHTML = now;
        }
    }
    /**/
}

function moveleft(id){
    var marginp = document.getElementById("e").style.marginLeft;
        marginp = marginp.replace(/px/g, "");

        marginp = marginp-10;
    document.getElementById("e").style.marginLeft = marginp;
    //document.getElementById("out").innerHTML += marginp+"_";
    id = id-10;

    if(id == 0){
        /**/
    }
    else {
        setTimeout ('moveleft('+id+')', timeout);
    }
}


function moveright(id){
    var marginp = document.getElementById("e").style.marginLeft;
        marginp = marginp.replace(/px/g, "");
        marginp = parseInt(marginp);
        marginp = marginp+10;
    document.getElementById("e").style.marginLeft = marginp;
    //document.getElementById("out").innerHTML += marginp+"_";
    id = id+10;
    if(id == pwidth){
        /**/
    }
    else {
        setTimeout ('moveright('+id+')', timeout);
    }
}

function load(id) {
    document.getElementById("load").style.display="none";
    document.getElementById("e").style.display="block";
    document.getElementById("sl").style.display="block";
    document.getElementById("sr").style.display="block";
    id = id-10;
    document.getElementById("e").style.marginLeft = id;
    if(id == 0){
        /**/
    }
    else {
        setTimeout ('load('+id+')', 5);
    }
}
