function slideShow(name,aPictures,aCaptions,objPic)
{
	this.create = false;
	if (aPictures.length <= 0) {return false;}
	// ==============================
	// Set the following variables...
	// ==============================
	if (objPic == null){objPic = "divPictureBox";}
	if (!document.getElementById(objPic)) return false;
	this._div = objPic;
	this.name = name;
	// Set the slideshow speed (in milliseconds)
	this.SlideShowSpeed = 4000;
	this.MessageShowSpeed = 2000;
	this.pathScript = "common/slideshow/";
	this.pathImg = "../UserFiles/banner/";
	this.pathImgButton = "../image/slideshow/";
	this.imgUp = "fup.gif";
	this.imgDn = "fdn.gif";
	this.imgCg = "loading6.gif";
	this.altMessage = "Loading...";
	
	//Datos de la imagen
	this.imgName = "img"+objPic;
	this.width = 145; //265;
	this.height = 100; //197;
	this.background = "#ffffff";
	
	this.msgPic = "msg"+objPic;
	this.tableName = "table"+objPic;
	
	
	
	// Set the duration of crossfade (in seconds)
	this.CrossFadeDuration = 2;

	this.showHot = false; // don't change this
	this.saveCookies = false;
	if (this.saveCookies) {
		this.ck = new CookieJar({
			expires:3600, // seconds
			path: '/'
			});	
	}
	this.jss = (this.saveCookies) ? this.loadCookie("numfoto") : 0;
	this.pss = aPictures.length-1;
	if (this.jss > this.pss) this.jss = 0;
	this.Id;
	this.msgId;
	this.swAutomatic = true;
	this.pictures = aPictures;
	this.preLoad = new Array();
	this.create = true;
	this.showCtrlPanel = false; // Muestra (true) o Oculta (false) el panel que enumera a la derecha las imágenes que hay
	this.showControls = false; // Activa la función de pararse o continuar.
	this.draw();
	this.hasImages = this.preload(aPictures);
	this.start = true;
}

slideShow.prototype.loadCookie = function(vari)
	{
		if (!this.ck) return false;
		var slideShow = this.ck.get(this.name);
		if (slideShow == null)
			return 0;
		return slideShow.vari;
	}
slideShow.prototype.saveCookie = function(vari,value)
	{
		if (!this.ck) return false;
		var slideShow = {vari: value};
		this.ck.put(this.name,slideShow);
	}

slideShow.prototype.preload = function(aPictures)
	{
		for (var iss = 0; iss <= this.pss; iss++)
		{
			this.preLoad[iss] = new Image();
			this.preLoad[iss].src = this.pathImg+aPictures[iss];
		}
		return (this.preLoad.length > 0);
	}
	
slideShow.prototype.restoreCSS = function ()
	{
		if (!this.showCtrlPanel) return false;
		newImage = document.getElementById("num"+this.name+this.jss);
		newImage.className = "none";
/*		if (this.jss > 0)
		{
	   		newImage = document.getElementById("num"+this.name+this.jss);
	  		newImage.className = "none";
		}
*/
	}
slideShow.prototype.control	= function control(how)
	{
	  this.restoreCSS();
	  if (this.showHot)
		{
		  if (how=='H') this.jss = 1;
		  if (how=='B') this.jss = this.jss - 1;
		  if (how=='F') 
		  {
			  if (this.start)
			  {
				  this.start = false;
			  }else{
				  /*if(this.jss==0)
				  {this.jss=-1;}//else{this.jss++;}*/
				  this.jss++;
				  if (this.saveCookies) {this.saveCookie("numfoto",this.jss);}
			  }
		  }
		  if (this.jss > (this.pss)) this.jss=0;
		  if (this.jss < 0) this.jss = this.pss;
		  this.cargar_foto(this.jss);
		}
	}
	
slideShow.prototype.no_automatic = function()
	{
		window.clearTimeout(this.Id);
	}
	
slideShow.prototype.automatic = function()
	{
		this.Id = window.setTimeout (this.name+".control('F')", this.SlideShowSpeed); 
	}
	
slideShow.prototype.auto_message = function(msg)
	{
		if (!this.showControls){return false;}
		window.clearTimeout(this.msgId);
		this.msgId = window.setTimeout(this.name+".hideMessage();", this.MessageShowSpeed);
		var omsgPic = document.getElementById(this.msgPic);
		omsgPic.innerHTML = msg;
		omsgPic.style.display = 'block';
	}

slideShow.prototype.getPositionMessage = function()
	{
		var omsgPic = document.getElementById(this.msgPic);
		var ww  = $(this._div).getDimensions();
		posY = Math.floor(ww.height/3)*2;
		omsgPic.style.top = posY+"px";
		/*debugger;
		var px = $(this.name+"ControlPanel").getDimensions().width;
		var px = ww.width - px;
		posX = Math.floor((px-omsgPic.getDimensions().width)/2);*/
		var xx = omsgPic.getDimensions().width;		
		var px = this.width-xx+8;
		if (px > 0)	posX = Math.floor((px)/2);
		else posX = 0;
		omsgPic.style.left = posX+"px";
		omsgPic.style.backgroundColor = "#FC0";
	}
	
slideShow.prototype.hideMessage = function()
	{
		window.clearTimeout(this.msgId);
		document.getElementById(this.msgPic).style.display = 'none';
	}
	
slideShow.prototype.cargar_foto	= function(numfoto)
	{
		 	this.restoreCSS();
			if (!this.showHot) return false;
			if (this.preLoad.length <= 0) return false;
			
			/* if (document.all&&!window.opera)
			{
			  //document.images.PictureBox.style.filter='blendTrans(duration=2)';
			  this.objPic.style.filter='blendTrans(duration='+this.CrossFadeDuration+')';
			  this.objPic.filters.blendTrans.Apply();
			}else{ */
				new Effect.Opacity(
				   this.objPic, { 
					  from: 1.0, 
					  to: 0.0,
					  duration: 0.5,
					  afterFinish: function(el){
						  el.element.src = objSlide.preLoad[numfoto].src;
						  new Effect.Opacity(
						   el.element, { 
							  from: 0.0, 
							  to: 1.0,
							  duration: 0.5
						   });
						 
					  }
				   }
				);
			//}
		 // if (document.getElementById) document.getElementById('CaptionBox').innerHTML= Caption[jss];
		 /* if (document.all&&!window.opera) this.objPic.filters.blendTrans.Play();
		  else{
				new Effect.Opacity(
				   this.objPic, { 
					  from: 0.0, 
					  to: 1.0,
					  duration: 0.5
				   }
				);	  
		  }*/
		  if (this.showCtrlPanel){
			  newImage = document.getElementById("num"+this.name+numfoto);
			  newImage.className = "img";
		  }
		  if (this.swAutomatic){this.no_automatic();this.automatic();}
		  this.jss = numfoto;
	}
slideShow.prototype.slide_stop	= function()
	{if (!this.showControls){return false;}this.swAutomatic = false;this.no_automatic();this.auto_message("Stop");}
slideShow.prototype.slide_start	= function()
	{if (!this.create){return false;}this.swAutomatic = true;this.automatic();this.auto_message("Play");}
	
slideShow.prototype.draw = function(){
if (!this.create){return false;}
strOut = "";
if (this.showControls){
strOut += "	<div id=\""+this.msgPic+"\" name=\""+this.msgPic+"\" ";
strOut += " onMouseOver=\""+this.name+".slide_stop()\" onMouseOut=\""+this.name+".slide_start()\" ";
strOut += " class=\"texto_slide\"></div>";
}
//width=\""+this.width+"\" height=\""+this.height+"\"
strOut += "<table id=\""+this.tableName+"\" name=\""+this.tableName+"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
strOut += "  <tr>";
strOut += "    <td width=\""+this.width+"\" align=\"center\" style=\"background-color:"+this.background+";\" height=\""+this.height+"\">";
strOut += "		<img src='"+this.pathImgButton+this.imgCg+"' alt='"+this.altMessage+"' ";
strOut += "		name='"+this.imgName+"' id='"+this.imgName+"' style=\"display:block; width:"+this.width+"px; max-height:"+this.height+"px; border:0px\" ";
strOut += "		title='"+this.altMessage+"' ";
if (this.showControls){
strOut += " onMouseOver=\""+this.name+".slide_stop()\" onMouseOut=\""+this.name+".slide_start()\"";
}
strOut += "/>";
strOut += "	</td>";
if (this.showCtrlPanel){
	strOut += "<td class=\"button\" colspan=\"3\" align=\"center\">";
	strOut += "<table border=\"0\" id=\""+this.name+"ControlPanel\">";
	strOut += "    <td class=\"button\" colspan=\"3\" align=\"center\">";
	strOut += "		<a href='javascript:;' onClick=\""+this.name+".control('B')\">";
	strOut += "			<img src='../adm/js/"+this.pathImgButton+this.imgUp+"' width=\"8\" height=\"10\" border=\"0\" />";
	strOut += "		</a>";
	strOut += "	</td>";
	strOut += "  </tr>";
	for (n=0;n<=this.pss;n++){
		if (n <= this.pss)
		{
			strOnClick = (this.pictures[n] != "") ? "onClick=\""+this.name+".cargar_foto("+n+")\"" : "";
			txtLink = n+1;
			txtLink = (txtLink < 10) ? "0"+txtLink : txtLink;
			strLink = "<a href=\"javascript:;\" onClick=\""+this.name+".cargar_foto("+n+");\">"+txtLink+"</a>";
			//strLink = n;
		}else{
			strOnClick = "";
			strLink = "&nbsp";	
		}
		strOut += "  <tr class=\"out\" onMouseOver=\"this.className='over'\" onMouseOut=\"this.className='out'\" "+strOnClick+">";
		strOut += "    <td class='none'>&nbsp;</td>";
		strOut += "    <td id=\"num"+this.name+n+"\" align=\"center\" class='none'>"+strLink+"</td>";
		strOut += "    <td class='none'>&nbsp;</td>";
		strOut += "  </tr>";
	}
	strOut += "  <tr>";
	strOut += "    <td class=\"button\" colspan=\"3\" align=\"center\">";
	strOut += "		<a href='javascript:;' onClick=\""+this.name+".control('F')\">";
	strOut += "			<img src='../adm/js/"+this.pathImgButton+this.imgDn+"' width=\"8\" height=\"10\" border=\"0\" />";
	strOut += "		</a>";
	strOut += "	</td>";
	strOut += "</table>";
	strOut += "	</td>";
}
strOut += "  </tr>";
strOut += "</table>";
//window.console.log("<pre>"+strOut+"</pre>");
domlay(this._div,1,1,1,strOut);
this.objPic = document.getElementById(this.imgName); // eval("document.image."+this.imgName);
this._table = document.getElementById(this.tableName);
document.getElementById(this._div).className = "slideshow";
if (this.showControls){this.getPositionMessage();}
this.showHot = true;
}

function domlay(id,trigger,lax,lay,content) {
	/*
	 * Cross browser Layer visibility / Placement Routine	
	 * Done by Chris Heilmann (mail@ichwill.net)
	 * http://www.ichwill.net/mom/domlay/
	 * Feel free to use with these lines included!
	 * Created with help from Scott Andrews.
	 * The marked part of the content change routine is taken
	 * from a script by Reyn posted in the DHTML
	 * Forum at Website Attraction and changed to work with
	 * any layername. Cheers to that!
	 * Welcome DOM-1, about time you got included... :)
	 */
	// Layer visible
	if (trigger=="1"){
		if (document.layers) document.layers[''+id+''].visibility = "show"
		else if (document.all) document.all[''+id+''].style.visibility = "visible"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
		}
	// Layer hidden
	else if (trigger=="0"){
		if (document.layers) document.layers[''+id+''].visibility = "hide"
		else if (document.all) document.all[''+id+''].style.visibility = "hidden"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
		}
	// Set horizontal position
	if (lax){
		if (document.layers){document.layers[''+id+''].left = lax}
		else if (document.all){document.all[''+id+''].style.left=lax}
		else if (document.getElementById){document.getElementById(''+id+'').style.left=lax+"px"}
		}
	// Set vertical position
	if (lay){
		if (document.layers){document.layers[''+id+''].top = lay}
		else if (document.all){document.all[''+id+''].style.top=lay}
		else if (document.getElementById){document.getElementById(''+id+'').style.top=lay+"px"}
		}
	// change content

	if (content){
	if (document.layers){
		sprite=document.layers[''+id+''].document;
		// add father layers if needed! document.layers[''+father+'']...
		sprite.open();
		sprite.write(content);
		sprite.close();
		}
	else if (document.all) document.all[''+id+''].innerHTML = content;
	else if (document.getElementById){
		//Thanx Reyn!
		rng = document.createRange();
		el = document.getElementById(''+id+'');
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(content)
		while(el.hasChildNodes()) el.removeChild(el.lastChild);
		el.appendChild(htmlFrag);
		// end of Reyn ;)
		}
	}
}