
// ABREVENTANA
function abreventana(url, name, w, h, perc, scroll) {

        var winX = (screen.availWidth - w)*perc*.01;
        var winY = (screen.availHeight - h)*perc*.01;
        popupWin = window.open(url, name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=0,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
		if ((document.window != null) && (!popupWin.opener)) 
             popupWin.opener = document.window; 
             popupWin.focus(); 

}

function abreventanaResize(url, name, w, h, perc, scroll) {

        var winX = (screen.availWidth - w)*perc*.01;
        var winY = (screen.availHeight - h)*perc*.01;
        popupWin = window.open(url, name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=1,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
		if ((document.window != null) && (!popupWin.opener)) 
             popupWin.opener = document.window; 
             popupWin.focus(); 

}
				
function ventanaSize(w,h)
{
if (document.all) 
	{
		window.resizeTo(w,h);

	}
else if (document.layers||document.getElementById)
	{
	if ( window.outerHeight<screen.availHeight|| window.outerWidth<screen.availWidth)
		{
		 window.outerHeight=h;
		 window.outerWidth = w;
		}
	}

}

function capaVisible(id)
	{
 if (document.layers) document.layers[''+id+''].visibility = "show"
        else if (document.all) document.all[''+id+''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"                
    }
function capaInvisible(id)
	{
        if (document.layers) document.layers[''+id+''].visibility = "hide"
        else if (document.all) document.all[''+id+''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"             

	}
	
function capaMostraOcultar(id){
	if(document.getElementById(''+id+'').style.display == "none"){
		document.getElementById(''+id+'').style.display = "";
	}
	else{
		document.getElementById(''+id+'').style.display = "none";
	}
}
	
function capaPos(id,x,y,v)
	{
	if(v==0)
		{	
        if (document.layers) document.layers[''+id+''].left = x;
        else if (document.all) document.all[''+id+''].style.left = x;
        else if (document.getElementById) document.getElementById(''+id+'').style.left = x;
    	}
	if(v==1)
		{	
        if (document.layers) document.layers[''+id+''].top=y;
        else if (document.all) document.all[''+id+''].style.top=y;
        else if (document.getElementById) document.getElementById(''+id+'').style.top=y;
		}
	if(v==2)
		{	
        if (document.layers) document.layers[''+id+''].left = x;
        else if (document.all) document.all[''+id+''].style.left = x;
        else if (document.getElementById) document.getElementById(''+id+'').style.left = x;
        if (document.layers) document.layers[''+id+''].top=y;
        else if (document.all) document.all[''+id+''].style.top=y;
        else if (document.getElementById) document.getElementById(''+id+'').style.top=y;
		}
	}
	
function domlay(id,trigger,lax,lay,content) {

    /*
     * Cross browser Layer visibility / Placement Routine
     * Done by Chris Heilmann (mail@ichwill.net)
     * Feel free to use with these lines included!
     * Created with help from Scott Andrews.
     * The marked part of the content change routine is taken
     * from a script by Reyn posted in the DHTML
     * Forum at Website Attraction and changed to work with
     * any layername. Cheers to that!
     * Welcome DOM-1, about time you got included... :)
     */
    // Capa visible
    if (trigger=="1"){
        if (document.layers) document.layers[''+id+''].visibility = "show"
        else if (document.all) document.all[''+id+''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"                
        }
    // Capa Invisible
    else if (trigger=="0"){
        if (document.layers) document.layers[''+id+''].visibility = "hide"
        else if (document.all) document.all[''+id+''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"             
        }
    // Posicion horizontal
    if (lax){
        if (document.layers){document.layers[''+id+''].left = lax}
        else if (document.all){document.all[''+id+''].style.left=lax}
        else if (document.getElementById){document.getElementById(''+id+'').style.left=lax+"px"}
        }
    // Posicion vertical
    if (lay){
        if (document.layers){document.layers[''+id+''].top = lay}
        else if (document.all){document.all[''+id+''].style.top=lay}
        else if (document.getElementById){document.getElementById(''+id+'').style.top=lay+"px"}
        }
    // Cambiar Contenido

    if (content){
    if (document.layers){
        sprite=document.layers[''+id+''].document;
        // Añadir capas padre si son necesarias! document.layers[''+father+'']...
        sprite.open();
        sprite.write(content);
        sprite.close();
        }
    else if (document.all) document.all[''+id+''].innerHTML = content;  
    else if (document.getElementById){
        rng = document.createRange();
        el = document.getElementById(''+id+'');
        rng.setStartBefore(el);
        htmlFrag = rng.createContextualFragment(content)
        while(el.hasChildNodes()) el.removeChild(el.lastChild);
        el.appendChild(htmlFrag);
        }
    }
}	

// Desactiva un botón y muestra un mensaje

function desactivarBoton(boton) {
	boton.value="Por favor espere ...";
	boton.disabled = true;
	//alert(boton.value);
}

// ANADIR OPCIONES DINÁMICAS - Esta función debe estar en la página origen.
// EN la ventana abierta está la función addOptions on
function addOptionPadre(campo,theText, theValue)
{
  var theSel = document.getElementById(campo);
  var newOpt = new Option(theText, theValue,true, true);
  theSel.options[theSel.length] = newOpt;
}


