function writit(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = text;
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}
function selCont(iCont,mCont)
{
actual=iCont;

writit("<img src=/img/contenido.gif align=absmiddle>"+nombre[iCont],"titulo");
document.ggbApplet.openFile("../ggb/"+archivo[iCont]+".ggb");
for (i=1;i<=mCont;i++)
  {
   if(i==iCont)
    {	
     dMen("men"+i)
	 if (visInst==true) {
	   showInline("inst"+i);
	    }
    }
   else
    {
     nMen("men"+i)
	 hideInline("inst"+i)
    }
  }
}
function selContnoIns(iCont,mCont)
{
actual=iCont;

writit("<img src=/img/contenido.gif align=absmiddle>"+nombre[iCont],"titulo");
document.ggbApplet.openFile("../ggb/"+archivo[iCont]+".ggb");
for (i=1;i<=mCont;i++)
  {
   if(i==iCont)
    {	
     dMen("men"+i)
	 if (visInst==true) {	   
	    }
    }
   else
    {
     nMen("men"+i)
    }
  }
}
function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "Block";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
function ocInst () {
	var theElemenet = document.getElementById("inst"+actual);
	var theTd = document.getElementById("tdInst");
	if (theElemenet.style.display== "none") {
		theElemenet.style.display = "block";
		theTd.style.width= "40%";
		visInst=true;
	}
	else
	{
		theElemenet.style.display = "none";	
		theTd.style.width= "0";
		visInst=false;
	}
}
function dMen (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.border = "solid #E87901 3px";
	}
}
function nMen (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.border = "solid #E87901 0px";
	}
}


function navSpan(cSpan,maxSpan)
{
for (i=1;i<=maxSpan;i++)
  {
   if(i==cSpan)
    {
     showInline(i)
    }
   else
    {
     hideInline(i)
    }
  }
}
function showInline (elName) {
	var theElemenet = document.getElementById("capa"+elName);
	if (theElemenet) {
		theElemenet.style.display = "block";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById("capa"+elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function ver_cont(idcont)
{win2=window.open("cont.php?id="+idcont,'elemento','toolbar=no,width=640,height=480,top=80,left=80,resizable=yes');
win2.creator=self;

}

function ver_cont_noadd(idcont)
{win2=window.open("cont.php?id="+idcont+"&noadd=true",'elemento','toolbar=no,width=640,height=480,top=80,left=80,resizable=yes');
win2.creator=self;

}


function agregar(nombre,idcont)
{parent.add_cont(nombre,idcont);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function creacion()
{
	window.open("/guias/paso1.php","creacion","width=720,height=540,toolbar=no,resizable=yes,scrollbars=yes");
}
function ejemplos()
{
	window.open("/guias/ejemplos.php","ejemplos","width=720,height=540,toolbar=no,resizable=yes,scrollbars=yes");
}
function ver_guia(idcont)
{window.open("/guias/ejemplo.php?mode=count&c=1&id="+idcont,'clases','toolbar=no,width=720,height=540')
}



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_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_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 esclay()
{
	for (i=1;i<8;i++)
	{ 
		if (eval('document.clase.conte'+i+'.value>0'))
		{
			writit('<a title=previsualizar href=javascript:ver_cont_noadd('+eval('document.clase.conte'+i+'.value')+')><img src=/img/contenido.gif align=middle></a><a title=eliminar href=javascript:eliminar('+i+')><img src=/img/del.gif align=middle></a> '+eval('document.clase.name'+i+'.value'),'cont'+i)
		}
		else 
		{
			writit('','cont'+i)
		}
	}
}


function add_cont(name,id)
{
if (id_cont>7) {
	
	alert('No se pueden agregar mas de 7 contenidos a una guia interactiva')
	}
	
else
{
	nombre=document.getElementById('name'+id_cont);
	valor=document.getElementById('conte'+id_cont);
	nombre.value=name;
	valor.value=id;
	id_cont++;
	return esclay()
}	

}
function eliminar(id_del)
{
	if (id_del==7) 
	{
	document.clase.conte7.value=0;
	document.clase.name7.value='';
	id_cont=eval(id_cont+'-1')
	return esclay()	
	}
	else {
		for (i=id_del;i<7;i++) 
			{
				eval('document.clase.conte'+i+'.value=document.clase.conte'+eval(i+'+1')+'.value')
				eval('document.clase.name'+i+'.value=document.clase.name'+eval(i+'+1')+'.value')
			}
		document.clase.conte7.value=0;
		document.clase.name7.value='';
		id_cont=eval(id_cont+'-1')
		return esclay()
}
}



//  Scriptlets code written by Jeremy Edmiston
//  The functions have been adapted from various sources
//  and re-written to provide maximum flexibility
//  and compatability with various browsers.

//Global Declarations
var ie = (document.all) ? true : false;

function toggleClass(objClass){
//  This function will toggle obj visibility of an Element
//  based on Element's Class
//  Works with IE and Mozilla based browsers

  if (getElementByClass(objClass).style.display=="none"){
    showClass(objClass)
  }else{
    hideClass(objClass)
  }
}

function hideClass(objClass){
//  This function will hide Elements by object Class
//  Works with IE and Mozilla based browsers

var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    if (elements[i].className==objClass){
      elements[i].style.display="none"
    }
  }
}

function showClass(objClass){
//  This function will show Elements by object Class
//  Works with IE and Mozilla based browsers
var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    if (elements[i].className==objClass){
      elements[i].style.display="block"
    }
  }
}

function toggleID(objID){
//  This function will toggle obj visibility of an Element
//  based on Element's ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  if (element.style.display=="none"){
    showID(objID)
  }else{
    hideID(objID)
  }
}

function hideID(objID){
//  This function will hide Elements by object ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  element.style.display="none"
}

function showID(objID){
//  This function will show Elements by object ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  element.style.display="block"
}

function getElementByClass(objClass){
//  This function is similar to 'getElementByID' since there
//  is no inherent function to get an element by it's class
//  Works with IE and Mozilla based browsers
var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    //alert(elements[i].className)
    //alert(objClass)
    if (elements[i].className==objClass){
    return elements[i]
    }
  }
}