function ShowModalSignedDialog(signedURL)
{
	var retvalue;
	retvalue = window.showModalDialog(signedURL, window, "dialogHeight: 500px; dialogWidth: 800px; edge: Raised; center: Yes; help: No; resizable: Yes; status: Yes; ");
	
	// two or more values
	if (retvalue && retvalue.length>=2)
	{
		document.forms[0].txtBrwSel.value = retvalue[1];
		document.forms[0].__EVENTTARGET.value="";
		document.forms[0].submit();
	}
	// only one value
	else if ((retvalue!=null) && (retvalue[0] != "") && (retvalue[0] != "undefined"))
	{
		document.forms[0].txtBrwSel.value = retvalue[0];
		document.forms[0].__EVENTTARGET.value="";
		document.forms[0].submit();
	}
}

function GetById(id)
{
	return document.getElementById(id);
}

function GetByName(name)
{
	return document.getElementByName(name);
}

function GetByTag(id, tag)
{
	if(IsEmpty(id)) return document.getElementsByTagName(tag);
	return GetById(id).getElementsByTagName(tag);	
}

function GetValue(id)
{
	var o = GetById(id);
	if(IsNull(o)) return null;
	return o.value;
}

function GetText(id)
{
	var o = GetById(id);
	if(IsNull(o)) return null;
	return GetById(id).innerText;
}

function GetHTML(id)
{
	var o = GetById(id);
	if(IsNull(o)) return null;
	return GetById(id).innerText;
}

function SetValue(id, value)
{
	var o = GetById(id);
	if(!IsNull(o)) GetById(id).value = value;
}

function SetImg(id, src)
{
	var oImg = GetById(id);
	if(!IsNull(oImg)) oImg.src = src;
}

function SetText(id, text)
{
	var o = GetById(id);	
	if(!IsNull(o)) GetById(id).innerText = text;
}

function SetHTML(id, html)
{
	var o = GetById(id);
	if(!IsNull(o)) GetById(id).innerHTML = html;
}

function IsNull(obj)
{
	return (typeof(obj) == "undefined") || (obj == null);
}

function IsEmpty(val)
{
	return (val == null) || (val == "");
}

function IsNotEmpty(val)
{
	return (val != null) && (val != "");
}

function Show(id)
{
	var o = GetById(id);
	if(!IsNull(o)) o.style.display = '';
}

function Hide(id)
{
	var o = GetById(id);
	if(!IsNull(o)) o.style.display = 'none';
}

function Enable(id)
{
	var o = GetById(id);
	if(!IsNull(o)) o.disabled = false;
}

function Disable(id)
{
	var o = GetById(id);
	if(!IsNull(o)) o.disabled = true;
}

function Switch(id)
{
	var o = GetById(id);
	if(IsNull(o)) return;
  if(o.style.display == 'none') o.style.display = '';
  else o.style.display = 'none';
}

function IsVisible(id)
{
	var o = GetById(id);
	return (o.style.display != "none") && (o.style.visibility != "hidden");
}

// Desactivar una alerta.
function SubmitByParam(paramId, paramValue, message)
{	
	if(!confirm(message)) return;
	var sUrl = location.href.toLowerCase();
	sUrl = sUrl.replace("#", "");
	var sParam = paramId + "=" + paramValue;
	if(sUrl.indexOf("?") < 0) sUrl += "?" + sParam;
	else
	{
		var iPos = sUrl.indexOf(paramId);
		if(iPos < 0) sUrl += "&" + sParam;
		else
		{
			var iEnd = sUrl.indexOf("&", iPos);			
			var sAux = sUrl.substring(0, iPos) + sParam;
			if(iEnd >= 0)
				sUrl = sAux + sUrl.substring(iEnd, sUrl.length);
			else sUrl = sAux;
		}
	}
	
	location.replace(sUrl);
}function getURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?"));
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if( 
				aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return unescape(strReturn);
}

function pnlDesplegar(control)
{
  var oControl=document.getElementById(control);
  if (oControl.style.display == 'none')
     {oControl.style.display = '';}
  else   
     {oControl.style.display = 'none';}
}

//Comportamientos ( si hay mootools)
if  (typeof MooTools != 'undefined')
{

window.addEvent('load',function()
{
	// Para ejecutar los paneles contraibles.
	$$('.CollapsiblePanel').each(function(obj)
	{
		// Se obtinen los controles a traves de las clases PanelToHide y PanelManager
		var myElements = obj.getElements('.PanelToHide');
		var panel = myElements[0];
		myElements = obj.getElements('.PanelManager');
		var PanelManager = myElements[0];

        // Se declara el efecto slide a ejecutar.
        var efecto = new Fx.Slide(panel, {duration:300, wait:false })
		// Si los elementos anteriores tienen float el wrapper generado por el slide debe 'limpiar' los float. 
		panel.getParent().setStyle('clear', 'both');
		//Si en vez de Collapse tiene la clase Expanda se esconde el panel.
		if (PanelManager.hasClass('Expand')==true)
		    efecto.hide();
        
        // Para que el efecto sea accesible desde cualquier punto a traves la propiedad efecto del Panel.
        PanelManager.efecto = efecto;
        
        // Se registra el evento que dispara el 'slide' al clicar en el PanelManager
    	PanelManager.addEvent('click',function()
    	{
    	    efecto.toggle(); 
    	    if (PanelManager.hasClass('PanelManagerIcon') == true)
    	    {
	            PanelManager.toggleClass('Collapse');
	            PanelManager.toggleClass('Expand');    	
    	    }
    	});
	});
	
	// Para ejecutar las tablas con enlaces.
	$$('a[href].MasterRowLink').each(function(obj)
	{
		// Se obtine el atributo con el link
		var oHref = obj.getProperty('href');
		var oTitle = obj.getProperty('Title');
		
		// Se obtiene la fila o tbody(conjunto de filas) a las que hay que aplicar el link
		var oFila = obj.getParent().getParent(); // TR
		var oParentFila = oFila.getParent(); // TBODY?
		// Si se trata de un conjunto de filas se usa el tbody
		if (oParentFila.hasClass('DoubleRow')) 
		    oFila = oParentFila;
    	// Se atacha el evento onclick en la fila correspondiente.
    	oFila.addEvent('click',function()
    	{
    	    location.href = oHref;
    	});
    	oFila.setProperty('Title',oTitle);
    	// Se Marca como link:
    	oFila.addClass('Selectable');
        // Se elimina el anchor (a)
		//obj.dispose();
	});
});	

}
