//Relleno footer (el valor debe ser mayor que 0)
rellenoExtra = 10

//imagen en popup
ancho = 600
alto = 400

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function videos(video){
	document.write('<embed src="videos/'+video+'" width="320" height="250" align="bottom"></embed>');
}
function videos2(video){
	document.write('<embed src="videos/'+video+'" width="320" height="250" align="bottom"></embed>');
}
function videos3(video){
	document.write('<embed src="videos/'+video+'" width="320" height="250" align="bottom" autostart="false"></embed>');
}

function newWindow(imagen) {
	opciones = 'width='+ancho+',height='+alto+', scrollbars=yes'
	imageWindow = window.open(imagen, "imageWin", opciones)
	imageWindow.document.write("<html><head><title>Dreams<\/title><\/head>")
    imageWindow.document.writeln("<body bgcolor='#000000' bottommargin='0' leftmargin='0' topmargin='0' rightmargin='0'><div align='center'><img src='"+imagen+"' /></div>")
    imageWindow.document.writeln("<\/body><\/html>")
	imageWindow.focus()
	imageWindow.document.close()                                                       
}

function newWindowVert(imagen) {
	opciones = 'width='+alto+',height='+ancho+', scrollbars=yes'
	imageWindow = window.open(imagen, "imageWin", opciones)
	imageWindow.document.write("<html><head><title>Dreams<\/title><\/head>")
    imageWindow.document.writeln("<body bgcolor='#000000' bottommargin='0' leftmargin='0' topmargin='0' rightmargin='0'><div align='center'><img src='"+imagen+"' /></div>")
    imageWindow.document.writeln("<\/body><\/html>")
	imageWindow.focus()
	imageWindow.document.close()                                                       
}

function newVideo(video) {
	imageWindow = window.open(video, "videoWin", "width=380,height=370, scrollbars=no")
	imageWindow.focus()
	imageWindow.document.close()                                                       
}


function flashPlayer(video,fv){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="240" id="video1" align="middle">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="allowFullScreen" value="false" />')
	document.write('<param name="movie" value="'+video+'" />')
	document.write('<param name="flashVars" value="'+fv+'" />')
	document.write('<param name="quality" value="high" />')
	document.write('<param name="wmode" value="transparent" />')
	document.write('<param name="bgcolor" value="#000000" />')
	document.write('<embed src="'+video+'" flashVars="'+fv+'" quality="high" bgcolor="#000000" width="320" height="240" name="video" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"  wmode="transparent"/>')
	document.write('</object>')
}

function flashPlayer2(video,fv){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="240" id="video1" align="middle">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="allowFullScreen" value="false" />')
	document.write('<param name="movie" value="'+video+'" />')
	document.write('<param name="flashVars" value="'+fv+'" />')
	document.write('<param name="quality" value="high" />')
	document.write('<param name="wmode" value="transparent" />')
	document.write('<param name="bgcolor" value="#000000" />')
	document.write('<embed src="'+video+'" flashVars="'+fv+'" quality="high" bgcolor="#000000" width="320" height="262" name="video" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"  wmode="transparent"/>')
	document.write('</object>')
}

function showFlash(nombre,width,height){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">'); 
	document.write('<param name="movie" value="'+nombre+'" />'); 
    document.write('<param name="quality" value="high" />'); 
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="'+nombre+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'); 
    document.write('</object>');
}

function menuFlash(nombre,width,height,num){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">'); 
	document.write('<param name="movie" value="'+nombre+'?botonon='+num+'" />'); 
    document.write('<param name="quality" value="high" />'); 
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="'+nombre+'?botonon='+num+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'); 
    document.write('</object>');
}


function menuSuperior(num){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="858" height="130" title="Menu sup">'); 
	document.write('<param name="movie" value="menusuperior.swf?botonon='+num+'" />'); 
    document.write('<param name="quality" value="high" />'); 
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="BGCOLOR" value="#000000" />');
    document.write('<embed src="menusuperior.swf?botonon='+num+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="858" height="130" bgcolor="#000000"></embed>'); 
    document.write('</object>');
}
function menuSuperiorEng(num){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="858" height="130" title="Menu sup">'); 
	document.write('<param name="movie" value="menusuperior_eng.swf?botonon='+num+'" />'); 
    document.write('<param name="quality" value="high" />'); 
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="BGCOLOR" value="#000000" />');
    document.write('<embed src="menusuperior_eng.swf?botonon='+num+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="858" height="130" bgcolor="#000000"></embed>'); 
    document.write('</object>');
}

function video(nombre,width,height,fv){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">'); 
	document.write('<param name="movie" value="'+nombre+'" />'); 
	document.write('<param name="flashvars" value="'+fv+'" />'); 
	document.write('<param name="align" value="middle" />'); 
	document.write('<param name="quality" value="high" />'); 
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="'+nombre+'" width="'+width+'" height="'+height+'" quality="high" flashvars="'+fv+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'); 
	document.write('</object>');
    
}

function insertaFlashPng(nombreF,nombreP,width,height,opc){
	if (document.all||(!opc)){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">'); 
		document.write('<param name="movie" value="'+nombreF+'" />'); 
    	document.write('<param name="quality" value="high" />'); 
    	document.write('<param name="wmode" value="transparent" />');
    	document.write('<embed src="'+nombreF+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'); 
    	document.write('</object>');
	}
	else{
		if (opc){
			document.write('<img src="'+nombreP+'" border="0" />');
		}
	}
}

/*******************/

/***************************/
			function ajustFooter_ant(){
					posFooter = document.getElementById("footer").offsetTop;
					spaFooter = document.getElementById("footerSpacer");
					if (document.all){
						relleno=50;
						extra=0;
						if (screen.height > 768){
							extra=screen.height-768;
						}
						if (posFooter < 550){
							spacer=(550-posFooter)+extra+relleno;
							spaFooter.style.height=spacer + "px";
						}
					}
					else {
						dif=window.innerHeight-posFooter;
						if (dif>40)
						spaFooter.style.height = dif + "px"
					}
		}
		
			function ajustFooter(){
					posFooter = document.getElementById("footer").offsetTop;
					spaFooter = document.getElementById("footerSpacer");
					if (document.all){
						relleno=20;
						spacer=0;
						dif=screen.height-posFooter;
						if (dif > 220){
							spacer=(dif-220)+relleno;
							spacer=spacer-40;
							spacer=spacer+rellenoExtra;
							spaFooter.style.height=spacer + "px";
						}
					}
					else {
						dif=window.innerHeight-posFooter;
						if (dif > 40){
							dif=dif-40;
							dif=dif+rellenoExtra;
							spaFooter.style.height = dif + "px"
							//alert (dif);
						}
					}
					//alert("Inner: "+window.innerHeight+" Pos: "+posFooter+" Dif: "+dif);
					//alert("Screen: "+screen.height+" Pos: "+posFooter+" Dif: "+dif);
		}				

//cantImg = myFondo.length;
//cantImg--;
function cambiaImg2(){
	if (document.images){
			randomNum = Math.round((Math.random() * cantImg));
			fondo = document.getElementById('mainHome_f').style;
			mostrar=myFondo[randomNum]
			fondo.backgroundImage = 'url(' + mostrar + ')';
	}	
}
//RM
function cambiaImg(){
	if (document.images){
			randomNum = Math.round((Math.random() * cantImg));
			fondo = document.getElementById('contentHome');
			mostrar=myFondo[randomNum]
			fondo.innerHTML = '<img src="' + mostrar + '" width="925" height="385"/>';
	}	
}

function initMuestraFoto(){
	flecha_l = document.getElementById('flechaLeft');
	flecha_r = document.getElementById('flechaRight');
	cont_nav = document.getElementById('menuGalerias');
	thisLink = cont_nav.getElementsByTagName('a');
	cant = thisLink.length;
	ultimo = cant-1;
	if (cant==1){
		flecha_l.href=thisLink[0].href;
		flecha_r.href=thisLink[0].href;
		flecha_l.style.display="none";
		flecha_r.style.display="none";
	}
	if (cant>=2){
		flecha_l.href=thisLink[ultimo].href;
		flecha_l.style.display="none";
		flecha_r.href=thisLink[1].href;
	}
}
function muestraFoto( cont, text ){
	cont_m = document.getElementById('foto');
	cont_m.src = cont;
	text_m = document.getElementById('epig');
	text_m.value = text;
	
	flecha_l = document.getElementById('flechaLeft');
	flecha_r = document.getElementById('flechaRight');
	cont_nav = document.getElementById('menuGalerias');
	thisLink = cont_nav.getElementsByTagName('a');
	cant = thisLink.length;
	if (cant!=0){
		ultimo = cant-1;
	}
	
	for (var i=0; i<cant; i++) {
		miLink=thisLink[i].href;
		ok = miLink.search(cont);
		if (ok!=-1){
			if (i!=0){
				flecha_l.href=thisLink[i-1].href;
				flecha_l.style.display="block";
			}
			else{
				flecha_l.href=thisLink[ultimo].href;
				flecha_l.style.display="none";
			}
			if (i!=ultimo){
				flecha_r.href=thisLink[i+1].href;
				flecha_r.style.display="block";
			}
			else{
				flecha_r.href=thisLink[0].href;
				flecha_r.style.display="none";
			}
		}
	}
}

var text, cant, currPos;
currPos = 0;
function muestraLista(pos, id){
	var cont = document.getElementById(id);
	text = cont.getElementsByTagName('ul');
	cant = text.length;
	ultPos=cant-1;
	//alert (cant);
	var flechaL = document.getElementById('flechaGalLeft');
	var flechaR = document.getElementById('flechaGalRight');
	if (pos=='init'){
		if (cant!=0){
			text[currPos].style.display = "block";
			flechaL.style.display = "none";
			if (cant==1){
				flechaR.style.display = "none";
			}
		}
	}
	if (pos=='init2'){
		if (cant!=0){
			currPos=1;
			text[currPos].style.display = "block";
			flechaR.style.display = "none";
		}
	}
	if (pos=='pre'){
		if (currPos!=0){
			text[currPos].style.display = "none";
			currPos--;
			text[currPos].style.display = "block";
			if (currPos==0){
				flechaL.style.display = "none";
				flechaR.style.display = "block";
			}
			else{
				flechaL.style.display = "block";
				flechaR.style.display = "block";
			}
		}
		else{
			/*text[currPos].style.display = "none";
			currPos=ultPos;
			text[currPos].style.display = "block";*/
			flechaR.style.display = "none";
		}
	}
	if (pos=='pos'){
		if (currPos!=ultPos){
			text[currPos].style.display = "none";
			currPos++;
			text[currPos].style.display = "block";
			if (currPos==ultPos){
				flechaR.style.display = "none";
				flechaL.style.display = "block";
			}
			else{
				flechaR.style.display = "block";
				flechaL.style.display = "block";
			}
		}
		else{
			/*text[currPos].style.display = "none";
			currPos=0;
			text[currPos].style.display = "block";*/
			flechaR.style.display = "none";
		}
	}
}
var clickear;
function rollover(este,img){
	capSwap='Captura'+este+'';
	imgSwap='Img'+este+'';
	capturaSwap = document.getElementById(capSwap);
	
	if (este!=clickear){
		imagen = document.getElementById(imgSwap);
		imagen.src=img;
		if (document.all){
			if (capturaSwap.filters.alpha.opacity==40){
				capturaSwap.filters.alpha.opacity=100;
			}
			else{
				capturaSwap.filters.alpha.opacity=40;
			}
		}
		else{
			if (capturaSwap.style.MozOpacity==0.4){
				capturaSwap.style.MozOpacity=1;
			}
			else{
				capturaSwap.style.MozOpacity=0.4;
			}
		}
	}
}
function clickeado(este,img){
	clickear=este;
	
	capSwap='Captura'+este+'';
	imgSwap='Img'+este+'';
	capturaSwapE = document.getElementById(capSwap);
	imagenSwapE = document.getElementById(imgSwap);
	
	imag = document.getElementById('menuVideos');
	labels = imag.getElementsByTagName('label');
	for (i=0;i<labels.length;i++){
		imagenes=labels[i].getElementsByTagName('img');
		imagenes[0].src="images/boton-video.jpg";
	}
	imagenSwapE.src=img;

	imag2 = document.getElementById('menuVideos');
	imagenes2 = imag2.getElementsByTagName('img');
	for (i=0;i<imagenes2.length;i++){
		if (document.all){
			imagenes2[i].filters.alpha.opacity=100;
		}
		else {
			imagenes2[i].style.MozOpacity=1;
		}
	}
	if (document.all){
		capturaSwapE.filters.alpha.opacity=40;
		imagenSwapE.filters.alpha.opacity=40;
	}
	else {
		capturaSwapE.style.MozOpacity=0.4;
		imagenSwapE.style.MozOpacity=0.4;
	}
}
//onmouseover="this.style.MozOpacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.MozOpacity=0.5;this.filters.alpha.opacity=50"
function muestraVideo (num){
	data1 = document.getElementById('video1');
	data2 = document.getElementById('video2');
	data3 = document.getElementById('video3');
	dataChange = document.getElementById(num);
	data1.style.display="none";
	data2.style.display="none";
	data3.style.display="none";
	dataChange.style.display="block";
}

function verVideo(){
	data1 = document.getElementById('leftShows');
	data2 = document.getElementById('videoShows');
	data1.style.display="none";
	data2.style.display="block";
}

function enviar(form) {
	data = document.getElementById(form);
	data.submit();
}
function borrar(form) {
	data = document.getElementById(form);
	document.form1.reset();
}

function opacity(imagen,cant) {
	if (cant==100){
		imagen.style.border="1px solid #999999";
	}else{
		imagen.style.border="0px"; 
	}
	if (document.all){
		imagen.filters.alpha.opacity=cant;
		
	}
	else{
		cant=cant/100;
		imagen.style.MozOpacity=cant;
	}
}

function hover(elem,color){
		myElem = document.getElementById(elem);
		myElem.style.color = color;
}

var borrado;
function borraCampo(thisCampo){
	if (borrado!=thisCampo){
		campo = document.getElementById(thisCampo);
		campo.value = "";
		borrado = thisCampo;
	}
}
var borradoPass;
function borraCampoPass(thisCampo){
	if (borradoPass!=thisCampo){
		campo = document.getElementById(thisCampo);
		campo.value = "";
		campo.setAttribute('type', 'password');
		borradoPass = thisCampo;
	}
}
