
	// Browser Slide-Show script.
	// With image cross fade effect for those browsers that support it.
	var slideCache = new Array();
	var pause = 1;
	var old_pause_images;
	var anterior_images;
	var velocidad = 2000;
	var t;
	var horas = new Array();

	function RunSlideShow(pictureName,imageFiles)
	{
		
		var imageSeparator = imageFiles.indexOf(";");
		var nextImage = imageFiles.substring(0,imageSeparator);

		var imageSeparator2 = imageFiles.lastIndexOf(";",imageFiles.length-3);
		var lastImage = imageFiles.substring(imageSeparator2+1, imageFiles.length);

		anterior_images = lastImage + ';' + imageFiles.substring(0,imageSeparator2);
		
		var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length) + ';' + nextImage;
		
		
		old_pause_images = futureImages;


		
// 			if (document.all)
// 			{
// 				document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
// 				document.getElementById(pictureName).filters.blendTrans.Apply();
// 			}
		
			document.getElementById(pictureName).src = nextImage;
			pintar_hora(nextImage);
// 			hora_ele = document.getElementById("hora_image");
// 			alert(document.getElementById(pictureName).fileModifiedDate);
// 			hora_ele.innerHTML = document.getElementById(pictureName).fileModifiedDate;
// 			hora_ele.innerHTML = 12;
		
// 			if (document.all)
// 			{
// 				document.getElementById(pictureName).filters.blendTrans.Play();
// 			}

		
			t = setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"')", velocidad);
		
			// Cache the next image to improve performance.
			imageSeparator = futureImages.indexOf(";");
			nextImage = futureImages.substring(0,imageSeparator);
		
			if (slideCache[nextImage] == null) {
				slideCache[nextImage] = new Image;
				slideCache[nextImage].src = nextImage;
			}
		
	}

	function pauseee(){
		pause = 0;
		clearTimeout(t);
// 		alert(old_pause_images);
	}

	function continueee(){
// 		alert(old_pause_images);
		clearTimeout(t);
		RunSlideShow("Fotos",old_pause_images);
	}

	function siguiente(){
// 		pause = 1;
		clearTimeout(t);
		RunSlideShow("Fotos",old_pause_images);
		clearTimeout(t);
	}

	function anterior(){
// 		alert(anterior_images);
		clearTimeout(t);
		RunSlideShow("Fotos",anterior_images);
		clearTimeout(t);
	}

	function menos_velocidad(){
		velocity();
		velocidad = velocidad + 500;
		createCookie("velocidad_webcams", velocidad, 7);
		velocity();
	}

	function mas_velocidad(){
		velocity();
		velocidad = velocidad - 500;
		if (velocidad < 500){
			velocidad = 500;
		}
		createCookie("velocidad_webcams", velocidad, 7);
		velocity();
	}

	function velocity(){
		var vel_coo = parseFloat(readCookie("velocidad_webcams"));
		

		if (vel_coo)
		{
			velocidad = vel_coo;
		} else {
			createCookie("velocidad_webcams", velocidad, 7);
		}

// 		alert(vel_coo);
		ele_vel = document.getElementById("vel");
		ele_vel.innerHTML = velocidad / 1000;

	}

	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

	function add_hora(i, hora){
		horas[i] = hora;
	}

	function pintar_hora(urli){
// 		alert(urli);
		z = index_hora(urli);
		hora_ele = document.getElementById("hora_image");
		hora_ele.innerHTML = horas[z];
	}

	function index_hora(urli){
		var sep = urli.split('/');
		var num = sep[3].substring(0, sep[3].length-4);
		return num;
	}

	function starter(pictureName,imageFiles)
	{
		var imageSeparator = imageFiles.indexOf(";");
		var nextImage = imageFiles.substring(0,imageSeparator);

		var imageSeparator2 = imageFiles.lastIndexOf(";",imageFiles.length-3);
		var lastImage = imageFiles.substring(imageSeparator2+1, imageFiles.length);

		anterior_images = lastImage + ';' + imageFiles.substring(0,imageSeparator2);

		document.getElementById(pictureName).src = lastImage;

		cuenta_atras(5000, pictureName, imageFiles);
	}

	function cuenta_atras(tiempo, pictureName, imageFiles)
	{
		if (tiempo == -1000){
			RunSlideShow( pictureName,imageFiles );
			exit;
		}
		nuevo_t = tiempo - 1000;
		hora_ele = document.getElementById("hora_image");
		hora_ele.innerHTML = "Última imagen! Play en: "+tiempo /1000;
		//  + (tiempo / 1000)+";
		t = setTimeout("cuenta_atras('"+nuevo_t+"', '"+pictureName+"','"+imageFiles+"')", 1000);
	}
