﻿function Calendario(control)
{
    var controlId = "ctl00$ContentPlaceHolder1$" + control;
	var formato = "dialogHeight:300px;dialogWidth:248px;scroll:no;status:no";
	var retorno = window.showModalDialog('Calendario.aspx?Fecha='+document.getElementById(controlId).value, '', formato);
	if (retorno!=undefined)
		document.getElementById(controlId).value = retorno;
}

function CalendarioHTML(control)
{
	var formato = "dialogHeight:275px;dialogWidth:248px;scroll:no;status:no";
	var retorno = window.showModalDialog('Calendario.aspx?Fecha='+document.getElementById(control).value, '', formato);
	if (retorno!=undefined)
		document.getElementById(control).value = retorno;
}

function MostrarMensaje(titulo, mensaje)
{
	ShowDialog('M', titulo, mensaje, '');
}

function MostrarConfirmacion(titulo, mensaje)
{
	var confirmacion = ShowDialog('C', titulo, mensaje, '')
	if (confirmacion!=undefined)
		return true;
	else
		return false;
}

function MostrarInput(titulo, mensaje, campo)
{
	var input = ShowDialog('I', titulo, mensaje, campo)
	return input;
}

function ShowDialog(accion, titulo, mensaje, campo)
{
	var formato = "dialogHeight:180px;dialogWidth:500px;scroll:no;status:no";
	return window.showModalDialog('Dialog.aspx?Accion=' + accion + '&Titulo=' + titulo + '&Mensaje=' + mensaje + '&Campo=' + campo, '', formato);
}

function Expand(controlId)
{
    control = eval("ctl00_ContentPlaceHolder1_" + controlId);
    if(control.style.display=="none")
    {
      control.style.display="";
    }
    else
    {
      control.style.display="none";
    }
}
function OpenPage(args)
{
	var indicePrimeraComa = args.indexOf(',');
	var indiceSegundaComa = args.indexOf(',', indicePrimeraComa + 1);
	var indiceTerceraComa = args.indexOf(',', indiceSegundaComa + 1);
	var url = args.substring(0, indicePrimeraComa);
	var target = args.substring(indicePrimeraComa + 2, indiceSegundaComa);
	var selectedParent = args.substring(indiceSegundaComa + 2, indiceTerceraComa);
	var selectedChild = args.substring(indiceTerceraComa + 2);
	if (url.indexOf('?') >= 0)
		url += '&';
	else
		url += '?';
	url += 'selectedparent=' + selectedParent + '&';
	url += 'selectedchild=' + selectedChild;
	window.open(url, target);
}

function CambiarAjusteLinea(idControl)
{
	var control = document.getElementById("ctl00_ContentPlaceHolder1_" + idControl);
	if ((control.getAttribute('wrap') != null) && (control.getAttribute('wrap') == 'soft'))
		control.setAttribute('wrap', 'off');
	else
		control.setAttribute('wrap', 'soft');
}

function BuscarContenido(controlNombreContenido, controlIdContenido)
{
	var controlBase = "ctl00_ContentPlaceHolder1_";
	var formato = "dialogHeight:650px;dialogWidth:800px;scroll:yes;status:no";
	var retorno = window.showModalDialog('SeleccionContenido.aspx', '', formato);
	if (retorno!=undefined)
	{
		var tbNombreContenido = document.getElementById(controlBase + controlNombreContenido);
		var hiIdContenido = document.getElementById(controlBase + controlIdContenido);

		var indiceBarrita = retorno.indexOf('|');
		hiIdContenido.value = retorno.substring(0, indiceBarrita);
		tbNombreContenido.value = retorno.substring(indiceBarrita + 1);
	}
}
