var lang = null;
var MSG = {};
MSG = {
	"es":{
		"MSG_SELECT_A_REGISTER":"Debe seleccionar un registro por lo menos",
		"MSG_DELETE_REGISTERS":"Quieres eliminar esta(s) entrada(s) completamente ?",
		"MSG_ACCEPT_THIS_REQUEST":"Quieres aceptar esta solicitud ?",
		"MSG_REJECT_THIS_REQUEST":"Quieres ignorar esta solicitud ?",
		"MSG_END_DATE_CAN_NOT_BE_LESS_THAN_SATRT_DATE":"La fecha final no puede ser menor a la inicial"
	},
	"en":{
		"MSG_SELECT_A_REGISTER":"You should select at least a register",
		"MSG_DELETE_REGISTERS":"Do you want to eliminate this/these register(s) completely ?",
		"MSG_ACCEPT_THIS_REQUEST":"Do you want to accept this request ?",
		"MSG_REJECT_THIS_REQUEST":"Do you want to ignore this request ?",
		"MSG_END_DATE_CAN_NOT_BE_LESS_THAN_SATRT_DATE":"The end date can not be less than start date"
	}
}

function deleteNotificacion() {

		var s = "";
		var space = "";
		document.getElementById("MM_list").value = "";
		var j = 0;
		if ( document.formNotificacion.notificacion.length > 0 ) {
			for( i=0; i<document.formNotificacion.notificacion.length; i++ ) {
				if( document.formNotificacion.notificacion[i].checked == true ) {
					space = j == 0 ? "" : ",";
					document.getElementById("MM_list").value = String( document.getElementById("MM_list").value + space + String( document.formNotificacion.notificacion[i].id).substr(13) );
					j++;
				}
			}
		}
		else {
			if( document.formNotificacion.notificacion.checked == true ) {
				document.getElementById("MM_list").value = String( document.formNotificacion.notificacion.id).substr(13);
				j++;
			}
		}
		if ( j == 0 ) { s = s + MSG[lang]['MSG_SELECT_A_REGISTER'] + "\n"; }
		if( s != "" ) {
			alert(s);
			return false;
		}
		var r = confirm(MSG[lang]['MSG_DELETE_REGISTERS']);
		if (r) {
			// document.formNotificacion.notificacion.name = "notificacion[]";
			document.formNotificacion.MM_delete.value=1;
			document.formNotificacion.MM_tipo.value=0;
			document.formNotificacion.submit();
		}
	}
	
	function aceptarSolicitud(v,t) {
		var r = confirm(MSG[lang]['MSG_ACCEPT_THIS_REQUEST']);
		if (r) {
			document.formNotificacion.MM_accion.value=1; // Aceptar
			document.formNotificacion.MM_tipo.value=t;
			document.formNotificacion.MM_id.value=v;
			document.formNotificacion.submit();
		}
	}
	
	function ignorarSolicitud(v,t) {
		var r = confirm(MSG[lang]['MSG_REJECT_THIS_REQUEST']);
		if (r) {
			document.formNotificacion.MM_accion.value=0; // Ignorar
			document.formNotificacion.MM_tipo.value=t;
			document.formNotificacion.MM_id.value=v;
			document.formNotificacion.submit();
		}
	}
	
	function searchNotificacion() {
		if( document.formSearch.hasta.value < document.formSearch.desde.value ) {
			alert(MSG[lang]['MSG_END_DATE_CAN_NOT_BE_LESS_THAN_SATRT_DATE']);
			return false;
		}
		document.formSearch.MM_search.value=1;
		document.formSearch.submit();
	}
	
	function cleanformNotificacion() {
		document.formSearch.tipo.selectedIndex = 0;
		document.formSearch.asunto.value = "";
		document.formSearch.desde.value = "";
		document.formSearch.hasta.value = "";
	}
