//---------------------- Constantes ----------------------
var MSTR_GRID_UNCHECKED = "~/IO/IMG/Checks/Unchecked.jpg"


//----------------------- Funciones -----------------------
// Quita los mensajes de errores
//window.onerror = function(){ return true; };

//Hide Controls (para el Menú que le estorban los combos)
var timeRef;
function cada1000()
{
	try 
	{
		if (window.parent.getHideControlsState() == "0") 
		{
			if (getControlShow() == "1") 
			{
				hideSelect("hidden");
				setControlShow("0");
			}
		}
	}
	catch(exp)
	{
	}
	
	try 
	{
		if (window.parent.getHideControlsState() == "1") 
		{
			if (getControlShow() == "0") 
			{
				hideSelect("visible");
				setControlShow("1");
			}
		}
	}
	catch(exp)
	{
	}
	timeRef = setTimeout("cada1000();",400);
}

function window_onload() 
{
	try
	{
		timeRef = setTimeout("cada1000();",400);
	}
	catch(exp)
	{
	}
}

function hideSelect(showStyle) 
{
	var controlIterator;
	for(controlIterator=document.all.length-1; controlIterator; controlIterator--)
	{
		if(document.all[controlIterator].tagName == "SELECT")
		{
            document.all[controlIterator].style.visibility = showStyle;
		}
	}
}

function getControlShow()
{
	var returnValueShow = "";
	try
	{
		returnValueShow =document.getElementById("controlShow").value;
	}
	catch(exp)
	{
		returnValueShow = "1";
	}
	return(returnValueShow);
}

function setControlShow(valueShow)
{
	try
	{
		document.getElementById("controlShow").value = valueShow;
	}
	catch(exp)
	{
	}
}
//window_onload(); // Está desactivado
//Hide Controls


// Despliega un mensaje de alerta
function DisplayAlert(message)
{
    alert(message);
}

// Despliega un mensaje de confirmación. Si el usuario cancela el evento se cancela
function QuestionToDelete(question)
{
	var answer = confirm(question);
    if (answer == false)
    {		        
        return false;
    }
    else
    {
		return true;
    }
}

// Asigna un mensaje de confirmación (msg) al botón con el id (id)
function AsignQuestionOnClick(id, msg)
{
	if(id != "")
	{
		var control = document.getElementById(id);
		if(control != null)
			control.onclick = new Function("QuestionToDelete('" + msg + "')");
	}
}

// Chequea todos los items del documento
function CheckAllItems()
{
	var a;
	var i=0;
	var r, re;
	for (a in window.document.all) 
	{ 
		r = a.search("SelectAllItems")
			if (r != -1)
			{
				re = i
			}
		i++;
	}
	//LuiSoft 12/10/2004
	if (re != null)
		window.document.all.item(re-1).src = MSTR_GRID_UNCHECKED; //"./IO/IMG/Checks/Unchecked.jpg";
}

// Manda los usuarios a la caja auxiliar y hace un postback
function sendBoxUsers(usuarios,box,boxUnique)
{
    document.getElementById(box).value = usuarios;
    __doPostBack(boxUnique,'');
}

// Valida el tamaño límite de un textarea 
function CheckOnKeypress(elementId, maxLength) 
{
	var element = document.getElementById(elementId);
	if(element != null && element.value.length >= maxLength)
		event.returnValue = false;
}

// Valida el tamaño límite de un textarea 
function CheckOnKeydownAndChange(elementId, maxLength) 
{
	var element = document.getElementById(elementId);
	if(element != null && element.value.length >= maxLength)
		element.value = element.value.substring(0, maxLength);
}

// Asigna a un botón la lectura del RichTextBox al darle Click
function AsignGetRTBOnClick(id)
{
	if(id != "")
	{
		var control = document.getElementById(id);
		if(control != null)
			control.onclick = new Function("GetRTB();");
	}
}

// Lee el texto del RichTextBox y llena las propiedades con estos valores
function GetRTB()
{
	document.getElementById("txtText").value = getText();
	document.getElementById("txtHtml").value = getHTML();
	document.getElementById("txtAction").value = "1";
	Form1.submit();
}
