///////////////////////////////////////////////////////////
// Usage IEprompt("dialog descriptive text", "default starting value");

// IEprompt will call promptCallback(val)
// Where val is the user's input or null if the dialog was canceled.
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// You must create a promptCallback(val) function to handle
// the user input.  If you don't this script will fail and
// Bunnies will die.
///////////////////////////////////////////////////////////

// Showtextfield is a boolean which is used to show or hide the textfield

///////////////////////////////////////////////////////////
// These are global scope variables, they should remain global.
///////////////////////////////////////////////////////////
var _dialogPromptID=null;
var _blackoutPromptID=null;
///////////////////////////////////////////////////////////

function IEprompt(windowname,innertxt,def, formobj,showTextField) {

   that=this;

   this.wrapupPrompt = function (cancled) {
      // wrapupPrompt is called when the user enters or cancels the box.      
     
     
       if(showTextField)
       {
         val=document.getElementById('iepromptfield').value;
        } 
         // clear out the dialog box
         _dialogPromptID.style.display='none';
         // clear out the screen
         _blackoutPromptID.style.display='none';
         // clear out the text field
         if(showTextField)
         {
         document.getElementById('iepromptfield').value = '';  
         }
         
         _dialogPromptID=null;
         _blackoutPromptID=null;
                
         // if the cancel button was pushed, force value to null.
         if (cancled) { val = 'Cancelled' }
         // call the user's function
         if(showTextField)
         {
         promptCallback(val,formobj);
         }
         else
         {
         if (cancled)
          val=false;
          else
          val=true;
	      promptCallbackFornoTextField(val,formobj);
         }
       
      return false;
      
   }

   //if def wasn't actually passed, initialize it to null
   if (def==undefined) { def=''; }

   // Check to see if we've created the dialog divisions.
         // 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');
         // name it
         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='#555555';
         _blackoutPromptID.style.filter='alpha(opacity=90)';
         _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 #1A368D';
         _dialogPromptID.style.backgroundColor='#DDDDDD';
         _dialogPromptID.style.position='absolute';
         _dialogPromptID.style.width='450px';
         _dialogPromptID.style.zIndex='100';
      // This is the HTML which makes up the dialog box, it will be inserted into
      // innerHTML later. We insert into a temporary variable because
      // it's very, very slow doing multiple innerHTML injections, it's much
      // more efficient to use a variable and then do one LARGE injection.
      var tmp = '<div id="iePromptDiv" style="width: 100%;height: 25px" class="acteva_prompt_header"><div style="padding:6px">'+windowname+'</div></div>';
      
      if(def=='waitScreen'){
      tmp += '<BR><BR><center>';
      tmp+='<img border="0" src="base/images/loading.gif"/>';
      tmp += '<BR><BR><div style="padding: 10px" class="acteva_prompt_detail">'+innertxt + '<BR><BR>';
      }
      else{   
      if(def=='doNotShowCancel'){
      tmp += '<div style="padding: 10px" class="acteva_prompt_detail_justify">'+innertxt + '<BR>';
      }
      else{
      tmp += '<div style="padding: 10px" class="acteva_prompt_detail">'+innertxt + '<BR><BR>';
      }  
      tmp += '<form action="" onsubmit="return that.wrapupPrompt()">';
      if(showTextField)
      {
	      if(def == 'password')
	      { 
	      	tmp += '<input id="iepromptfield" name="iepromptdata" type=password size=46 value="">';
	      }
	      else
	      {
	      	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;">';
      tmp += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
      if(def!='doNotShowCancel'){      
      tmp += '<input type="button" onclick="that.wrapupPrompt(true)" value="&nbsp;Cancel&nbsp;">';
      }
      }
      tmp += '</form></div>';
      // Stretch the blackout division to fill the entire document
      // and make it visible.  Because it has a high z-index it should
      // make all other elements on the page unclickable.
      _blackoutPromptID.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
      _blackoutPromptID.style.width='100%';
      _blackoutPromptID.style.display='block';
      // Insert the tmp HTML string into the dialog box.
      // Then position the dialog box on the screen and make it visible.
      _dialogPromptID.innerHTML=tmp;     
      var browserName=navigator.userAgent;
      if(browserName.indexOf('Safari') > 1)
      {
      	_dialogPromptID.style.top=parseInt(document.body.scrollTop+(screen.height/4))+'px';
      } 
      else
      {
      	_dialogPromptID.style.top=parseInt(document.documentElement.scrollTop+(screen.height/4))+'px';
      }
      
      
      _dialogPromptID.style.left=parseInt((document.body.offsetWidth-315)/2.5)+'px';
      _dialogPromptID.style.display='block';
      // Give the dialog box's input field the focus.
      if(showTextField){
      document.getElementById('iepromptfield').focus();
      }  	     
}

// For rounded corners 
    settings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: false,
      br: false,
      antiAlias: true,
      autoPad: true
    } 
    
    
    

