var mKey,mKeynum;
var intervalo;
var author="julifos";
var versionx="2.0";

document.onkeydown = myKeyDown;

function myKeyDown() {
	mKeynum =event.keyCode;
	x = top.lf.current_img;
	if (mKeynum == 39 || mKeynum == 40) { // left
		top.lf.current_img++;
	} else if (mKeynum == 37 || mKeynum == 38) {
		top.lf.current_img--;
	}
	paYohazAlgo();
}

function paYohazAlgo() {
	if (x != top.lf.current_img) { // si hay cambios...
		if (top.lf.current_img == parent.frames['lf'].index_array.length) {
			top.lf.current_img = x;
			alert("You reached the last image!");
		} else if (top.lf.current_img == -1) {
			top.lf.current_img = 0;
			alert("You reached the first image!");
		} else {
			parent.frames['lf'].kambia(top.lf.current_img);
		}
	}

}

function doIt(m) {
	x = top.lf.current_img;
	if (m == 0) {
		top.lf.current_img--;
	} else {
		top.lf.current_img++;
	}
	paYohazAlgo();
}

var slideShowInProgress = false;

function rotarmundi(){
	if(this.slideShowInProgress){
 		kannabis = top.lf.current_img;
		if (kannabis == ((parent.frames['lf'].index_array.length)-1)) {
			top.lf.current_img = -1;
		}
		doIt(1);
		setTimeout("rotarmundi()", intervalo);
	} else {
		document.slideshowx.src = "start.gif";
	}
}

function slideshow(){
	if (this.slideShowInProgress) {
		this.slideShowInProgress=false;
		document.slideshowx.src = "start.gif";
	} else {
		this.slideShowInProgress=true;
		document.slideshowx.src = "stop.gif";
		promptear(); 
	}
}

function promptear(){
	intervalo=prompt("Interval between fonts (in seconds)...\rE.g.> 3, 1.5, 10...","3");
	if (intervalo != null) {
		intervalo=intervalo*1000;
		rotarmundi();
	}
}