 var win = null;
  var index = 1;
	function openDialog(id) {
	  Dialog.alert($(id).innerHTML, {className: "alphacube",  width:450, height:200, okLabel: "Aceptar", id: "d" + index})
	  index++;
  }
  
  function lastDialog(id) {
	  Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:350, height:280, okLabel: "Close All", ok: closeAllModalWindows})
  }
  
  function closeAllModalWindows() {
    Windows.closeAllModalWindows();
    return true;
  }
  
function addgroup(selectId,  label)
{
	optGroup = document.createElement('optgroup')
	optGroup.label = label;
    document.getElementById(selectId).appendChild(optGroup);
}
function addOption(selectId,  txt, val)
{
    var objOption = new Option(txt,val);

//    objOption.id = optionId;
    document.getElementById(selectId).options.add(objOption);
}
function selOption(selectId,valor)
{
    obj = document.getElementById(selectId);
	contador=0;
	for(n=0;n<obj.length;n++)
	{
		if(obj[n].value==valor)
		{
			document.getElementById(selectId).selectedIndex=contador;	
			break;
		}
		contador++;
	}
}

function subOption(selectId,valor)
{
    obj = document.getElementById(selectId);
	for(n=0;n<obj.length;n++)
	{
		if(obj[n].value==valor) obj[n].removeNode();
	}
}

function addOptionSELECTED(selectId,  txt, val)
{
	
	indice=document.getElementById(selectId).length;
	var objOption = new Option(txt,val);
    document.getElementById(selectId).options.add(objOption);
	document.getElementById(selectId).selectedIndex=indice;	
}

function emptryDropdown(selectId)
{
    obj = document.getElementById(selectId);
    while(obj.hasChildNodes() == true)
    {
        obj.removeChild(obj.childNodes[0]);
    }
}


function ventana(fichero,alto,ancho) {
posancho=(screen.width/2)-(ancho/2);
posalto=(screen.height/2)-(alto/2);
vent=window.open(fichero,'documento', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top='+posalto+',left='+posancho+',width='+ancho+',height='+alto);
vent.focus();
}

function ventana2(fichero,alto,ancho) {
posancho=(screen.width/2)-(ancho/2);
posalto=(screen.height/2)-(alto/2);
vent=window.open(fichero,'documento', 'toolbar=no,location=no,status=no,scrollbars=yes,resizable=0,titlebar = no,top='+posalto+',left='+posancho+',width='+ancho+',height='+alto);
vent.focus();
}

function vi(fichero,titulo) {
vent=window.open('vi.php?fichero='+fichero+'&titulo='+titulo,'ventana', 'toolbar=no,location=no,status=no,scrollbars=no,width=20,height=20');
vent.focus();
}


function visualizador(fichero,pagina) 
{
 vent=window.open('visuimg/visualizador.php?tam=1&direct='+fichero+'&page='+pagina,'imagen', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top=0,left=0,width='+(screen.availWidth-10)+',height='+(screen.availHeight-29));
 vent.focus();
}

function editor(fichero)
{
w=790;
h=590;
ancho=(screen.width/2)-(w/2);
alto=(screen.height/2)-(h/2);
var vent = window.open(fichero,'editor', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top='+alto+',left='+ancho+',width='+w+',height='+h);
 vent.focus();
}

window.name="MAIN";

function indice(url)
{
ancho=(screen.width/2)-(734/2);
alto=(screen.height/2)-(520/2);

var newWind = window.open('','indices', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top='+alto+',left='+ancho+',width=734,height=520');
if(newWind.document.title=="")
{
   newWind.close();
   newWind=window.open(url,'indices', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top='+alto+',left='+ancho+',width=734,height=520');
}

newWind.focus();

/*if (newWind.opener == null) {
newWind.opener = self
}*/

//ancho=(screen.width/2)-(734/2);
//alto=(screen.height/2)-(520/2);
//  ventindice=window.open(url,'indices', 'toolbar=no,location=no,status=no,scrollbars=no,resizable=0,titlebar = no,top='+alto+',left='+ancho+',width=734,height=520');
//ventindice.focus();
}


function opciontab(seleccionada,layer)
{
        document.getElementById('opcion1').className="noseleccionado";
        document.getElementById('opcion2').className="noseleccionado";
        document.getElementById('opcion3').className="noseleccionado";
        shd('ventanabuscador','none');
        shd('ventanacarrito','none');
        shd('ventanamonedero','none');
/*        if(window.opera) shd('publicacion','none');
        shd('ficha','none');
        shd('imprimir','none');
        shd('configuracion','none');*/

        document.getElementById(seleccionada).className="seleccionado";
        shd(layer,'block');
        return;
}

function shd(idlayer,visStr) { //v2.5

          if (document.getElementById)
                  { // Netscape 6 & IE 6
                document.getElementById(idlayer).style.display=visStr;

//                                document.getElementById('Layer1').style.visibility='hidden';
                  } else {
              if (navigator.appName == 'Netscape' && document.layers != null) // Netscape 4
                  {
                  document.layers[idlayer].style.display=visStr;
                  } else if (document.all != null) { //IE 4+
                  document.all[idlayer].style.display=visStr;}
                  }
}
