// JavaScript Document

rrresta=0;
ggresta=0;
bbresta=0;
//document.title = "test";


function fadeNaaz(rr,gg,bb,rrfin,ggfin,bbfin,rgb,control){ 

if(control==1){
	rrresta=rr-rrfin;
	ggresta=gg-ggfin;
	bbresta=bb-bbfin;
//document.title +=rrresta+" "+ggresta+" "+bbresta;
	if(rr==rrfin){rrsigno=0;} else { if(rrresta>0){ rrsigno = -1; } else {rrsigno = 1; } }
	if(gg==ggfin){ggsigno=0;} else { if(ggresta>0){ ggsigno = -1; } else {ggsigno = 1; } }
	if(bb==bbfin){bbsigno=0;} else { if(bbresta>0){ bbsigno = -1; } else {bbsigno = 1; } }
}
//if(rr==rrfin){rrsigno=0;}else{rrsigno=rrresta/abs(rrresta);}
//if(gg==ggfin){ggsigno=0;}else{ggsigno=ggresta/abs(ggresta);}
//if(bb==bbfin){bbsigno=0;}else{bbsigno=bbresta/abs(bbresta);}

if(rr!=rrfin || gg!=ggfin || bb!=bbfin){
	if(rr!=rrfin){rr= rr + 3*(1*rrsigno);}
	if(gg!=ggfin){gg= gg + 3*(1*ggsigno);}
	if(bb!=bbfin){bb= bb + 3*(1*bbsigno);}

	if((rr-rrfin)<5 & (rr-rrfin)>-5){rr= rrfin;}
	if((gg-ggfin)<5 & (gg-ggfin)>-5){gg= ggfin;}
	if((bb-bbfin)<5 & (bb-bbfin)>-5){bb= bbfin;}
	
		document.getElementById("fondo").style.backgroundColor="rgb("+rr+","+gg+","+bb+")";
		document.getElementById("menuResto2").style.backgroundColor="rgb("+rr+","+gg+","+bb+")";
		document.getElementById("contenedor_menu").style.backgroundColor="rgb("+rr+","+gg+","+bb+")";
//	document.title = "rgb("+rr+","+gg+","+bb+") "+gg+" ["+ggfin+"] "+bb+" ["+bbfin+"] "+rr+" ["+rrfin+"] "+rgb ;
//	document.title = "rgbIntro("+rrintro+","+ggintro+","+bbintro+") rgb("+rr+","+gg+","+bb+")";

		setTimeout("fadeNaaz("+rr+","+gg+","+bb+","+rrfin+","+ggfin+","+bbfin+","+rgb+",0)",20); 
	
//	document.title += ".";
}


}


function deColor(decolor){
document.getElementById("fondo").style.backgroundColor=decolor;
document.getElementById("menuResto1").style.backgroundColor=decolor;
document.getElementById("menuResto2").style.backgroundColor=decolor;

}
function deColorLite(elemento,decolor){
	document.getElementById(elemento).style.backgroundColor=decolor;
}
function deColorPlus(elemento,decolor,fucolor,bocolor){
	document.getElementById(elemento).style.backgroundColor=decolor;
	document.getElementById(elemento).style.color=fucolor;
	document.getElementById(elemento).style.borderColor=bocolor;
}

function portSobre(elemento,color){
	document.getElementById(elemento).style.borderTopWidth="3px";
	document.getElementById(elemento).style.borderBottomWidth="3px";
	document.getElementById(elemento).style.borderBottomStyle="solid";
	document.getElementById(elemento).style.borderColor=color;
	
  new Effect.Opacity(elemento, {from:1.0, to:0.5});

	setTimeout("new Effect.Opacity('"+elemento+"', {from:0.5, to:1})",1000);
	
}
function portFuera(elemento,color){
	document.getElementById(elemento).style.borderTopWidth="6px";
	document.getElementById(elemento).style.borderBottomWidth="0px";
	document.getElementById(elemento).style.borderBottomStyle="solid";
	document.getElementById(elemento).style.borderColor=color;

  
}

function muestra(elemento){
	document.getElementById(elemento).style.display="block";

}
function oculta(elemento){
	document.getElementById(elemento).style.display="none";

}


function resultado(resultado,comentario){
	var resultado
	var comentario
window.open('resultado.php?resultado='+resultado+'&comentario='+comentario,'resultados');
vuelve();

}

function vuelve(){
	setTimeout("window.open('resultado.php?resultado=2&comentario=','resultados')",3500); 
}

function show_ml (elemento){


var longstring=elemento;
var elementom=longstring.split("-");


	for (i=0; i<elementom.length; i++) {
//	document.getElementById(elementom[i]).style.display = 'block';
	document.getElementById(elementom[i]).style.display = '';
	} 

}

function hide_ml (elemento){
	
var longstring=elemento;
var elementom=longstring.split("-");


	for (i=0; i<elementom.length; i++) {
	document.getElementById(elementom[i]).style.display = 'none';
	} 
}
function toggle_showhide(elemento){
	if(document.getElementById(elemento).style.display == 'none'){ show_ml(elemento)}
	else{hide_ml(elemento)}
}


//function toggle_showhide(obj) {
//var el = document.getElementById(obj);
//el.style.display = (el.style.display != 'none' ? 'none' : '' );
//}

function cambiatam(tam){

document.getElementById('contenedorgeneral').style.fontSize = tam+"%";
//document.getElementById('general').style.fontSize = tam+"pt";
//document.getElementById('general').style.fontSize = "+"+tam;
	
}

// <![CDATA[
function cambios(mundo,titulo){

	var numero=1;
	while (numero<=5){
		if(numero!=mundo){
		Effect.toggle('portMundo'+numero,'slide');
		}
		numero=numero+1;
	}
	Effect.toggle(titulo,'appear');
	Effect.toggle('cont1','slide');
//	Effect.Shake('portMundo'+mundo, {distance:2});
//	Effect.toggle('portMundo'+mundo,'appear');
//	new Effect.ScrollTo('apartado',{duration:5.0});
//	new Effect.Scale( 'cont1', 20,{ scaleContent: true, scaleX: true, scaleY: false });

}
// ]]>

function enmenu(elemento){
	document.getElementById(elemento).style.backgroundColor="#95211A";
	document.getElementById(elemento).style.fontSize="110%";
  
}


function apartado(actual,futuro,mapaactual,mapafuturo){

var longstring=actual;
var actualm=longstring.split("-");

var longstring=mapaactual;
var mapaactualm=longstring.split("-");


var longstring=futuro;
var futurom=longstring.split("-");

var longstring=mapafuturo;
var mapafuturom=longstring.split("-");

	for (i=0; i<actualm.length; i++) {
	Effect.BlindUp(actualm[i],{duration:0.2}); 
	} 
	for (v=0; v<mapaactualm.length; v++) {
	hide_ml(mapaactualm[v]);
	} 
	
	for (w=0; w<futurom.length; w++) {
	Effect.BlindDown(futurom[w],{duration:1.5});
	} 
	for (u=0; u<mapafuturom.length; u++) {
	show_ml(mapafuturom[u]);
	} 	
//	Effect.BlindDown(futuro,{duration:1.5});
//	show_ml(mapafuturo);
}

function cambiaimagen(imagen,ruta){
	document[imagen].src=ruta;	
}
function clickdiferenciales(elemento){
	show_ml('s31');
	show_ml('s32');
	show_ml('s33');
	show_ml('s34');
	hide_ml('s31_on');
	hide_ml('s32_on');
	hide_ml('s33_on');
	hide_ml('s34_on');
	hide_ml(elemento);
	show_ml(elemento+'_on');
}
function cambia_minimundo(elemento){


	for (h=1; h<6; h++) {
		if(document.getElementById('divmundo'+h).style.display=="none"){

		Effect.SlideDown('divmundo'+h,{duration:0.2});
		}
		
		if(document.getElementById('cmundo'+h).style.display=="block" || document.getElementById('cmundo'+h).style.display==""){

//		Effect.SlideUp('cmundo'+h,{duration:0.2});
		hide_ml('cmundo'+h);
		hide_ml('mindex_'+h);
		}

	}
	hide_cont_subsubmun(); 
	hide_lista_subsubmun(); 
	Effect.SlideUp('divmundo'+elemento,{duration:0.2});
	show_ml('cmundo'+elemento);
	show_ml('cmundo'+elemento+'0');
	show_ml('mindex_'+elemento);
}


function swapImage(elemento,imagen) {
 var cambiaima="imagenes/"+imagen;
 document.getElementById(elemento).src = cambiaima;
}

function efecto_submun_titulos(elemento,imagen,punto,estado){

	swapImage(elemento,'titulo_'+imagen+estado+'.png'); 
	swapImage('p'+elemento,'ico_puntoRoll_'+punto+estado+'.gif');
}

function hide_mundos(){
	hide_ml('cmundo1-cmundo2-cmundo3-cmundo4-cmundo5-cmundo11-cmundo12-cmundo13-cmundo21-cmundo22-cmundo31-cmundo32-cmundo33-cmundo34-cmundo41-cmundo42-cmundo43-cmundo44-cmundo45-cmundo51-cmundo52-cmundo53');
}

function cambia_subsubmundo(nivelA,nivelB){
	if(nivelB=='0'){
	var mostrar = 'cmundo'+nivelA+nivelB;
	}else{
	var mostrar = 'cmundo'+nivelA+nivelB+'-mindex_'+nivelA+(nivelB-1);
	}
	hide_cont_subsubmun(); 
	hide_lista_subsubmun(); 
	
	show_ml(mostrar);
}




	function relTo( origen,destino,desplazax,desplazay,fijx,fijy ) {
  if( typeof( origen.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; origen; origen = origen.offsetParent ) {
      posX += origen.offsetLeft;
      posY += origen.offsetTop;
    }
//    return [ posX, posY ];
	if(fijx==1){document.getElementById(destino).style.left = desplazax+'px';}else{document.getElementById(destino).style.left = (posX+desplazax)+'px';}
	if(fijy==1){document.getElementById(destino).style.top = desplazay+'px';}else{document.getElementById(destino).style.top = (posY+desplazay)+'px';}
	
  } else {
//    return [ origen.x, origen.y ];
	if(fijx==1){document.getElementById(destino).style.left = desplazax+'px';}else{document.getElementById(destino).style.left = (origen.x+desplazax)+'px';}
	if(fijy==1){document.getElementById(destino).style.top = desplazay+'px';}else{document.getElementById(destino).style.top = (origen.y+desplazay)+'px';}
  }
}
function printPage() {
  if (window.print)
    window.print()
  else
    alert("Sorry, your browser doesn't support this feature.");
}

function openpopup(direccion,ancho,alto){
var popurl=direccion;
winpops=window.open(popurl,"","width="+ancho+",height="+alto+",scrollbars=no, menubar=no, resizable=1");
}