var URL_ACTUAL="http://www.conceep.com";
var historico = new Array();
var lastCall ="";
var retorno = false;
function guardaDirec(direc){
	if (!retorno){
		historico.push(direc);	
	}else{
		retorno=false;
	}
}
function extraeDirec(){
	if (historico.length>0){ 
		return historico.pop();
	}else{
		return "top.document.location.href='"+URL_ACTUAL+"'";
	}
}
/*FUNCIONES GLOBALES*/
function limit(field, idlabel, max) {
	if (field.value.length >= max) {
		field.value = field.value.substr(0,max);
	}

	document.getElementById(idlabel).innerHTML = max - field.value.length;
}

/*LLAMADAS DE AJAX*/	
/**MAS DETALLE 
Y RESPONDER**/
function responderApregunta(codPregunta){
	oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=300;
    oConn.reconectarSi['404']=0;

    strPost = "codigo="+codPregunta;
    if (!oConn) alert("FALLO LA LLAMADA A AJAX");
    var fnWhenDone = function (oXML)
    	{
	    	$("botonResponder").style.visibility="hidden";
  			new Insertion.After($("fPregunta"),oXML.responseText);
  			
      	};
    oConn.connect("jsp/respuesta.jsp", "POST", strPost , fnWhenDone);    
	

}

function responderApreguntaMyXcio(codPregunta){
	oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=300;
    oConn.reconectarSi['404']=0;

    strPost = "codigo="+codPregunta+"&myconceep=1";
    if (!oConn) alert("FALLO LA LLAMADA A AJAX");
    var fnWhenDone = function (oXML)
    	{
  			new Insertion.After($("fPControl"),oXML.responseText);
  			
      	};
    oConn.connect("jsp/respuesta.jsp", "POST", strPost , fnWhenDone);    
	
}

function masDetalle(pregunta){
	guardaDirec(lastCall);
	lastCall="masDetalle('"+pregunta+"')";
	bloqueaPagina("pagina");  //anula enlaces.

	Cargando(true,"Cargando la pregunta"); // muestra la ventana con el texto.
	oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=500;
    oConn.reconectarSi['404']=0;

    strPost = "codigo="+pregunta;
    if (!oConn) alert("FALLO LA LLAMADA A AJAX");
    var fnWhenDone = function (oXML)
    	{
  			document.getElementById("preguntasResponde").innerHTML = oXML.responseText;
  			document.title = document.getElementById("tituloPagina").innerHTML+" - Conceep. ";
  			$("textoRespuesta").innerHTML ="Demuestra tu conocimiento, respondiendo a esta pregunta. Ademas no olvides de que aparte de ganar prestigio, recibiras parte del dinero generado en publicidad por la pagina. ¿Se te ocurre algo mas?. Entra en CONCEEP y a responde a los demas.";
  			Cargando(false);
  			activaPagina("pagina");
  			refreshAd();  			
  			if (historico.length>0){
      			document.getElementById("volver").style.visibility="visible"; 
		    }
  			
  			try{
  				Nifty("span.marcoBotonGenerico","small");	
  			}catch(e){}
  			try{
	 			Nifty("div.marcoBoton","small");	
  			}catch(e){}
  			try{
	 			Nifty("div.sombreado","normal");	
  			}catch(e){}
  			
  			
      	};
    oConn.connect("jsp/masDetalle.jsp", "POST", strPost , fnWhenDone);    
}
/** CARGA PREGUNTAS **/	
	function masDetallePrincipal(codigo){
		cargaResponde(codigo," ",1)
	}
	function mostrarTag(busqueda){
		cargaResponde("tag",busqueda,0);
	}
	function mostrarCategoria(busqueda){
		cargaResponde("categoria",busqueda,0);
		}

	function cargaResponde(tipo,busqueda,respuesta) {
			if(lastCall!="cargaResponde(\""+tipo+"\",\""+busqueda+"\","+respuesta+")"){
				guardaDirec(lastCall);	
				lastCall="cargaResponde(\""+tipo+"\",\""+busqueda+"\","+respuesta+")";
				}
			bloqueaPagina("pagina");  //anula enlaces.
			if (tipo=="miembro"){
	       		Cargando(true,"Buscando usuarios"); // muestra la ventana con el texto.
			}else{
	       		Cargando(true,"Buscando preguntas"); // muestra la ventana con el texto.
	       		}
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("principal").innerHTML = oXML.responseText;
   					cargaRespondeCentral(tipo,busqueda,respuesta);   
	      	};
	      	oConn.connect("jsp/responde.jsp", "POST", strPost , fnWhenDone);       
      }

      function cargaRespondeCentral(tipo,busqueda,respuesta) {
  			oConn = new XHConn();
		    oConn.reconectarSi['timeout']=0;
		    oConn.tiempoTimeout=300;
		    oConn.reconectarSi['404']=0;
	      	if(respuesta==0){
		      	strPost = "tipo="+tipo+"&cadena="+busqueda;
		      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
		      		var fnWhenDone = function (oXML)
		      			{
	      				document.getElementById("preguntasResponde").innerHTML = oXML.responseText;
	      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      				cargaRespondeIzquierdaCateg();
		      	};
		      	oConn.connect("jsp/cuadro_pregunta.jsp", "POST", strPost , fnWhenDone);       
		    }
	      	else{
			    strPost = "codigo="+tipo;
			    if (!oConn) alert("FALLO LA LLAMADA A AJAX");
			    var fnWhenDone = function (oXML)
			    	{
			  			document.getElementById("preguntasResponde").innerHTML = oXML.responseText;
			  			$("textoRespuesta").innerHTML ="Demuestra tu conocimiento, respondiendo a esta pregunta. Ademas no olvides de que aparte de ganar prestigio, recibiras parte del dinero generado en publicidad por la pagina. ¿Se te ocurre algo mas?. Entra en CONCEEP y a responde a los demas.";			  			
			  			document.title = document.getElementById("tituloPagina").innerHTML+" - Conceep. ";
			  			cargaRespondeIzquierdaCateg();
			      	};
			    oConn.connect("jsp/masDetalle.jsp", "POST", strPost , fnWhenDone);    
	      		
	      	}
	      	
      }
      
      function cargaRespondeIzquierdaCateg() {
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
	      			Cargando(false);
      				document.getElementById("izqResponde").innerHTML = oXML.responseText;
      				activaPagina("pagina");	
      				refreshAd();
      				if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }
      				try{
      					Nifty("div.paginacion","normal");   				     				
      				}catch(e){}
      				try{
			  			Nifty("span.marcoBotonGenerico","small");	
			 			Nifty("div.marcoBoton","small");	      				
	    			}catch(e){}
	    			try{
		 				Nifty("div.sombreado","normal");	
  					}catch(e){}
	    			
      	  	};
	      	oConn.connect("jsp/categorias.jsp", "POST", strPost , fnWhenDone);       
      }

function refreshAd() {
      var currentTime = new Date(); 
      document.getElementById("googlead").src = "jsp/ad.jsp?s=" + currentTime.getTime(); 
      document.getElementById("googlead").style.display="Block";
}


/*Pagina Principal*/

      function cargaInicio() {
      		historico=new Array();
      		lastCall="top.document.location.href='"+URL_ACTUAL+"'";
            Cargando(true, "Bienvenido a conceep");
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
	      			Element.hide("fila31");	      			
      				document.getElementById("fila31").innerHTML = oXML.responseText;
      				cargaFila3Derecha();
	      	};
	      	oConn.connect("jsp/novedades.jsp", "POST", strPost , fnWhenDone);       
      }  		
      
  		function cargaFila3Derecha() {
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("fila32").innerHTML = oXML.responseText;
      				cargaCabecera();
	      	};
	      	oConn.connect("jsp/topPreguntas.jsp", "POST", strPost , fnWhenDone);       
      }

      


  		function cargaCabecera() {
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("cabecera").innerHTML = oXML.responseText;
      				Element.show("cabecera");	   
	      			Element.show("fila31");
	        	  	Cargando(false);
					try{
						rotacionTablon();
		        		Nifty("div.marcoBotonErrores","small");
		        		Nifty("div#container1","top");
					    Nifty("div#header1","small top");
		        		Nifty("div#container2","top");
					    Nifty("div#header2","small top");
		        		Nifty("div#container3","top");
					    Nifty("div#header3","small top");
					    if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }else{
			      			document.getElementById("volver").style.visibility="hidden"; 
					    }

					    $("principal").style.visibility="";
					    scroll = new NewsScroller('marquesina',5000);
					}catch(e){}
					try{
						Nifty("div.bienvenido","small");
					}catch(e){}
	        		
	      	};
	      	oConn.connect("jsp/cabecera.jsp", "POST", strPost , fnWhenDone);       
      }
      
      function cargaSaberMas(id) {
		    bloqueaPagina("pagina");
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("divSaberMas").innerHTML = oXML.responseText;
	      			document.getElementById("divSaberMas").className = "cMuestra";
	      	};
	      	switch(id)
				{
				case "1":
			      	oConn.connect("jsp/saberMasPregunta.html", "POST", strPost , fnWhenDone);       
					break;
				case "2":
			      	oConn.connect("jsp/saberMasPresencia.html", "POST", strPost , fnWhenDone);       
					break;
				case "3":
			      	oConn.connect("jsp/saberMasRespuesta.html", "POST", strPost , fnWhenDone);       
					break;
				case "4":
					try{  				
	  					Nifty("div#dAltaCancelar","small");  								
						bloqueaPagina("fFormularioUsuario");	  					
		  			}catch(e){}
			      	oConn.connect("jsp/terminosDeUso.html", "POST", strPost , fnWhenDone);       
					break;
				case "5":
			      	oConn.connect("jsp/disclaimer.html", "POST", strPost , fnWhenDone);       
					break;
				case "6":
			      	oConn.connect("jsp/licencia_condiciones.html", "POST", strPost , fnWhenDone);       
					break;
				case "7":
			      	oConn.connect("jsp/legal.html", "POST", strPost , fnWhenDone);       
					break;
				case "8":
			      	oConn.connect("jsp/privado.html", "POST", strPost , fnWhenDone);       
					break;				
				case "9":
			      	oConn.connect("jsp/contacto.html", "POST", strPost , fnWhenDone);       
					break;						
				}

      }  		
      function cerrarSaberMas(){
    	  	document.getElementById("divSaberMas").className = "cOculta";
			try{  												
				activaPagina("fFormularioUsuario");	  					
				activaPagina("pagina");
  			}catch(e){}    	  	
      }
      function cargaNuevaPreguntaAUsuario(codUsuario) {
      		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("principal").innerHTML = oXML.responseText;
      				cargaCentroPregunta(codUsuario);
	      	};
	      	oConn.connect("jsp/nuevaPregunta.jsp", "POST", strPost , fnWhenDone);       
      }
      
      function cargaNuevaPregunta() {
      		guardaDirec(lastCall);
			lastCall="cargaNuevaPregunta()";
      		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("principal").innerHTML = oXML.responseText;
      				cargaCentroPregunta("");
	      	};
	      	oConn.connect("jsp/nuevaPregunta.jsp", "POST", strPost , fnWhenDone);       
      }
      
      function cargaCentroPregunta(codUsuario) {
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "codUsuario="+codUsuario;
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("panelControlCentral").innerHTML = oXML.responseText;
      				cargaDerechaConsejos();
	      	};
	      	oConn.connect("jsp/pregunta.jsp", "POST", strPost , fnWhenDone);       
      }
    
      function cargaDerechaConsejos() {
      		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      	var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("panelControlDerecho").innerHTML = oXML.responseText;  
      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";    				
      				if (historico.length>0){
	      				document.getElementById("volver").style.visibility="visible"; 
	      				}
      				
	      	};
	      	oConn.connect("jsp/consejoPreguntas.html", "POST", strPost , fnWhenDone);       
      }   

/* Modifica la privacidad del usuario */
function cargaModPrivacidad() {
			document.getElementById("panelControlCentral").innerHTML ="Cargando datos...";
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("panelControlCentral").innerHTML = oXML.responseText;
      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
      				try{  				
	  					Nifty("div#dPrivacidad","small");  								
	  				}catch(e){}
	      	};
	      	oConn.connect("jsp/privado/modPrivacidad.jsp", "POST", strPost , fnWhenDone);       
      }      
      
/* CARGAR DATOS DEL USUARIO */
function cargaAlta() {
			document.getElementById("panelControlCentral").innerHTML ="Cargando datos...";
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
      				document.getElementById("panelControlCentral").innerHTML = oXML.responseText;
      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
      				try{  				
	  					Nifty("div#bAcepModDatos","small");  								
	  					Nifty("div#bCanceModDatos","small");
	  				}catch(e){}
	      	};
	      	oConn.connect("jsp/privado/modDatos.jsp", "POST", strPost , fnWhenDone);       
      }      

function muestraDatosUsuario() {
			bloqueaPagina("pagina");  //anula enlaces.
			new Effect.Shrink('logarseUsuario'); 
       		Cargando(true,"Verificando usuario"); // muestra la ventana con el texto.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "usuario="+document.getElementById("usuario").value+"&passwd="+document.getElementById("clave").value;
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					Cargando(false); //Oculta la ventana.
					var a = oXML.responseText;
					document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
					if (a.substring(0,5)=="Error"){						
						document.getElementById("contenidoError").innerHTML=oXML.responseText;
						new Effect.Grow('error', {direction: 'center'}); 
						new Effect.Opacity("error", {duration:1.0, from:0.1, to:0.90});	
					} else {	
						activaPagina("pagina");		
      					document.getElementById("usuarioLogado").innerHTML = oXML.responseText;
						Element.show("desconecta_session");      					
						Element.hide("inicio_session");      					
      					if(top.document.getElementById("botonResponder")!=null && $("nickUsuarioPregunta").value!= $("usuarioLogadoRespuesta").value){
							Element.show("botonResponder");      					
						}
						try{
							Nifty("div.marcoBoton","small");							
						}catch(e){}
						volverLoginUsuario();	
	      			}
	      	};
	      	oConn.connect("jsp/privado/usuario.jsp", "POST", strPost , fnWhenDone);       
      }      

function ocultaError(){
			activaPagina("pagina");
    		Element.hide("error");	
    		try{
				new Effect.Opacity("logarseUsuario", {duration:0.0, from:0.1, to:0.95})
				Element.show('logarseUsuario');
		  	}catch(e){}
			    							
}      
function guardaPregunta() {
			bloqueaPagina("pagina");  //anula enlaces.
       		Cargando(true,"Guardando pregunta"); // muestra la ventana con el texto.

	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;
			//Tratamiento de las imagenes.
			var imagen1="";
			var imagen2="";
			var textoVideo = "";
			try{
				var teImg1=document.getElementById("imgSubida1").src;
				imagen1 = teImg1.substring(teImg1.lastIndexOf("/")+1,teImg1.length);
			}catch(e){
				imagen1="";
				}
			try{
				var teImg2=document.getElementById("imgSubida2").src;
				imagen2 = teImg2.substring(teImg2.lastIndexOf("/")+1,teImg2.length);
			}catch(e){
				imagen2 = "";
			}
			if (imagen1=="" && imagen2!=""){
				imagen1=imagen2;
				imagen2="";
			}
			
			if (Trim($F("preVideo"))!=''){
				textoVideo = ($F("preTexto"))+escape("<div style=\"height:360px; margin-top:10px; width:99%; overflow: auto;\">") +escape($F("preVideo"))+escape(" </div>");
			} else {
				textoVideo = Trim($F("preTexto"));
			}
			
			
	      	strPost = "titulo="+encodeURIComponent($F("preTitulo"))+"&categoria="+$("preCategoria").options[$("preCategoria").selectedIndex].value;
	      	strPost = strPost + "&texto="+encodeURIComponent(textoVideo)+"&tags="+encodeURIComponent($F("preTags"))+"&para="+$F("preNick")+"&img1="+imagen1+"&img2="+imagen2;
	        
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					Cargando(false); //Oculta la ventana.
					var a = oXML.responseText;
					
					if (a.substring(0,5)=="Error" ){	
						if (a=="") a="Sistema momentaneamente no operativo, por favor vuelva a intentarlo";
												
						$("contenidoError").innerHTML=a;
						new Effect.Grow('error', {direction: 'center'});/*
						activaPagina("pagina");				
      					document.getElementById("principal").innerHTML = oXML.responseText;
      					document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";		*/				 	        								
					} else {	
						activaPagina("pagina");				
      					document.getElementById("principal").innerHTML = oXML.responseText;
      					document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      			}
	      	};
	      	oConn.connect("servlet/savePregunta", "POST", (strPost) , fnWhenDone);       
      }      

function linkSubeImagen(idLink) {
			bloqueaPagina("pagina");  //anula enlaces.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					Cargando(false); //Oculta la ventana.
					var a = oXML.responseText;
					if (a.substring(0,5)=="Error" || a==""){	
						if (a=="") a="Sistema momentaneamente no operativo, por favor vuelva a intentarlo";
												
						$("contenidoError").innerHTML=a;
						new Effect.Grow('error', {direction: 'center'}); 	        								
					} else {	
						activaPagina("pagina");			
					 	parent.document.getElementById("img1").style.visibility="hidden";	
					 	parent.document.getElementById("img2").style.visibility="hidden";
					 	parent.document.getElementById("displayImg1").style.display="none";	
					 	parent.document.getElementById("displayImg2").style.display="none";
					 	document.getElementById(idLink).src=a;	
						document.getElementById(idLink).style.display='';	
						document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      			}
	      	};
	      	oConn.connect("servlet/validaUsuario", "POST", strPost , fnWhenDone);       
      }      
   
	   
function linkBorraImagen(name,numero) {
			bloqueaPagina("pagina");  //anula enlaces.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "nomImagen="+name+"&numImg="+numero;
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					Cargando(false); //Oculta la ventana.
					var a = oXML.responseText;
					if (a.substring(0,5)=="ERROR" || a==""){	
						if (a=="") a="Sistema momentaneamente no operativo, por favor vuelva a intentarlo";
												
						$("contenidoError").innerHTML=a;
						new Effect.Grow('error', {direction: 'center'}); 	        								
					} else {	
						activaPagina("pagina");			
					 	parent.document.getElementById("img"+numero).innerHTML =a;
					    parent.document.getElementById("img"+numero).style.visibility='visible';	
					 	parent.document.getElementById("displayImg"+numero).innerHTML ="";
					 	parent.document.getElementById("displayImg"+numero).style.display ="none";
					 	document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      			}
	      	};
	      	oConn.connect("servlet/borraImagen", "POST", strPost , fnWhenDone);       
      }   	

	function muestraMiXcio() {
			guardaDirec(lastCall);
			lastCall="muestraMiXcio()";
	
			bloqueaPagina("pagina");  //anula enlaces.
       		Cargando(true,"Mi CONCEEP"); // muestra la ventana con el texto.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					var a = oXML.responseText;
					
					if (a.substring(0,5)=="Error"){						
						document.getElementById("contenidoError").innerHTML=oXML.responseText;
      					Cargando(false); //Oculta la ventana.
						new Effect.Grow('error', {direction: 'center'}); 	        								
					} else {	
      					document.getElementById("principal").innerHTML = oXML.responseText;	
      					Cargando(false); //Oculta la ventana.
      					if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }
					    activaPagina("pagina");	
					    document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      			}
	      	};
	      	oConn.connect("jsp/privado/panelControl.jsp", "POST", strPost , fnWhenDone);       	
      }  
      
  
  function muestraPanelControlIzquierdo(){
       		
       		Cargando(true,"Mi CONCEEP"); // muestra la ventana con el texto.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					var a = oXML.responseText;

      				document.getElementById("panelControlIzquierdo").innerHTML = oXML.responseText;
      				muestraPanelControlCentral();
	      	};
	      	oConn.connect("jsp/privado/datosContacto.jsp", "POST", strPost , fnWhenDone);    
	      	
  }
 
 function muestraPanelControlCentral(){
       		
       		Cargando(true,"Mi CONCEEP"); // muestra la ventana con el texto.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					var a = oXML.responseText;

      				document.getElementById("panelControlCentral").innerHTML = oXML.responseText;
      				muestraPanelControlDerecho();
	      	};
	      	oConn.connect("jsp/privado/panelPrincipal.jsp", "POST", strPost , fnWhenDone);    
	      	
  } 
  
 function muestraPanelControlDerecho(){
       		
       		Cargando(true,"Mi CONCEEP"); // muestra la ventana con el texto.
       		
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					var a = oXML.responseText;

      				document.getElementById("panelControlDerecho").innerHTML = oXML.responseText;
      				Cargando(false); //Oculta la ventana.
      				
      				document.getElementById("panelControlIzquierdo").style.visibility="visible";
      				document.getElementById("panelControlCentral").style.visibility="visible";
      				document.getElementById("panelControlDerecho").style.visibility="visible"; 
      				activaPagina("pagina");	
      				if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }
					document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      	};
	      	oConn.connect("jsp/privado/panelPreguntas.jsp", "POST", strPost , fnWhenDone);    
	      	
  } 
  
  function registrarUsuario(){
		bloqueaPagina("pagina");
   		Cargando(true,"Registro de usuario"); // muestra la ventana con el texto.

	    oConn = new XHConn();
        oConn.reconectarSi['timeout']=2;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=2;

      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
      			Cargando(false);
  				new Insertion.After($("principal"),"<div id=\"divMensaje\" style=\"position:absolute; top:5px; z-index:100;width: 850px; display:none; \"></div>"	);
  				$("divMensaje").style.left= ((new Element.getDimensions($("pagina")).width-870)/2)+"px";
  				$("divMensaje").innerHTML = oXML.responseText;
//  				new Effect.Grow('divMensaje', {direction: 'center'}); 
				new Effect.Opacity("divMensaje", {duration:0.0, from:0.1, to:0.97})  
  				Element.show('divMensaje');
//  				cargarImagenLogging(document.getElementById('codLogging').value);
				document.getElementById('tUsuario').focus(); 	  
				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";		
  				try{  				
	  				Nifty("div#dAltaCancelar","small");  								
	  			}catch(e){}
  				try{  				
	  				Nifty("div#dAltaAceptar","small");  								
	  			}catch(e){}
  				try{  				
	  				Nifty("div#dRecargarLogging","small");  								
	  			}catch(e){}  				
      			};
      	oConn.connect("jsp/altFormulario.jsp", "POST", "" , fnWhenDone);       
}

function cargarImagenLogging(){
	    oConn = new XHConn();
        oConn.reconectarSi['timeout']=2;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=2;

      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
  				$("marcoImagen").innerHTML = oXML.responseText;
      			};
	    oConn.connect("servlet/makeImagen", "GET", "" , fnWhenDone); 
      	
}

  function altPrivacidad(){

	    oConn = new XHConn();
        oConn.reconectarSi['timeout']=2;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=2;

      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
  				new Insertion.After($("principal"),"<div id=\"divPrivacidad\" style=\"position:absolute; top:120px; z-index:200;width: 400px; display:none; \"></div>"	);
  				$("divPrivacidad").style.left= ((new Element.getDimensions($("pagina")).width-400)/2)+"px";
  				$("divPrivacidad").innerHTML = oXML.responseText;

				$("divMensaje").style.display="none";
				new Effect.Opacity("divPrivacidad", {duration:0.0, from:0.1, to:0.90})  
  				Element.show('divPrivacidad');
  				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	  			
  				try{  				
	  				Nifty("div#dPrivacidad","small");  								
	  			}catch(e){}
  				
      			};
      	oConn.connect("jsp/privacidad.jsp", "POST", "" , fnWhenDone);       
}

function loginUsuario(){
		bloqueaPagina("pagina");
   		Cargando(true,"Inicio de sesión"); // muestra la ventana con el texto.

	    oConn = new XHConn();
        oConn.reconectarSi['timeout']=2;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=2;

      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
      			Cargando(false);
  				new Insertion.After($("principal"),"<div id=\"logarseUsuario\" class=\"fondoBlanco\" style=\"position:absolute; top:81px; z-index:1200;width: 220px; display:none;\"></div>"	);
  				$("logarseUsuario").style.left= ((new Element.getDimensions($("pagina")).width-180)/2)+"px";
  				$("logarseUsuario").innerHTML = oXML.responseText;
//  				new Effect.Grow('divMensaje', {direction: 'center'}); 
				new Effect.Opacity("logarseUsuario", {duration:0.0, from:0.1, to:0.95})
  				Element.show('logarseUsuario');
  				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
				try{  				
	  				Nifty("div.marcoBotonGenerico","small");  								
	  			}catch(e){}
  				Field.focus("usuario"); 
      			};
      	oConn.connect("jsp/usuario.html", "POST", "" , fnWhenDone);    
      	   
	}
function volverLoginUsuario(){
		activaPagina("pagina");	
		new Effect.Shrink('logarseUsuario'); 		
		Element.remove("logarseUsuario");
	
	}

function refreshUsuario() {
			Element.remove('divMensaje'); //Quita el mensaje.
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

	      	strPost = "";
	      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					activaPagina("pagina");				
  					document.getElementById("usuarioLogado").innerHTML = oXML.responseText;
  					document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
	      	};
	      	oConn.connect("jsp/privado/usuario.jsp", "POST", strPost , fnWhenDone);       
      }    
function cargaInicioPerfil(codUsuario) {

   		Cargando(true, "Obteniendo el perfil");
        oConn = new XHConn();
        oConn.reconectarSi['timeout']=0;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=0;
		
      	strPost = "";
      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
      			Element.hide("cabecera");
  				document.getElementById("cabecera").innerHTML = oXML.responseText;
  				Element.show("cabecera");	      			  				
  				cargaPerfil(codUsuario,1);
  				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";
      	};
      	oConn.connect("jsp/cabecera.jsp", "POST", strPost , fnWhenDone);       

  }

function cargaAmpliada(url){
	if ((document.getElementById("cargaOriginal").src).indexOf(url)!=-1){
		document.getElementById("ampliar").style.display="none";
		document.getElementById("cargaOriginal").src="";
	}else{
		document.getElementById("cargaOriginal").src=url;
		document.getElementById("ampliar").style.display="";
	}	
}

function enviaMailClave(codUsuarioMail){
			bloqueaPagina("pagina");  //anula enlaces.
			new Effect.Shrink('logarseUsuario'); 
       		Cargando(true,"Enviando clave a su correo"); // muestra la ventana con el texto.
	        oConn = new XHConn();
	        oConn.reconectarSi['timeout']=0;
	        oConn.tiempoTimeout=300;
	        oConn.reconectarSi['404']=0;

			strPost = "codUsuario=" + codUsuarioMail;
			if (!oConn) alert("FALLO LA LLAMADA A AJAX");
	      		var fnWhenDone = function (oXML)
	      			{
					Cargando(false); //Oculta la ventana.
					var a = oXML.responseText;					
      					    		
      				if (a.indexOf("Error")==-1){	
	      				document.getElementById("contenidoConfirmacion").innerHTML= "El envio se ha realizado correctamente";
	      				new Effect.Grow('confirmacion', {direction: 'center'});
	      				volverLoginUsuario();
	      				document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";		      				
	      			}else{
						document.getElementById("contenidoError").innerHTML=a;
	      				a="";
						new Effect.Grow('error', {direction: 'center'}); 
						new Effect.Opacity("error", {duration:1.0, from:0.1, to:0.90});	
	      			}
	      	};
	      	oConn.connect("servlet/EnvioMailClave", "POST", strPost , fnWhenDone);	

}
function cargaSuscripcion(codUsuario, codCategoria) { 
      	
   		Cargando(true, "Obteniendo preguntas");
        oConn = new XHConn();
        oConn.reconectarSi['timeout']=0;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=0;
        strPost="";
      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
      			Cargando(false);
      			Element.hide("cabecera");
  				document.getElementById("cabecera").innerHTML = oXML.responseText;
  				Element.show("cabecera");	 
  				cargaSuscripcion2(codUsuario, codCategoria,1);		  				   			  				     				
      	};
      	oConn.connect("jsp/cabecera.jsp", "POST", strPost , fnWhenDone);    
      	   
  }

function cargaSuscripcion2(codUsuario, codCategoria, inicial) {

	if (inicial==undefined){
			guardaDirec(lastCall);
			lastCall="cargaSuscripcion("+codUsuario+","+codCategoria+")";
	}
	bloqueaPagina("pagina");  //anula enlaces.
	Cargando(true,"Obteniendo la pregunta"); // muestra la ventana con el texto.
	 
    oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=300;
    oConn.reconectarSi['404']=0;

  	strPost = "codUsuario="+codUsuario+"&codCategoria="+codCategoria;
   	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
   		var fnWhenDone = function (oXML)
   			{
  				document.getElementById("principal").innerHTML = oXML.responseText;    	
  				Cargando(false);
	  			activaPagina("pagina");
	  			if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }
				if (inicial!=undefined){
	  				try{
			        		Nifty("div.marcoBotonErrores","small");
			        		Nifty("div#container1","top");
						    Nifty("div#header1","small top");
			        		Nifty("div#container2","top");
						    Nifty("div#header2","small top");
			        		Nifty("div#container3","top");
						    Nifty("div#header3","small top");
						    if (historico.length>0){
				      			document.getElementById("volver").style.visibility="visible"; 
						    }else{
				      			document.getElementById("volver").style.visibility="hidden"; 
						    }
						    $("principal").style.visibility="";
						}catch(e){}
						try{
							Nifty("div.bienvenido","small");
						}catch(e){}
						document.title = "Conceep.- Conocimiento compartido y útil para mejorar el mundo.";  				      				
				}			     				
    	};
    	oConn.connect("jsp/suscripcion.jsp", "POST", strPost , fnWhenDone);       
}
function mailDetallePrincipal(codPregunta) { 
      	
   		Cargando(true, "Obteniendo pregunta");
        oConn = new XHConn();
        oConn.reconectarSi['timeout']=0;
        oConn.tiempoTimeout=300;
        oConn.reconectarSi['404']=0;
        strPost="";
      	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
      		var fnWhenDone = function (oXML)
      			{
      			Cargando(false);
      			Element.hide("cabecera");
  				document.getElementById("cabecera").innerHTML = oXML.responseText;
  				Element.show("cabecera");	 
  				mailDetallePrincipal2(codPregunta,1);				   			  				     				
      	};
      	oConn.connect("jsp/cabecera.jsp", "POST", strPost , fnWhenDone);    
      	   
  }
function mailDetallePrincipal2(codPregunta,inicial) {

	if (inicial==undefined){
			guardaDirec(lastCall);
			lastCall="mailDetallePrincipal("+codUsuario+","+codCategoria+")";
	}
	bloqueaPagina("pagina");  //anula enlaces.
	Cargando(true,"Obteniendo la pregunta"); // muestra la ventana con el texto.
	 
    oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=300;
    oConn.reconectarSi['404']=0;

    strPost = "codigo="+codPregunta;
   	if (!oConn) alert("FALLO LA LLAMADA A AJAX");
   		var fnWhenDone = function (oXML)
   			{
  				document.getElementById("principal").innerHTML = oXML.responseText;    	
  				document.title = document.getElementById("tituloPagina").innerHTML+" - Conceep. ";
  				Cargando(false);
	  			activaPagina("pagina");
	  			if (historico.length>0){
			      			document.getElementById("volver").style.visibility="visible"; 
					    }
				if (inicial!=undefined){
	  				try{
			        		Nifty("div.marcoBotonErrores","small");
			        		Nifty("div#container1","top");
						    Nifty("div#header1","small top");
			        		Nifty("div#container2","top");
						    Nifty("div#header2","small top");
			        		Nifty("div#container3","top");
						    Nifty("div#header3","small top");
						    if (historico.length>0){
				      			document.getElementById("volver").style.visibility="visible"; 
						    }else{
				      			document.getElementById("volver").style.visibility="hidden"; 
						    }
						    $("principal").style.visibility="";
						}catch(e){}
						try{
							Nifty("div.bienvenido","small");
						}catch(e){}
  				      			
				}			     				
    	};
    	oConn.connect("jsp/masDetalle.jsp", "POST", strPost , fnWhenDone);       
}

var aleat = Math.random() * 3 
aleat = Math.round(aleat) 
var indicadorTablo = parseInt(aleat) ;

function rotacionTablon() 
{
	try{
		if (indicadorTablo>4){
			indicadorTablo=1;
		}
		switch(indicadorTablo)
		{
		case 1:
			 Element.hide("divTablon2");	
			 Element.hide("divTablon3");
			 Element.hide("divTablon4");	
			 Element.removeClassName("divTablon1",'cOculta');	
			 Element.show("divTablon1");
			 break;
			 
		case 2:
			 Element.hide("divTablon1");	
			 Element.hide("divTablon3");
			 Element.hide("divTablon4");	
			 Element.removeClassName("divTablon2",'cOculta');	
			 Element.show("divTablon2");
			 break;
		case 3:
			 Element.hide("divTablon2");	
			 Element.hide("divTablon1");	
			 Element.hide("divTablon4");
			 Element.removeClassName("divTablon3",'cOculta');	
			 Element.show("divTablon3");
			 break;
		case 4:
			 Element.hide("divTablon1");	
			 Element.hide("divTablon2");	
			 Element.hide("divTablon3");
			 Element.removeClassName("divTablon4",'cOculta');	
			 Element.show("divTablon4");
			 break;
		}
		indicadorTablo++;
		setTimeout("rotacionTablon();",10000);
	}catch(e){}
}

function masDetalle2(pregunta){
	guardaDirec(lastCall);
	lastCall="masDetalle2('"+pregunta+"')";
	bloqueaPagina("pagina");  //anula enlaces.

	Cargando(true,"Cargando la pregunta"); // muestra la ventana con el texto.
	oConn = new XHConn();
    oConn.reconectarSi['timeout']=0;
    oConn.tiempoTimeout=500;
    oConn.reconectarSi['404']=0;

    strPost = "codigo="+pregunta;
    if (!oConn) alert("FALLO LA LLAMADA A AJAX");
    var fnWhenDone = function (oXML)
    	{
  			document.getElementById("principal").innerHTML = oXML.responseText;
  			document.title = document.getElementById("tituloPagina").innerHTML+" - Conceep. ";
  			//$("textoRespuesta").innerHTML ="Demuestra tu conocimiento, respondiendo a esta pregunta. Ademas no olvides de que aparte de ganar prestigio, recibiras parte del dinero generado en publicidad por la pagina. Â¿Se te ocurre algo mas?. Entra en CONCEEP y a responde a los demas.";
  			Cargando(false);
  			activaPagina("pagina");
  			refreshAd();  			
  			if (historico.length>0){
      			document.getElementById("volver").style.visibility="visible"; 
		    }
  			
  			try{
  				Nifty("span.marcoBotonGenerico","small");	
  			}catch(e){}
  			try{
	 			Nifty("div.marcoBoton","small");	
  			}catch(e){}
  			try{
	 			Nifty("div.sombreado","normal");	
  			}catch(e){}
  			
  			
      	};
    oConn.connect("jsp/masDetalle.jsp", "POST", strPost , fnWhenDone);    
}
