
var _dialogPromptID=null;
var _blackoutPromptID=null;
///////////////////////////////////////////////////////////

function IEprompt(innertxt,def,promptCallback) {

   that=this;

   // Check to see if this is MSIE 7.   This isn't a great general purpose
   // detection system but it works well enough just to find MSIE 7.
   var _isIE7=(navigator.userAgent.indexOf('MSIE 7')>0);
//   _isIE7=true;
   this.wrapupPrompt = function (cancled) {
      // wrapupPrompt is called when the user enters or cancels the box.
      // It's called only by the IE7 dialog box, not the non IE prompt box
      if (_isIE7) {
         val=document.getElementById('iepromptfield').value;
         _dialogPromptID.style.display='none';
         _blackoutPromptID.style.display='none';
         document.getElementById('iepromptfield').value = '';
         if (cancled) { val = null }
         // call the user's function
//         promptCallback(val);
        if(val!=null){
          eval(promptCallback.replace('{%value}',val));
        }    
        return false;
      }
      return false;
   }

   if (def==undefined) { def=''; }

   if (_isIE7) {
      // If this is MSIE 7.0 then...
      if (_dialogPromptID==null) {
        var tmp = '<div style="width: 100%; background-color: #36578B; color: white; font-family: verdana; font-size: 10pt; font-weight: bold; height: 25px;padding:3px;border-bottom:1px solid #022A6B;background-image:url(\'/img/dialog-title-bar.png\')">Input Required</div>';
        tmp += '<div style="padding:10px;color:#022A6B;font-weight:bold;font-size:12px"><BR><div id=iepdtext>'+innertxt + '</div><BR>';
        tmp += '<form action="" onsubmit="return that.wrapupPrompt()">';
        tmp += '<input id="iepromptfield" name="iepromptdata" type=text size=46 value="'+def+'">';
        tmp += '<br><br><center>';
        tmp += '<input type="submit" value="&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;" onClick="that.wrapupPrompt();return false;">';
        tmp += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        tmp += '<input type="reset" onclick="that.wrapupPrompt(true);return false;" value="&nbsp;Cancel&nbsp;">';
        tmp += '</form></div>';
         // This block sets up the divisons
         // Get the body tag in the dom
         var tbody = document.getElementsByTagName("body")[0];
         // create a new division
         tnode = document.createElement('div');
         tnode.id='IEPromptBox';
         // attach the new division to the body tag
         tbody.appendChild(tnode);
         // and save the element reference in a global variable
         _dialogPromptID=document.getElementById('IEPromptBox');
         // Create a new division (blackout)
         tnode = document.createElement('div');
         // name it.
         tnode.id='promptBlackout';
         // attach it to body.
         tbody.appendChild(tnode);
         // And get the element reference
         _blackoutPromptID=document.getElementById('promptBlackout');
         // assign the styles to the blackout division.
         _blackoutPromptID.style.opacity='.9';
         _blackoutPromptID.style.position='absolute';
         _blackoutPromptID.style.top='0px';
         _blackoutPromptID.style.left='0px';
         _blackoutPromptID.style.backgroundColor='#444444';
         _blackoutPromptID.style.filter='alpha(opacity=50)';
         _blackoutPromptID.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
         _blackoutPromptID.style.display='block';
         _blackoutPromptID.style.zIndex='50';
         // assign the styles to the dialog box
         _dialogPromptID.style.border='2px solid #022A6B';
         _dialogPromptID.style.backgroundColor='#E3EDF7';
         _dialogPromptID.style.position='absolute';
         _dialogPromptID.style.width='335px';
         _dialogPromptID.style.zIndex='100';
        _dialogPromptID.innerHTML=tmp;
      }
      _blackoutPromptID.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
      _blackoutPromptID.style.width='100%';
      _blackoutPromptID.style.display='block';

      _dialogPromptID.style.top=parseInt(document.documentElement.scrollTop+(screen.height/3))+'px';
      _dialogPromptID.style.left=parseInt((document.body.offsetWidth-315)/2)+'px';
      _dialogPromptID.style.display='block';

      var iepf=document.getElementById('iepromptfield');
      document.getElementById('iepdtext').innerHTML=innertxt;
      iepf.value=def;
      iepf.focus();
   } else {
      val=prompt(innertxt,def);
        if(val!=null)
          eval(promptCallback.replace('{%value}',val));
       return false;
   }
}
