//*************** CONFIGURATIÓN ***************//

//***** Number of Images in the Slide Show *****//
var _SLIDE_NUM_IMG = "_SLIDE_NUM_IMG";

//***** Speed of slides *****//
var _SLIDE_SPEED = 3000;	// in miliseconds

//******************* Main *******************//
// 
function Slideshow(object_num)
{
	if(object_num == null)
	{
		this.object_num = "mySlide";
	}else{
		this.object_num = object_num;
	}
	this.images_list = new Array();
	this.position = 0;

	this.add_image = add_image;
	this.roll_slides = false;
	
	this.auto = auto;
	this.stop = stop;
	
	this.create_slide = create_slide;

	slide_id = setTimeout(this.object_num + ".auto()", _SLIDE_SPEED);

}

function add_image(list)
{
	for(i = this.images_list.length; i < add_image.arguments.length; i++)
	{
		this.images_list[i] = add_image.arguments[i];
	}
}


function auto()
{
	this.roll_slides = true;
	if( this.position >= this.images_list.length-1 )
	{
		this.position = 0;
	}else{
		this.position++;
	}
	document.getElementById(this.image_number).src = this.images_list[this.position];
	slide_id = setTimeout(this.object_num + ".auto()", _SLIDE_SPEED);
}

function stop()
{
	if( this.roll_slides )
		clearTimeout(slide_id);
}

function create_slide()
{
	salida = "";
	salida = "<table border='1' cellspacing='0' cellpadding='0'>";
	salida += "<tr>";
	salida += "<td valign='middle'";
  salida += " colspan='2'>";
	if(this.images_list.length == 0)
	{
		salida += "<b>:: No images have been defined ::</b>";
	}else{
		salida += "<img border='0'id='"+ this.image_number +"' src='" + this.images_list[this.position] +"'>";
	}
	salida += "</td>";
	salida += "</table>";
	
	document.writeln(salida);
}

/***** END *****/
