function Previsualizador(id,aF,aFG,aT,aD,rutaVideo,titulo,subTitulo,noImg,noImgG){
	this.aF = aF;	this.aFG = aFG; 	this.aT = aT; 	this.aD = aD; this.rutaVideo = rutaVideo;
	this.contenedor = document.getElementById(id);
	this.thumbs = document.getElementById(id).getElementsByTagName('p')[0];
	this.aElements = this.thumbs.getElementsByTagName('a');
	//alert (this.aElements.length);
	this.ultima = this.aElements.length; this.actualPicture = 0; this.titulo = titulo; this.subTitulo = subTitulo;	this.noImg = noImg;
	this.noImgG = noImgG;

	this.isIe = function(){
		var gko = navigator.userAgent.toLowerCase();
		if (gko.indexOf('gecko')!=-1){ //si soporta gecko, es Mozilla, Netscape, Safari, etc
			return false;//elemento.setAttribute('onclick','alert("hola");ret urn false');//hacemos el setAttribute normalmente
		}else{ //es I Explroer
			return true;//elmento['onclick']=new Function('alert("hola");return false;');//creamos en setAttribute de esta forma
		}
	}
	// comprueba si es explorer ya que toma al DIV como un tag mas asi que se le suma 1 y queda en 3
	// es 3 esta porque el elemento 0 es el contenedor de las fotos, el 1 es el del video, el 2 es el contenedor del video y el 3 es la barra de masimagenes
	// ...aparentemente
	if(this.isIe()){
		this.ulList = document.getElementById(id).getElementsByTagName('p')[3];
	} else {
		this.ulList = document.getElementById(id).getElementsByTagName('p')[2];
	}

	this.openVideo = function(){

			var videoVisible = document.createElement('div'); // div
				(this.obj.isIe())?videoVisible.className='videoVisible':videoVisible.setAttribute('class','videoVisible');
				(this.obj.isIe())?videoVisible.id='videoVisible':videoVisible.setAttribute('id','videoVisible');

			var video = document.createElement('div');
				(this.obj.isIe())?video.className='reproVideo':video.setAttribute('class','reproVideo');

			var object = document.createElement('object');
				(this.obj.isIe())?object.classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000':object.setAttribute('classid','clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');
				(this.obj.isIe())?object.codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0':object.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0');
				(this.obj.isIe())?object.width='405':object.setAttribute('width','405');
				(this.obj.isIe())?object.height='317':object.setAttribute('height','317');
				(this.obj.isIe())?object.id='video':object.setAttribute('id','video');

			var urlVideo = 'swf/video.swf?rutavideo='+this.obj.rutaVideo;
			var paramVideo = document.createElement('param');
				(this.obj.isIe())?paramVideo.name='movie':paramVideo.setAttribute('name','movie');
				(this.obj.isIe())?paramVideo.value=('swf/video.swf?rutavideo='+this.obj.rutaVideo):paramVideo.setAttribute('value',('swf/video.swf?rutavideo='+this.obj.rutaVideo));

			var paramWmode = document.createElement('param');
				(this.obj.isIe())?paramWmode.name='wmode':paramWmode.setAttribute('name','wmode');
				(this.obj.isIe())?paramWmode.value='opaque':paramWmode.setAttribute('value','opaque');

			var embed = document.createElement('embed');
				(this.obj.isIe())?embed.src=('swf/video.swf?rutavideo='+this.obj.rutaVideo):embed.setAttribute('src',('swf/video.swf?rutavideo='+this.obj.rutaVideo));
				(this.obj.isIe())?embed.width='405':embed.setAttribute('width','405');
				(this.obj.isIe())?embed.height='317':embed.setAttribute('height','317');
				(this.obj.isIe())?embed.wmode='opaque':embed.setAttribute('wmode','opaque');
				(this.obj.isIe())?embed.type='application/x-shockwave-flash':embed.setAttribute('type','application/x-shockwave-flash');
				(this.obj.isIe())?embed.pluginspage='http://www.macromedia.com/go/getflashplayer':embed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');


			var tCerrar = document.createTextNode('cerrar');
			var aCerrar = document.createElement('a'); // boton cerrar
				(this.obj.isIe())?aCerrar.href='#':aCerrar.setAttribute('href','#');
				(this.obj.isIe())?aCerrar.className='cerrar':aCerrar.setAttribute('class','cerrar');
				aCerrar.obj = this.obj;
				aCerrar.onclick = function(){
					var eliminar = this.obj.contenedor;
						eliminar.removeChild(document.getElementById('videoVisible'));
					return false;
				}

			this.obj.contenedor.appendChild(videoVisible);

				aCerrar.appendChild(tCerrar);
			videoVisible.appendChild(aCerrar);
			videoVisible.appendChild(video);
			video.appendChild(object);
			//object.appendChild(paramWmode);
			//object.appendChild(paramVideo);
			//object.appendChild(embed);
			return false;
		}




	this.openZoom = function(){

		var pic = this.thumbs==true?this.id:(this.obj.ultima-parseInt(this.obj.ultima/2)-1); // foto seleccionada

			var aElement = document.createElement('div'); // div
				(this.obj.isIe())?aElement.className='zoomVisible':aElement.setAttribute('class','zoomVisible');
				(this.obj.isIe())?aElement.id='zoomVisible':aElement.setAttribute('id','zoomVisible');

			var tCerrar = document.createTextNode('cerrar');
			var aCerrar = document.createElement('a'); // boton cerrar
				aCerrar.setAttribute('href','#');
				(this.obj.isIe())?aCerrar.className='cerrar':aCerrar.setAttribute('class','cerrar');
				aCerrar.obj = this.obj;
				aCerrar.onclick = function(){
					var eliminar = this.obj.contenedor;
						eliminar.removeChild(document.getElementById('zoomVisible'));
					return false;
				}
				aCerrar.appendChild(tCerrar);

			var img = document.createElement('img');
				var bigImg = this.obj.aFG[pic]==undefined?this.obj.noImgG:this.obj.aFG[pic];
				img.setAttribute('src',bigImg);
				img.setAttribute('alt','');
				img.setAttribute('width','480');
				this.img = img;
				(!this.thumbs)?this.obj.actualPicture=pic:this.obj.actualPicture=pic;


			var navegador = document.createElement('div');
				(this.obj.isIe())?navegador.className='navegador':navegador.setAttribute('class','navegador');

				var antText = document.createTextNode(' ');
				var anterior = document.createElement('a');
					anterior.setAttribute('href','#');
					anterior.setAttribute('title','Anterior');
					(this.obj.isIe())?anterior.className='anterior':anterior.setAttribute('class','anterior');
					anterior.obj = this;
					anterior.onclick = function(){
						if(this.obj.obj.actualPicture>0){
							this.obj.obj.actualPicture--;
							this.obj.img.src = this.obj.obj.aFG[this.obj.obj.actualPicture];
							this.obj.h1.innerHTML = this.obj.obj.aT[this.obj.obj.actualPicture];
							this.obj.p.innerHTML = this.obj.obj.aD[this.obj.obj.actualPicture];
							this.obj.obj.setSelected();
						}
						return false;
					}
					anterior.appendChild(antText);
				navegador.appendChild(anterior);



				for(a=0;a<this.obj.aF.length;a++){
					var aET = document.createTextNode(a+1);
					var aE = document.createElement('a');
						aE.setAttribute('href','#');
						aE.appendChild(aET);
						aE.obj = this;
						aE.pic = a;
						//aE.className = '';
						a==pic?(this.obj.isIe())?aE.className='seleccionado':aE.setAttribute('class','seleccionado'):'';
						aE.onclick = function(){
							this.obj.img.src = this.obj.obj.aFG[this.pic];
							this.obj.h1.innerHTML = this.obj.obj.aT[this.pic];
							this.obj.p.innerHTML = this.obj.obj.aD[this.pic];
							this.obj.obj.actualPicture = this.pic;
							this.obj.obj.setSelected();
							//this.className = 'seleccionado';
							return false;
						}
					navegador.appendChild(aE);
				}

				var sigText = document.createTextNode(' ');
				var siguiente = document.createElement('a');
					siguiente.setAttribute('href','#');
					siguiente.setAttribute('title','Siguiente');
					(this.obj.isIe())?siguiente.className='siguiente':siguiente.setAttribute('class','siguiente');
					siguiente.obj = this;
					siguiente.onclick = function(){
						if(this.obj.obj.actualPicture<(this.obj.obj.aFG.length-1)){
							this.obj.obj.actualPicture++;
							this.obj.img.src = this.obj.obj.aFG[this.obj.obj.actualPicture];
							this.obj.h1.innerHTML = this.obj.obj.aT[this.obj.obj.actualPicture];
							this.obj.p.innerHTML = this.obj.obj.aD[this.obj.obj.actualPicture];
							this.obj.obj.setSelected();
						}
						return false;
					}
					siguiente.appendChild(sigText);
				navegador.appendChild(siguiente);
				this.obj.navegador = navegador;


			var tH1 = document.createTextNode(this.obj.aT[pic]==undefined?this.obj.titulo:this.obj.aT[pic]);
			var h1 = document.createElement('h1');
				(this.obj.isIe())?h1.className='zoom':h1.setAttribute('class','zoom');
				h1.appendChild(tH1);
				this.h1 = h1;

			var tP = document.createTextNode(this.obj.aD[pic]==undefined?this.obj.subTitulo:this.obj.aD[pic]);
			var p = document.createElement('p');
				(this.obj.isIe())?p.className='zoom':p.setAttribute('class','zoom');
				p.appendChild(tP);
				this.p = p;



			aElement.appendChild(aCerrar);
			aElement.appendChild(img);
			aElement.appendChild(navegador);
			aElement.appendChild(h1);
			aElement.appendChild(p);

			//this.setSelected();
			this.obj.contenedor.appendChild(aElement);
			return false;
	}



	this.menosFotos = function(){
		if(this.ultima>this.aElements.length){
			var num = this.ultima - this.aElements.length - 1;
			for(a=this.aElements.length;a>0;a--){ //

				var aTag = this.aElements[a-1];
					aTag.title = this.aT[num];
					aTag.id = num;
				var img = this.aElements[a-1].getElementsByTagName('img')[0];
					img.alt = this.aT[a];
					img.src = this.aF[num];
				num--;
				this.ultima--;
				aTag.style.display = '';
			}
		}
	}

	this.masFotos = function(){
		if((this.aF.length)>this.ultima){
			//var siguientesSeis = this.aF.length - this.aElements.length;
			for(a=0;a<this.aElements.length;a++){ //
			//for(a=0;a<siguientesSeis;a++){
				this.ultima++;
				var aTag = this.aElements[a];
					aTag.title = this.aF.length<this.ultima?this.titulo:this.aT[this.ultima-1];
					aTag.id = this.ultima-1;
				var img = this.aElements[a].getElementsByTagName('img')[0];
					if(this.aF.length<this.ultima){
						img.alt = this.titulo;
						img.src = this.noImg;
						aTag.style.display = 'none';
					} else {
						img.alt = this.aT[a-1];
						img.src = this.aF[this.ultima-1];
					}
			}
		}
	}

	if(this.aElements.length>1){
		/*var verFotos = this.ulList.getElementsByTagName('a')[0];
			verFotos.thumbs = false;
			verFotos.obj = this;
			verFotos.onclick = this.openZoom;

		var verVideo = this.ulList.getElementsByTagName('a')[1];
			verVideo.obj = this;
			verVideo.onclick = this.openVideo;*/

		var span_opciones = this.ulList.getElementsByTagName('span')[0];
		if(span_opciones != undefined) {
			var verMas = span_opciones.getElementsByTagName('a')[0];
				verMas.obj = this;
				verMas.onclick = function(){
					this.obj.masFotos();
					return false;
				}

			var verMenos = span_opciones.getElementsByTagName('a')[1];
				verMenos.obj = this;
				verMenos.onclick = function(){
					this.obj.menosFotos();
					return false;
				}
		}
	}

	this.setSelected = function(){
		nFoto = this.navegador.getElementsByTagName('a');
		for(a=0;a<nFoto.length;a++){
			if(a==this.actualPicture){
				(this.isIe())?nFoto[a+1].className='seleccionado':nFoto[a+1].setAttribute('class','seleccionado');
			} else {
				if((a+1)<(nFoto.length-1)){
					nFoto[a+1].className = '';
				}

			}
		}
		return false;
	}

	for(a=0;a<this.aElements.length;a++){ //
		this.aElements[a].id = a;
		this.aElements[a].thumbs = true;
		this.aElements[a].obj = this;
		this.aElements[a].title = this.aT[a];
		this.aElements[a].onclick = this.openZoom;
	}



}

