// *******************************************************
// Libreria de Scripts comunes al Framework NEO
// Propiedad de MakeIT Consulting
// *******************************************************


function ResolveUrl(relativePath) {
	if( relativePath.indexOf('~') === 0 ) {
		if( typeof(g_applicationRootPath) === 'string' ) {
			return relativePath.replace('~', g_applicationRootPath);
		}
		else {
			return relativePath.substr(1);
		}
	}
	else {
		return relativePath;
	}
}

// Esta funcion es para ejecutar una busqueda por ID
function doGlobalSearch() {
	window.location = ResolveUrl('~/propiedades/' + document.getElementById('txtBuscarCodigo').value);
}

// Esta funcion abre el visor de imagenes
// Recibe el ID de la imagen (sin Entidad)
//   o el ID del registro y el nombre de la Entidad
function OpenGalleryViewer(DataID)
{
	OpenDialog(ResolveUrl('~/galleryviewer.aspx?ShowID=' + DataID), 508, 480);
}

// Esta funcion permite abrir un dialogo modal sin necesidad de 
// hacer un postbak para crear el script.
function OpenModalDialog(dialogURL, dialogHeight, dialogWidth, doPostback, dialogName)
{
	var iRandomContainer = Math.random()*4;
	var DialogReturn, sURL, sParams;
	sURL = ResolveUrl('library/dialogContainer.aspx?__rnd=' + iRandomContainer + '&src=' + escape(dialogURL));
	sParams = 'dialogHeight:' + dialogHeight + 'px;dialogWidth:' + dialogWidth + 'px;center:Yes;help:No;resizable:No;status:No;scroll:No;'
	DialogReturn = window.showModalDialog(sURL, '', sParams);
	if (DialogReturn != '' && doPostback == true)
	{
		document.forms(0).__DIALOGRETURN.value=DialogReturn;
		__doPostBack('_ctl1', dialogName);
	}
}

// Esta funcion permite abrir un dialogo NO-modal sin necesidad de 
// hacer un postbak para crear el script.
function OpenDialog(dialogURL, dialogHeight, dialogWidth)
{
	var sURL, sParams;
	sURL = ResolveUrl(dialogURL);
	sParams = 'height=' + dialogHeight + ',width=' + dialogWidth + ',resizable=No,status=No,scrollbars=No;'
	window.open(sURL, '', sParams);
}

