function subsec(pagina){	
document.getElementById("nombreseccion").innerHTML=document.getElementById("menu" + pagina).innerHTML;
if (document.getElementById("submenu" + pagina)){
document.getElementById("submenuses").innerHTML=document.getElementById("submenu" + pagina).innerHTML ;
}
else{
document.getElementById("submenuses").innerHTML="";
}
}

var tituloact;
var paginaact;
function seccion(pagina,modo){
	
	paginaact=pagina;
	if (document.getElementById("tituloseccion") && document.getElementById('divContent').innerHTML){
document.getElementById("tituloseccion").innerHTML="";
document.getElementById('divContent').innerHTML="<table width=370 ><tr><td height=350 class=b16 align=center>Cargando seccion,<br>espere un momento, por favor...</td></tr></table>";
	}
tituloact=document.getElementById("menu" + pagina).innerHTML;
if (pagina=="galeria"){
imagen.creargaleria('inicio', '0',cargadeseccion) 	
}
else if (pagina=="foro"){
	crforos();
	}
else{
	if (modo==2){
		crdoble(pagina);
		}else{
	index.cargarseccion(pagina,cargadeseccion);		
			}

}
if (posicion==0){
movdn();
}else{
movup();
}
}

function galeria(galeria,inicio){
	if (document.getElementById('informacionesvarias')){
document.getElementById('informacionesvarias').innerHTML="<span class='b10b'>Cargando las imagenes de la galeria, un momento, por favor ...</span>";
	}
imagen.creargaleria(galeria, inicio,cargadeseccion) 
	}
function singleimg(imagensel,galeria){
document.getElementById('celdaizq').innerHTML="<table cellpadding=0 cellspacing=0 width='350' border=0><tr><td align='center' valign='middle' height='330'><img src='imagenes/mendatalogo1.jpg'><img src='imagenes/mendatalogo2.jpg'><br><br><span class='v16'>Cargando imagen<br>espere un momento, por favor ...</span></td></tr></table>";
imagen.cargarimg(imagensel,galeria,singleimgcb);
	}
function singleimgcb(res){
	if (res.error != null){
alert("Se ha producido el siguiente error:\n" + res.error);}
else {
document.getElementById('celdaizq').innerHTML=res.value;
	}
	}

function cargadeseccion(res)
{
if (res.error != null){
alert("Se ha producido el siguiente error:\n" + res.error);}
else {

el=document.getElementById("contenedor");
 doble=document.getElementById("tabladoble");
if (doble){
	  el.removeChild(doble); 
}
 simple=document.getElementById("tablasimple");
if (simple){
	  el.removeChild(simple); 
}
tab=document.createElement("table");
 
  tab.id="tabladoble";
  tab.setAttribute("cellSpacing","0");
  tab.setAttribute("cellPadding","0");
 tab.style.width="758";
 var clase;
var rspan;
var cspan;
if (isIE){
clase="className";
rspan="rowSpan";
cspan="colSpan";	
}else{
clase="class";
rspan="rowspan";
cspan="colspan";
}
//tab.setAttribute(clase,"tabla");

  tbody=document.createElement("tbody");
  tab.appendChild(tbody);
  r=document.createElement("tr");
  tbody.appendChild(r);
  td=document.createElement("td");
  td.width="379"
  td.setAttribute(rspan,"2")
td.id="celdaizq";
td.innerHTML="<div align='center'><img id='imgsec' src='imagenes/PERFIL_RUTA_2005.jpg'></div>";
  r.appendChild(td);
  td=document.createElement("td");
  td.width="5" 
  td.height="31"
  td.setAttribute("bgColor","#80b05c")
  r.appendChild(td);
  td=document.createElement("td");
  td.width="370"
  td.setAttribute("bgColor","#80b05c")
  spn=document.createElement("span");
	spn.id="tituloseccion";

	spn.setAttribute(clase,"b16");
  td.appendChild(spn);
  r.appendChild(td);
  tbody.appendChild(r);
  //td=document.createElement("td");
  //td.width="11" ;
   //td.setAttribute(rspan,"2");
   //td.setAttribute("bgColor","#80b05c");
  /*divcapa=document.createElement("div");
  divcapa.id="Layerscroll";
  divcapa2=document.createElement("div");
  divcapa2.id="scrinside";
  /*divcapa2.setAttribute("style","left:-3px");
  divcapa2.setAttribute("style","VISIBILITY:hidden");
  divcapa2.style.left="-3px";
  divcapa2.style.VISIBILITY="visible";
  divcapa2.style.CURSOR="move";
  divcapa2.style.POSITION="absolute";
  divcapa2.style.TOP="1px"*/
   //divcapa2.Z-Index = "10"
   //divcapa2.style.Z-INDEX=10;*/
 /* divcapa2.setAttribute("style","Z-INDEX:10; LEFT:-3px; VISIBILITY:visible; CURSOR:move; POSITION:absolute; TOP:1px");
  divcapa2.setAttribute("onMouseover","isHot=true;if (isN4) ddN4(scrinside)");
  divcapa2.setAttribute("onMouseout","isHot=false");
  tabscr=document.createElement("table");
  tabscr.setAttribute("cellSpacing","0");
  tabscr.width="11";
  tabscr.setAttribute(clase,"tablascr");
  tabscr.height="11" ;
  tabscr.id="scr";
  tabscr.setAttribute("cellPadding","0");
  tbodyscr=document.createElement("tbody");
  tabscr.appendChild(tbodyscr);
  trscr=document.createElement("tr");
  
  tdscr=document.createElement("td");
  tdscr.setAttribute("bgColor","#333333") ;
  tdscr.id="titleBar" ;
  tdscr.style.CURSOR="move";
  //tdscr.setAttribute("style","CURSOR:move");
  trscr.appendChild(tdscr);
  tbodyscr.appendChild(trscr);
divcapa2.appendChild(tabscr);
divcapa.appendChild(divcapa2);
td.appendChild(divcapa);*/
//r.appendChild(td);
tbody.appendChild(r);
  r=document.createElement("tr");
  td=document.createElement("td");
  td.height="183" ;
  td.setAttribute(cspan,"2") ;
  td.setAttribute("bgColor","#80b05c");
  divcapa=document.createElement("div");
  divcapa.id="divContainer";
  divcapa2=document.createElement("div");
  divcapa2.id="divContent";
  divcapa2.Align="justify" ;
  divcapa2.setAttribute(clase,"b10");
  divcapa.appendChild(divcapa2);
td.appendChild(divcapa);
r.appendChild(td);
tbody.appendChild(r);
el.appendChild(tab);
//alert(tab.innerHTML);
//document.getElementById("contenidoya").value=tab.innerHTML;
document.getElementById("tituloseccion").innerHTML=tituloact;
document.getElementById('divContent').innerHTML=res.value;
if (document.getElementById('tablaizq')){
document.getElementById('celdaizq').innerHTML=document.getElementById('tablaizq').value;
}
if (document.getElementById('imgsec')){
document.getElementById('imgsec').src="imagenes/menus/" + paginaact + ".jpg";
}
hallarbarra();
}
}
function cargadesecciondoble(res){
	document.getElementById("tituloseccion").innerHTML=tituloact;
document.getElementById('divContent').innerHTML=res.value;
hallarbarra();
	}
function crdoble(pagina){
		el=document.getElementById("contenedor");
		tab=document.createElement("table");
 doble=document.getElementById("tabladoble");
if (doble){
	  el.removeChild(doble); 
}
 simple=document.getElementById("tablasimple");
if (simple){
	  el.removeChild(simple); 
}
  tab.id="tablasimple";
  tab.setAttribute("cellSpacing","0");
  tab.setAttribute("cellPadding","0");
  tab.setAttribute("border","0");
 tab.style.width="760";
 var clase;
var rspan;
var cspan;
if (isIE){
clase="className";
rspan="rowSpan";
cspan="colSpan";	
}else{
clase="class";
rspan="rowspan";
cspan="colspan";
}
tbody=document.createElement("tbody");
tab.appendChild(tbody);
r=document.createElement("tr");
td=document.createElement("td");
td.width="559" 
td.height="20" 
td.setAttribute("bgColor","#80b05c") 
td.setAttribute(clase,"b16")
spn=document.createElement("span");
spn.id="tituloseccion";
td.appendChild(spn);
r.appendChild(td);
td=document.createElement("td");
td.height="20" 
td.setAttribute(cspan,"1")
td.setAttribute("bgColor","#80b05c")
td.setAttribute(clase,"b16")
td.align="right"
spn=document.createElement("span");
spn.id="paginacion"
spn.setAttribute(clase,"n10")
td.appendChild(spn);
r.appendChild(td);
tbody.appendChild(r);
r=document.createElement("tr");
td=document.createElement("td");
td.height="320"
td.setAttribute(cspan,"2")
td.setAttribute("bgColor","#80b05c")
divcapa=document.createElement("div");
  divcapa.id="divContainer";
  divcapa.style.width="750px";
  divcapa.style.height="327px";
  divcapa2=document.createElement("div");
  
  divcapa2.id="divContent";
  divcapa2.Align="justify" ;
  divcapa2.setAttribute(clase,"b10");
  divcapa.appendChild(divcapa2);
td.appendChild(divcapa);
r.appendChild(td);
tbody.appendChild(r);
r=document.createElement("tr");
td=document.createElement("td");
td.height="20"
td.setAttribute(cspan,"2")
td.setAttribute("bgColor","#80b05c")
td.setAttribute(clase,"b12")
td.id="celdareg";
td.innerHMTL="registro"
r.appendChild(td);
tbody.appendChild(r);
el.appendChild(tab);
	
		
		
			index.cargarseccion(pagina,cargadesecciondoble);
			}

	function crforos(){
		el=document.getElementById("contenedor");
		tab=document.createElement("table");
 doble=document.getElementById("tabladoble");
if (doble){
	  el.removeChild(doble); 
}
 simple=document.getElementById("tablasimple");
if (simple){
	  el.removeChild(simple); 
}
  tab.id="tablasimple";
  tab.setAttribute("cellSpacing","0");
  tab.setAttribute("cellPadding","0");
  tab.setAttribute("border","0");
 tab.style.width="760";
 var clase;
var rspan;
var cspan;
if (isIE){
clase="className";
rspan="rowSpan";
cspan="colSpan";	
}else{
clase="class";
rspan="rowspan";
cspan="colspan";
}
tbody=document.createElement("tbody");
tab.appendChild(tbody);
r=document.createElement("tr");
td=document.createElement("td");
td.width="559" 
td.height="20" 
td.setAttribute("bgColor","#80b05c") 
td.setAttribute(clase,"b16")
spn=document.createElement("span");
spn.id="cabecera";
td.appendChild(spn);
r.appendChild(td);
td=document.createElement("td");
td.height="20" 
td.setAttribute(cspan,"1")
td.setAttribute("bgColor","#80b05c")
td.setAttribute(clase,"b16")
td.align="right"
spn=document.createElement("span");
spn.id="paginacion"
spn.setAttribute(clase,"n10")
td.appendChild(spn);
r.appendChild(td);
tbody.appendChild(r);
r=document.createElement("tr");
td=document.createElement("td");
td.height="320"
td.setAttribute(cspan,"2")
td.setAttribute("bgColor","#80b05c")
divcapa=document.createElement("div");
  divcapa.id="divContainer";
  divcapa.style.width="760px";
  divcapa.style.height="327px";
  divcapa2=document.createElement("div");
  
  divcapa2.id="divContent";
  divcapa2.Align="justify" ;
  divcapa2.setAttribute(clase,"b10");
  divcapa.appendChild(divcapa2);
td.appendChild(divcapa);
r.appendChild(td);
tbody.appendChild(r);
r=document.createElement("tr");
td=document.createElement("td");
td.height="20"
td.setAttribute(cspan,"2")
td.setAttribute("bgColor","#80b05c")
td.setAttribute(clase,"b12")
td.id="celdareg";
td.innerHMTL="registro"
r.appendChild(td);
tbody.appendChild(r);
el.appendChild(tab);
	
		
		
			foro.cargarforos(idiomapag,cargadeforos);
			}
			function cargadeforos(res)
{

	if(res.error!= null)
	{
		alert(res.error);
}
	else{

if (idiomapag=='eus'){
	document.getElementById('cabecera').innerHTML="<span class='menuseccion'>Foroa</span>";
	}
	else{
	document.getElementById('cabecera').innerHTML="<span class='menuseccion'>Foros</span>";	
		}
		
		
		document.getElementById("divContent").innerHTML = res.value;
		if (document.getElementById("reg")){
		document.getElementById("celdareg").innerHTML=document.getElementById("reg").value;
		//alert(document.getElementById("reg").value);
		}
		hallarbarra();
		}	
}
var valortema;
var indicepagina=0;
function cargarforo(valor,pagina){
document.getElementById("cabecera").innerHTML=document.getElementById("tema" + valor).innerHTML;
indicepagina=pagina;
valortema=valor;
			foro.cargarforo(indicepagina,valor,cargadeforo);
			}
			function cargadeforo(res)
{
if(res.error != null)
	{
alert(res.error);
}
	else{
	document.getElementById("divContent").innerHTML = res.value;
		document.getElementById('paginacion').innerHTML=document.getElementById('paginacionhd').value;
		
		if (document.getElementById("reg")){
		document.getElementById("celdareg").innerHTML=document.getElementById("reg").value;
		//alert(document.getElementById("reg").value);
		}
		hallarbarra();
			}

}
function pagina(pg){
	indicepagina=pg-1;
	document.getElementById('paginacion').innerHTML="<span class='b12'>Cargando pagina,<br>un momento, por favor ...</span>";
	foro.cargarforo(indicepagina,valortema,cargadeforo);
	}
function abrir(pagina,w,h){

LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height=' + h +',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=0,resizable'
win = window.open(pagina + '.aspx','menu',settings)
}

function chkuser(){
document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'><tr><td align='center'><span class='n12'>Bienvenido al foro</span></td></tr>" + 
"<tr><td align='center' class='b10'>Ahora como usuario registrado podr&aacute; a&ntilde;adir comentarios <br>a todos los temas existentes.<br />Haga click <a href='javascript:cl();' class='r12'>aqu&iacute;</a> para cerrar esta ventana</td></tr></table>" 

document.getElementById("msginfo").style.left=findPosX(document.getElementById("guia"))-400	;
document.getElementById("msginfo").style.top=findPosY(document.getElementById("guia"))+200;
crforos();
	}
	
function chkadmin(){
document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'><tr><td align='center'><span class='n12'>Bienvenido al foro</span></td></tr>" + 
"<tr><td align='center' class='b10'>Ahora como ADMINISTRADOR podr&aacute; a&ntilde;adir comentarios as&iacute; como editarlos y borrarlos,<br> tambi&eacute;n tiene el control sobre las cuentas de los usuarios registrados en el foro.<br />Haga click <a href='javascript:cl();' class='r12'>aqu&iacute;</a> para cerrar esta ventana</td></tr></table>" 

document.getElementById("msginfo").style.left=findPosX(document.getElementById("guia"))-400	;
document.getElementById("msginfo").style.top=findPosY(document.getElementById("guia"))+200;
crforos();
	}
function cl(){
	document.getElementById("msginfo").innerHTML="";
	document.getElementById("msginfo").style.left=-1000	;
document.getElementById("msginfo").style.top=-1000;
	//foro.chkuser(devusr);
	}
function devusr(res){
	if(res.error != null)
	{
alert(res.error);
}
else{
document.getElementById("celdareg").innerHTML=res.value;
}
}
function lgout(){
	foro.lgout(devusr);
	crforos();
	}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
}
function recargarpagina(){
	cargando();
	document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'>" + 
"<tr><td align='center' class='b10'>Su comentario se ha a&ntilde;adido correctamente<br><a href='javascript:vercmt();' class='r9'>Haga click aqu&iacute; para ir a la p&aacute;gina donde se encuentra</a></td></tr></table>" ;
	//indexnew.cargarforo(indicepagina,valortema,cargadeforo);
	}
function recargarpaginamd(){
	cargando();
	document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'>" + 
"<tr><td align='center' class='b10'>Su comentario se ha modificado correctamente<br><a href='javascript:vercmtmd();' class='r9'>Haga click aqu&iacute; para cerrar este mensaje</a></td></tr></table>" ;
	//indexnew.cargarforo(indicepagina,valortema,cargadeforo);
	}
	function cargando(){
var xpos=findPosX(guia);
var ypos=findPosY(guia);
document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'>" + 
"<tr><td align='center' class='b10'>Cargando secci&oacute;n</a></td></tr></table> " 
document.getElementById("msginfo").style.left=findPosX(document.getElementById("guia"))-400	;
document.getElementById("msginfo").style.top=findPosY(document.getElementById("guia"))+200;
document.getElementById("msginfo").style.display="block";
document.getElementById("msginfo").style.position="absolute";
}
function vercmtmd(){
	pagina(indicepagina+1);
	cl();
	}

function vercmt(){
	pagina(document.getElementById("totpg").innerHTML);
	cl();
	}
function addcoment(estado,ided){
	LeftPosition = (screen.width) ? (screen.width-430)/2 : 0;
TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
settings ='height=400,width=430,top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=auto,resizable'
win = window.open('addcmt.aspx?id=' + valortema + '&e=' + estado + '&v=' + ided,'menu',settings)
	}
function addtema(){
	foro.addtemanuevo(document.getElementById("ntema").value,document.getElementById("desctema").value,fintemanuevo)
	}	
	function fintemanuevo(res){
	if (res.error != null){
alert("Se ha producido el siguiente error:\n" + res.error);}
else {
	document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'>" + 
"<tr><td align='center' class='b10'>" +res.value +"<br><a href='javascript:verntema();' class='r9'>Haga click aqu&iacute; para cerrar este mensaje</a></td></tr></table> " 
document.getElementById("msginfo").style.left=findPosX(document.getElementById("guia"))-400	;
document.getElementById("msginfo").style.top=findPosY(document.getElementById("guia"))+200;
document.getElementById("msginfo").style.display="block";
document.getElementById("msginfo").style.position="absolute";
cancel();
	}
	}
function verntema(){
	cl();
	crforos();
	}
	function delcoment(id){
		if(!confirm("Borrar mensaje ?")) {
              
              
              } 

              else {

           foro.delmsg(id,finborrado);  
            }
		
		}
function finborrado(res){
	if (res.error != null){
alert("Se ha producido el siguiente error:\n" + res.error);}
else {
	document.getElementById("msginfo").innerHTML="<table cellpadding='0' cellspacing=4' width='200px' bgcolor='#80b05c' class='tablaforo'>" + 
"<tr><td align='center' class='b10'>" +res.value +"<br><a href='javascript:vercmtmd();' class='r9'>Haga click aqu&iacute; para cerrar este mensaje</a></td></tr></table> " 
document.getElementById("msginfo").style.left=findPosX(document.getElementById("guia"))-400	;
document.getElementById("msginfo").style.top=findPosY(document.getElementById("guia"))+200;
document.getElementById("msginfo").style.display="block";
document.getElementById("msginfo").style.position="absolute";
}
	}
	
function mdforo(id){
document.getElementById("ntema").value=document.getElementById("tema" + id).innerHTML;
document.getElementById("desctema").value=document.getElementById("desc" + id).innerHTML;
document.getElementById("addtem").innerHTML="Modificar";
document.getElementById("addtem").href="javascript:modforo(" + id +")";
document.getElementById("cantem").innerHTML="&nbsp;&nbsp;Cancelar&nbsp;&nbsp;";
	}	
function cancel(){
	document.getElementById("ntema").value="";
document.getElementById("desctema").value="";
document.getElementById("addtem").innerHTML="&nbsp;&nbsp;A&ntilde;adir tema&nbsp;&nbsp;";
document.getElementById("addtem").href="javascript:addtema()";
document.getElementById("cantem").innerHTML="";	
		}
function modforo(id){
foro.modtema(document.getElementById("ntema").value,document.getElementById("desctema").value,id,fintemanuevo)	
	}
function delforo(id){
	if(!confirm("Borrar tema ?")) {
              
              
              } 

              else {

         foro.delforo(id,fintemanuevo)	
            }

	}	