
function confirmar( pregunta, destinoSi )
{
	if( confirm(pregunta) )
	{
		window.location.assign(destinoSi);
	}
}
function rollOver( elemento, sufijo )
{
	elemento = $(elemento);
	if(sufijo === undefined) sufijo = 'Over';
	if(!elemento.className.endsWith(sufijo)) elemento.className += sufijo;
}
function rollOut( elemento, sufijo )
{
	elemento = $(elemento);
	if(sufijo === undefined) sufijo = 'Over';
	if(elemento.className.endsWith(sufijo)) 
		elemento.className = elemento.className.slice(0, elemento.className.length-sufijo.length);
}
function iconoOver( elem )
{
	var imagen = elem.getElementsByTagName('img')[0];
	if(imagen !== undefined)
	{
		if( imagen.__ouSrc ) imagen.src = imagen.__ouSrc;
		else
		{
			var fuente = (typeof(imagen.src__orig) == 'undefined') ? imagen.src : imagen.src__orig; 
			var longitud = fuente.length;
			var extension = fuente.substr(longitud-4);
			imagen.__ovSrc = fuente;
			var fuenteOver = fuente.substr(0, longitud-4);
			fuenteOver += ((!fuenteOver.endsWith('Over')) ? 'Over'+extension : extension);
			imagen.src = fuenteOver;
			imagen.__ouSrc = fuenteOver;
		}
	}
}
function iconoOut( elem )
{
	var imagen = elem.getElementsByTagName('img')[0];
	if(imagen !== undefined && imagen.__ovSrc) imagen.src = imagen.__ovSrc;
}

DeslizVert = Class.create();
Object.extend(DeslizVert.prototype, {
	
	initialize:function( contenedor, btns )
	{
		this.efecto = false;
		this.duracion = 0.5;
		this.desliz = $( $(contenedor).firstChild );
		this.altoCont = $(contenedor).getHeight();
		this.altoDesliz = this.desliz.getHeight();
		
		this.idIntervalo = false;
		this.desplazamiento = 4;
		this.tpo = 5;

		if(this.altoCont >= this.altoDesliz) 
		{
			$(btns).hide();
			$(contenedor).removeClassName('padDcha1');
			return;
		}
		this.desliz.setStyle({position: 'absolute', overflow: 'hidden'});
		
		var esto = this;
		/*$(btns+'Arr').onclick = function(){ esto.anterior() };
		$(btns+'Aba').onclick = function(){ esto.siguiente() };*/
		$(btns+'Arr').onmousedown = function(){ esto.subir() };
		$(btns+'Aba').onmousedown = function(){ esto.bajar() };
		$(btns+'Arr').onmouseup = $(btns+'Aba').onmouseup = function(){ esto.parar() };
	},
	parar:function()
	{
		clearInterval(this.idIntervalo);
	},
	bajar:function()
	{
		if(this.idIntervalo) this.parar();
		this.idIntervalo = setInterval(this._bajar.bind(this), this.tpo);
		this._bajar();
	},
	_bajar:function()
	{
		var posActual = parseInt(this.desliz.getStyle('top'));
		if( isNaN(posActual) ) posActual = 0;
		
		if( this.altoDesliz+posActual-this.altoCont+8 < 0 ) 
			this.parar();
		else 
			this.desliz.setStyle({top: (posActual-this.desplazamiento)+'px'});
	},
	subir:function()
	{
		if(this.idIntervalo) this.parar();
		this.idIntervalo = setInterval(this._subir.bind(this), this.tpo);
		this._subir();
	},
	_subir:function()
	{
		var posActual = parseInt(this.desliz.getStyle('top'));
		if( isNaN(posActual) ) posActual = 0;
		
		if( posActual >= 0 )
			this.parar();
		else 
			this.desliz.setStyle({top: (posActual+this.desplazamiento)+'px'});
	},
	siguiente:function()
	{
		if( this.efecto && this.efecto.state != 'finished' ) return;

		var posActual = parseInt(this.desliz.getStyle('top'));
		if( isNaN(posActual) ) posActual = 0;
		
		if( this.altoDesliz + posActual - this.altoCont > 0 )
			this.efecto = new Effect.Move(this.desliz, {y: -this.altoCont, duration: this.duracion});
	},
	anterior:function()
	{
		if( this.efecto && this.efecto.state != 'finished' ) return;

		var posActual = parseInt(this.desliz.getStyle('top'));
		if( isNaN(posActual) ) posActual = 0;
		
		if( posActual < 0 )
			this.efecto = new Effect.Move(this.desliz, {y: this.altoCont, duration: this.duracion});
	}
});
