/*****************************************************************************************
   JavaScript obtained from http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp 
   on 10/05/06 
   
   HTML output of it was completely modified to match our formatting, but the functionality
   of it was left intact.
 *****************************************************************************************/
 
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,requestType)
 {

    ModalDialogRemoveWatch();
    ModalDialog.eventhandler = EventHandler;

    var args='width=400,height=200,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('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	ModalDialogWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
	ModalDialogWindow.document.write('<head>');
	ModalDialogWindow.document.write('<BASE HREF="http://www.vitalsmarts.com/UserFiles/File/silencefails/">');
	ModalDialogWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />');
	ModalDialogWindow.document.write('<title>' + Title + '</title>');
	ModalDialogWindow.document.write('<style type="text/css">');
	ModalDialogWindow.document.write('');
	ModalDialogWindow.document.write('body {');
	ModalDialogWindow.document.write(' padding: 0;');
	ModalDialogWindow.document.write(' margin: 0;');
	ModalDialogWindow.document.write('	color: #000; ');
	ModalDialogWindow.document.write('	font-family: Verdana, Arial, sans-serif;');
	ModalDialogWindow.document.write(' background-color: #d8d8d8;');
	ModalDialogWindow.document.write('}');
	ModalDialogWindow.document.write('');
	ModalDialogWindow.document.write('a {');
	ModalDialogWindow.document.write('  color: #fff;');
	ModalDialogWindow.document.write('  text-align: center;');
	ModalDialogWindow.document.write('  border: 1px solid #d8d8d8;');
	ModalDialogWindow.document.write('  font-weight: bold;');
	ModalDialogWindow.document.write('  background-color: #a91224;');
	ModalDialogWindow.document.write('  padding: 3px 3px 3px 3px;');
	ModalDialogWindow.document.write('  text-decoration: none;');
	ModalDialogWindow.document.write('}');
	ModalDialogWindow.document.write('a:hover {');
	ModalDialogWindow.document.write('  color: #fff;');
	ModalDialogWindow.document.write('  background-color: #d8d8d8;');
	ModalDialogWindow.document.write('  border: 1px solid #a91224;');
	ModalDialogWindow.document.write('}');
	ModalDialogWindow.document.write('#warning_message {');
	ModalDialogWindow.document.write('	position: absolute;');
	ModalDialogWindow.document.write('	top: 10px;');
	ModalDialogWindow.document.write('	width: 380px;');
	ModalDialogWindow.document.write('	left: 10px;');
	ModalDialogWindow.document.write('	height: 150px;');
	ModalDialogWindow.document.write('}');
	ModalDialogWindow.document.write('');
	ModalDialogWindow.document.write('</style>');
	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.opener.ModalDialog.reqType = \'' + requestType + '\';');	
    ModalDialogWindow.document.write(' window.close(); ');
    ModalDialogWindow.document.write('} ');
    ModalDialogWindow.document.write('</script' + '>');
	ModalDialogWindow.document.write('</head>');
	ModalDialogWindow.document.write('');
	ModalDialogWindow.document.write('<body onblur="window.focus();">');
	ModalDialogWindow.document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">');
	ModalDialogWindow.document.write('</script>');
	ModalDialogWindow.document.write('<script type="text/javascript">');
	ModalDialogWindow.document.write('_uacct = "UA-605896-4";');
	ModalDialogWindow.document.write('urchinTracker(\'download_request/' + requestType + '.pdf\');');
	ModalDialogWindow.document.write('</script>');	
//	ModalDialogWindow.document.write('<img name="bkgnd" src="/images/bkgnd.jpg" width="400" height="200" border="0" id="bkgnd" alt="" />');
	ModalDialogWindow.document.write('<div id="warning_message">'); 
	ModalDialogWindow.document.write('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2>');
    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>' + Buttons + '</td></tr></table>');
	ModalDialogWindow.document.write('</body>');
	ModalDialogWindow.document.write('</html>');
	ModalDialogWindow.document.write('');
    ModalDialogWindow.document.close(); 
    ModalDialogWindow.focus(); 

    ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);

 }
