/*************************************************************************
									DATAGRID
**************************************************************************/
	
var dtg_selectedIndex = -1;

// Selecciona el item seleccionado
function SeleccionaItem(value, rowIndex, datagrid, hiddenInput){
	ColoraItem(rowIndex, datagrid);
	// Guardo el id seleccionado en el input oculto
	document.getElementById(hiddenInput).value = value;
}

// Colora el item seleccionado
function ColoraItem(index, datagrid){
	var arrFilas = document.getElementById(datagrid).rows;
	if(dtg_selectedIndex != -1) arrFilas[dtg_selectedIndex].className = 'filaNormal';
	arrFilas[index + 1].className = 'filaSeleccionada';
	dtg_selectedIndex = index + 1;
}

// Muestra un confirm despues de comprobar si hay elemento seleccionado
function EliminarItem(sMensajeSeleccionar, sMensajeConfirmacion,nombreGrid){
	if (ComprobarSeleccion(sMensajeSeleccionar,nombreGrid))
		return confirm(sMensajeConfirmacion);
	else 
		return false;
}

// Comprueba si hay un elemento seleccionado
function ComprobarSeleccion(sMensajeSeleccionar,nombreGrid){
	// Comprueba si hay un elemento seleccionado
	if(document.getElementById(nombreGrid + "_selectedValue") == null || 
		 document.getElementById(nombreGrid + "_selectedValue").value == ""){
		alert(sMensajeSeleccionar);
		return false;
	}
	else{
		return true;
	}
}

// Abre una ventana no modal y la centra
function MuestraVentana(URL, height, width){
	lPos = (screen.width) ? (screen.width - width) / 2 : 0; 
	tPos = (screen.height) ? (screen.height - height) / 2 : 0;
	var sPropiedades = 'height=' + height + ',width=' + width + 
										 ',left=' + lPos + ',top=' + tPos + 
										 ',status=0,toolbar=0,menubar=0,location=0,resizable=0,border=0';
	window.open(URL, '', sPropiedades, true);
	return false;
}

// Abre una ventana no modal,la centra y con scroll
function MuestraVentanaScroll(URL, height, width){
	lPos = (screen.width) ? (screen.width - width) / 2 : 0; 
	tPos = (screen.height) ? (screen.height - height) / 2 : 0;
	var sPropiedades = 'height=' + height + ',width=' + width + 
										 ',left=' + lPos + ',top=' + tPos + 
										 ',status=0,toolbar=0,menubar=0,location=0,resizable=0,border=0,scrollbars=1';
	window.open(URL, '', sPropiedades, true);
	return false;
}

// Abre una ventana modal y la centra
function MuestraVentanaModal(URL, height, width){
	var sPropiedades = 'status:no; resizable: no; help:no; ' +
										 'dialogWidth:' + width + 'px;' +
										 'dialogHeight:' + height + 'px';
	window.showModalDialog(URL, '', sPropiedades);
	return false;
}

