function pic(pictureid) {
    
    if (pictureid == loaded) {
    	return;
    }
    
    var picturebox = document.getElementById("viewerpic");
    var data = picture[pictureid]; 
    var arrowleft = document.getElementById("viewerleft_pic");
    var arrowright = document.getElementById("viewerright_pic");
    
    
    picturebox.src = data["url"];
    picturebox.alt = data["text"];
    picturebox.title = data["text"];
        
    if (data["last"] >= 0) {
    	arrowleft.style.display = "block";
    	left = data["last"];
    }
    else {
	arrowleft.style.display = "none";
    	left = -1;
    }

    if (data["next"] >= 0) {
    	arrowright.style.display = "block";
    	right = data["next"];
    }
    else {
	arrowright.style.display = "none";
    	right = -1;
    }
    

    document.getElementById("viewertext").innerHTML = data["text"];
}

function leftclick() {
    if (left >= 0) {
    	pic(left);
    }
}

function rightclick() {
    if (right >= 0) {
    	pic(right);
    }
}

var picture = new Array();
var loaded = -1;
var left = -1;
var right = -1;
