var smf_theme_url = "Themes/default";
var smf_images_url = "Themes/default/images";
var smf_scripturl = "";
var smf_iso_case_folding = false;
var smf_charset = "ISO-8859-1";  
  
function toggle( targetId )
{
var state = 0;
var blockname = "block" + targetId;
var blockimage = "blockcollapse" + targetId;
if ( document.getElementById ) {
  target = document.getElementById( blockname );
  if ( target.style.display == "none" ) {
    target.style.display = "";
    state = 1;
    }
    else {
    target.style.display = "none";
    state = 0;
  }

  document.getElementById( blockimage ).src = smf_images_url + (state ? "/collapse.gif" : "/expand.gif");
  document.getElementById( blockimage ).alt = (state ? "+" : "-");

}
}
  
  
  
var currentSwapArticle = true;
function swapOptionsArticle(one)
{
document.getElementById(one).style.display = currentSwapArticle ? "" : "none";
document.getElementById("articleUpshrink").src = smf_images_url + ( currentSwapArticle ? "/upshrink.gif" : "/upshrink2.gif");
currentSwapArticle = !currentSwapArticle;
}
  
  

var current_header = false;
function shrinkHeader(mode)
{
document.cookie = "upshrink=" + (mode ? 1 : 0);
document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");
document.getElementById("upshrink").title = (mode ? "Expandir panel Superior" : "Retraer panel Superior");
document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
current_header = mode;
}  
  

  
var current_leftbar = false;
function shrinkHeaderLeftbar(mode)
{
document.cookie = "upshrink=" + (mode ? 1 : 0);
document.getElementById("upshrinkLeftbar").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");
document.getElementById("upshrinkLeftbar").title = (mode ? "Expandir panel Izquierdo" : "Retraer panel Izquierdo");
document.getElementById("leftbarHeader").style.display = mode ? "none" : "";
current_leftbar = mode;
}





var current_header_ic = false;
function shrinkHeaderIC(mode)
{
document.cookie = "upshrinkIC=" + (mode ? 1 : 0);
document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");
document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";
current_header_ic = mode;
}

// *****  no borrar codigo especifico para el menu en IE
navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);
// *****



function togglePanel(targetId)
{
var state = 0;
var panelname = "panel" + targetId;
var panelimage = "panelcollapse" + targetId;

target = document.getElementById( panelname );

if ( target.style.display == "none" ) {
target.style.display = "";
state = 1;
}
else {
target.style.display = "none";
state = 0;
}
document.getElementById( panelimage ).src = smf_images_url + (state ? "/collapse.gif" : "/expand.gif");
document.getElementById( panelimage ).title = (state ? "Retraer panel" : "Expandir panel");
document.getElementById( panelimage ).alt = (state ? "+" : "-");

}



function toggleSubPanel(targetId)
{
var state = 0;
var panelname =  targetId;
var panelimage = "subpanelcollapse" + targetId;

target = document.getElementById( panelname );
if ( target.style.display == "none" ) {
  target.style.display = "";
  state = 1;

}else {
  target.style.display = "none";
  state = 0;
  }
document.getElementById( panelimage ).src = smf_images_url + (state ? "/collapse.gif" : "/expand.gif");
document.getElementById( panelimage ).title = (state ? "Retraer panel" : "Expandir panel");
document.getElementById( panelimage ).alt = (state ? "+" : "-");
}


function openSubPanel(targetId)
{
var state = 0;
var panelname =  targetId;
var panelimage = "subpanelcollapse" + targetId;

target = document.getElementById( panelname );
if ( target.style.display == "none" ) {
  target.style.display = "";
}
document.getElementById( panelimage ).src = smf_images_url + "/collapse.gif";
document.getElementById( panelimage ).title = "Retraer panel";
document.getElementById( panelimage ).alt = "-";
}


function CargaPanel(NombrePanel)
{
//si ya existe se muestra
if (document.getElementById( NombrePanel )!=null ) { 
document.location="#"+NombrePanel;
}

var textoCodigo='<iframe id="iframeCarga" src="' + NombrePanel +'.html" onLoad=insertaPanel("' + NombrePanel +'") style="display:none" height="50" width="100%"></iframe>';
document.getElementById( "Central" ).innerHTML = textoCodigo

// var theParent=document.getElementById('Central');
// var attribs = {};
// 
// 	var e = document.createElement('iframe');
// 	
// 	e.setAttribute("style",'display:none');
// 	e.setAttribute("onLoad",'insertaPanel("' + NombrePanel +'")');
// 	e.setAttribute("src", NombrePanel +'.html');
//   e.setAttribute("id",'iframe1');
// 
// 	if(attribs){
// 		for(var n in attribs){
// 			e.setAttribute(n,attribs[n]);
// 		}
// 	}
//  theParent.appendChild(e);



// var theParent=document.getElementById('Central');
// var attribs = {};
// 
// 	var e = document.createElement('div');
// 	e.setAttribute("id","DivCarga");
// 	e.innerHTML=textoCodigo;
// 
// 	if(attribs){
// 		for(var n in attribs){
// 			e.setAttribute(n,attribs[n]);
// 		}
// 	}
//  //theParent.appendChild(e);
//  theParent.insertBefore (e, theParent.firstChild);
// 		




}




function insertaPanel(NombrePanel)
{
// se obtiene el contenido del iframe
var frame1=document.getElementById('iframeCarga');
var iframeDocument = frame1.contentWindow ? frame1.contentWindow.document : frame1.contentDocument;

var fecha= new Date(iframeDocument.lastModified);
var ano=""+fecha.getFullYear();
var mes=""+(fecha.getMonth()+1);  //se le suma uno porque da el mes 0-11
var dia=""+(fecha.getDate());

if (mes.length==1) mes="0"+mes;
if (dia.length==1) dia="0"+dia;
var actualizado='Ultima actualización: '+ ano+'/'+mes+'/'+dia;

var root =  iframeDocument.body;
var HTML = root.innerHTML;

var resultado=HTML.replace("<pre>","");
HTML=resultado;
resultado=HTML.replace("</pre>","");
HTML=resultado;
// se reemplaza <NOMBRE_PANEL> por el nombre del panel
resultado=HTML.replace(/<NOMBRE_PANEL>/gi,NombrePanel);
HTML=resultado;

resultado=HTML.replace('id="panelclose"','id="panelclose'+ NombrePanel+'"');
HTML=resultado;
//lo mismo para IE
resultado=HTML.replace('id=panelclose','id="panelclose'+ NombrePanel+'"');
HTML=resultado;

resultado=HTML.replace('id="panelcollapse"','id="panelcollapse'+ NombrePanel+'"');
HTML=resultado;
//lo mismo para IE
resultado=HTML.replace('id=panelcollapse','id="panelcollapse'+ NombrePanel+'"');
HTML=resultado;

resultado=HTML.replace('id="panel"','id="panel'+ NombrePanel+'"');
HTML=resultado;
resultado=HTML.replace('id=panel','id="panel'+ NombrePanel+'"');
HTML=resultado;

resultado=HTML.replace('id="subpanelcollapse"','id="subpanelcollapseSubPanel'+ NombrePanel+'"');
HTML=resultado;
resultado=HTML.replace('id=subpanelcollapse','id="subpanelcollapseSubPanel'+ NombrePanel+'"');
HTML=resultado;

resultado=HTML.replace('id="subpanel"','id="SubPanel'+ NombrePanel+'"');
HTML=resultado;
resultado=HTML.replace('id=subpanel','id="SubPanel'+ NombrePanel+'"');
HTML=resultado;

resultado=HTML.replace('<A name="name">','<a name="'+ NombrePanel+'" id="idlink'+ NombrePanel +'"',"gi");
HTML=resultado;
resultado=HTML.replace('<A name=name>','<a name="'+ NombrePanel+'" id="idlink'+ NombrePanel +'"',"gi");
HTML=resultado;

resultado=HTML.replace('<A href="Panel"','<a href="#'+ NombrePanel+'"',"gi");
HTML=resultado;
resultado=HTML.replace('<A href=Panel','<a href="#'+ NombrePanel+'"',"gi");
HTML=resultado;

resultado=HTML.replace('^ACTUALIZACION^',actualizado);
HTML=resultado;


resultado=HTML.replace(/origen=/gi,'src=');
HTML=resultado;

resultado=HTML.replace(/_texto_script_/gi,"");
HTML=resultado;

if (document.getElementById( NombrePanel )==null ) { 


//document.getElementById( "Central2" ).innerHTML ='<DIV id="'+ NombrePanel +'"' + HTML + '</DIV>'+ '<br>' +document.getElementById( "Central2" ).innerHTML;
//'<DIV id="'+ NombrePanel +'"' + HTML + '</DIV>'+ '<br>' +document.getElementById( "Central2" ).innerHTML;

var theID=''+NombrePanel;
var theParent=document.getElementById('Central2');
var theText=HTML + '<br>' + '<br>';
var attribs = {};

	var e = document.createElement('div');
	if(theID != null)
		e.setAttribute("id",theID);
	if(theText != null)
		//e.appendChild(document.createTextNode(theText));
		e.innerHTML=theText;
	if(attribs){
		for(var n in attribs){
			e.setAttribute(n,attribs[n]);
		}
	}
	if(theParent != null)
		//theParent.appendChild(e);
		theParent.insertBefore (e, theParent.firstChild);
		
		//alert(e.innerHTML );


} else {
document.location="#"+NombrePanel;
}

//iframeDocument.src="";

//BorraIframeCarga();
}



function BorraDivCarga(){
document.getElementById( "Central" ).innerHTML ='';
}



function borrarPanel(NombrePanel)
{
//se elimina el panel
  var d = document.getElementById('Central2');
  
   var olddiv = document.getElementById(''+NombrePanel);
  d.removeChild(olddiv);


//se elimina el <br> que separa los paneles

//if( d.innerHTML.substr( 0, 4).toUpperCase()  == "<BR>") {
//    d.innerHTML=d.innerHTML.substr(4);
//}

//especifico para IE
//if( d.innerHTML.substr( 0, 15).toUpperCase()  == "<DIV></DIV><BR>") {
//  d.innerHTML=d.innerHTML.substr(15);
//}

}

function ResizeIframe(idIframe)
{
  //find the height of the internal page
  var the_height=
    document.getElementById(idIframe).contentWindow.document.body.scrollHeight;
  //change the height of the iframe
  document.getElementById(idIframe).height=the_height;
}


function GetIF(IdIF) {var ifr = document.getElementsByTagName('iframe');for(i=0; ifr[i]; i++) {if (ifr[i].id == IdIF) IndiceIF = i;}if (IndiceIF>=0) return IndiceIF;else return -1;}
