// ------------------------ ADL PROMPT SCRIPT -----------------------

var adlprompt_tw=new Fx.Tween();

//ADL
// width & height can be undefined, closemessage also
// top&left can be -1 (be careful with page that have flash : with IE7 flash goes above)
function adl_simpleprompt(htmlmessage,width,height,closemessage,top,left)
{
  $('adlprompt_modal').setStyles({'width':'100%','height':'150%'});
  //
  var newwidth=500;
  if (width!=undefined && width>0)
    newwidth=width;
  var docwidth=$(document.body).getStyle('width');
  if (docwidth.substr(docwidth.length-1,1)=="%")//happens with ie7
    docwidth="600";
  else
    docwidth=docwidth.substr(0,docwidth.length-2);//remove px
  docwidth=parseInt(docwidth);
  var newleft=100;
  if (left!=undefined && left>0)
    newleft=left;
  else
    newleft=docwidth/2-newwidth/2;
  //
  var newheight=300;
  if (height!=undefined && height>0)
    newheight=height;
  var docheight=$(document.body).getStyle('height');
  if (docheight.substr(docheight.length-1,1)=="%")//happens with ie7
    docheight="400";
  else
    docheight=docheight.substr(0,docheight.length-2);//remove px
  docheight=parseInt(docheight);
  var newtop=100;
  if (top!=undefined && top>0)
    newtop=top;
  else
    newtop=docheight/2-newheight/2;
  //
  $('adlprompt_messagecontainer').setStyles({'width':newwidth,'left':newleft,'height':newheight,'top':newtop});
  $('adlprompt_message').set({html:htmlmessage});
  if (closemessage==undefined)
    closemessage="OK";
  $('adlprompt_close').set({html:
    "<a href='#' onclick='return(false)' style='text-decoration:none'>"+
    closemessage+"</a>"});
  adlprompt_tw.chain(function() {});
  adlprompt_tw.start('opacity',0,1);
}

//ADL
function adl_simpleprompt_end()
{
  adlprompt_tw.chain(function() {$('adlprompt_modal').setStyles({'width':'1px','height':'1px'});});
  adlprompt_tw.start('opacity',1,0);
}

//ADL
window.addEvent('domready', 
  function()
  {
    var adlprompt_modal=new Element('div',{id:'adlprompt_modal'});
    adlprompt_modal.inject($(document.body));
    adlprompt_modal.setStyles({position:'absolute',top:'0',left:'0',
      width:'1px',height:'1px',visibility:'hidden','z-index':'1000',
      opacity:'0'});
    //
    adlprompt_tw.initialize(adlprompt_modal);
    //
    var adlprompt_back=new Element('div',{id:'adlprompt_back'});
    adlprompt_back.inject(adlprompt_modal);
    adlprompt_back.setStyles({
      position:'absolute',top:'0px',left:'0px',
      width:'100%',height:'100%',
      'z-index':'1',opacity:'0.5'});
    adlprompt_back.setProperty('class', 'adlprompt_backclass');
    //
    var adlprompt_messagecontainer=new Element('div',{id:'adlprompt_messagecontainer'});
    adlprompt_messagecontainer.inject(adlprompt_modal);
    adlprompt_messagecontainer.setStyles({
      position:'absolute',top:'0px',left:'0px',width:'1px',height:'1px',
      'z-index':'2'});
    //
    var adlprompt_message=new Element('div',{id:'adlprompt_message'});
    adlprompt_message.inject(adlprompt_messagecontainer);
    adlprompt_message.setStyles({
      position:'absolute',top:'0px',left:'0px',
      width:'100%',height:'100%',
      'z-index':'1','padding':'10px','text-align':'center'});
    adlprompt_message.setProperty('class', 'adlprompt_messageclass');
    //
    var adlprompt_close=new Element('div',{id:'adlprompt_close'});
    adlprompt_close.inject(adlprompt_messagecontainer);
    adlprompt_close.setStyles({
      position:'absolute',right:'0px',bottom:'0px',
      width:'100px',height:'18px',
      'z-index':'2','padding':'2px','text-align':'center'});
    adlprompt_close.setProperty('class', 'adlprompt_closeclass');
    adlprompt_close.addEvent('click',adl_simpleprompt_end);
  });

