var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;

ModalDialog.value = '';
ModalDialog.eventhandler = '';


function ModalDialogMaintainFocus()
{
 try
 {
	 if (ModalDialogWindow.closed)
	 {
		 window.clearInterval(ModalDialogInterval);
		 eval(ModalDialog.eventhandler);
		 return;
	 }
		 ModalDialogWindow.focus();
	 }
 catch (everything) { }
}

 function ModalDialogRemoveWatch()
 {
	 ModalDialog.value = '';
	 ModalDialog.eventhandler = '';
 }

function ModalDialogShow(Title,BodyText,Buttons,EventHandler)
 {
	 ModalDialogRemoveWatch();
	 ModalDialog.eventhandler = EventHandler;
	
	 var args='width=350,height=125,left=325,top=300,toolbar=0,';
	 args+='location=0,status=0,menubar=0,scrollbars=0,resizable=0';
	
	 ModalDialogWindow=window.open("","",args);
	 ModalDialogWindow.document.open();
	 ModalDialogWindow.document.write('<html>');
	 ModalDialogWindow.document.write('<head>');
	 ModalDialogWindow.document.write('<title>' + Title + '</title>');
	 ModalDialogWindow.document.write('<script' + ' language="JavaScript">');
	 ModalDialogWindow.document.write('function CloseForm(Response) ');
	 ModalDialogWindow.document.write('{ ');
	 ModalDialogWindow.document.write(' window.opener.ModalDialog.value = Response; ');
	 ModalDialogWindow.document.write(' window.close(); ');
	 ModalDialogWindow.document.write('} ');
	 ModalDialogWindow.document.write('</script' + '>');
	 ModalDialogWindow.document.write('<link href="/SestifeWeb/generales/inc/css/estilos-itelem.css" rel="stylesheet" type="text/css" media="screen">');
	 ModalDialogWindow.document.write('</head>');
	 ModalDialogWindow.document.write('<body onblur="window.focus();" id="body_iframe">');
	 ModalDialogWindow.document.write('<H3>Mensaje de Advertencia</H3>');
	 ModalDialogWindow.document.write('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2 id=body_iframe>');
	 ModalDialogWindow.document.write('<tr><td align=left>' + BodyText + '</td></tr>');
	 ModalDialogWindow.document.write('<tr><td align=left><br></td></tr>');
	 ModalDialogWindow.document.write('<tr><td align=center><form id=form>' + Buttons + '</form></td></tr>');
	 ModalDialogWindow.document.write('</table></div>');
	 ModalDialogWindow.document.write('</body>');
	 ModalDialogWindow.document.write('</html>');
	 ModalDialogWindow.document.close();
	 ModalDialogWindow.focus();
	 ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
 }
 
 function YesNoCancel(BodyText,EventHandler)
 {
	 var Buttons='';
	 Buttons += '<button class=button onclick=CloseForm("Aceptar");>Aceptar</button>&nbsp;&nbsp;';
	 Buttons += '<button class=button onclick=CloseForm("Cancelar");>Cancelar</button>&nbsp;&nbsp;';
	 ModalDialogShow("Dialog",BodyText,Buttons,EventHandler);
 }
 
 function MensajeError(BodyText,EventHandler)
 {
 	 var Buttons='';
	 Buttons += '<button class=button onclick=CloseForm("Aceptar");>Aceptar</button>&nbsp;&nbsp;';
	 ModalDialogShow("Dialog", BodyText ,Buttons,EventHandler);
 }
 
 function MensajeErrorVacio(BodyText,EventHandler)
 {
 	 var Buttons='';
	 Buttons += '<button class=button onclick=CloseForm("Aceptar");>Aceptar</button>&nbsp;&nbsp;';
	 ModalDialogShow("Dialog",'El campo ' + BodyText + ' esta vacio',Buttons,EventHandler);
 }
 
  function MensajeErrorGral(BodyText,EventHandler)
 {
 	 var Buttons='';
	 Buttons += '<button class=button onclick=CloseForm("Aceptar");>Aceptar</button>&nbsp;&nbsp;';
	 ModalDialogShow("Dialog",BodyText,Buttons,EventHandler);
 }
 
 function MensajeValidaciones(BodyText,EventHandler)
 {
 	 var Buttons='';
	 Buttons += '<button class=button onclick=CloseForm("Aceptar");>Aceptar</button>&nbsp;&nbsp;';
	 ModalDialogShow("Dialog",'Error : ' + BodyText,Buttons,EventHandler);
 }
 
 