/* It needs in HTML code this structure (perl CGI.pm code format)
 * 

  div({-id=>'dialog'},
    div({-id=>'windowBox',-class=>'windowBoxNormal'},
       img({-id=>'closeImg',-src=>'images/close_inactive.gif',-alt=>'x', -onclick=>'cancelAll();'},''),
       "<center>",
       p({-id=>'msgTitle'},'title'),
       img({-id=>'dialogImg',-src=>'images/wait.gif',-alt=>'please wait..'},''),
       "</center>",
       div({-class=>'clear'},'&nbsp;'),
       div({-id=>'msgDescription'},''),
       "<center>",
       input({-id=>"dialogCancel",-type=>"button",-class=>"cancelButton",-onclick=>"cancelAll();",-value=>'OK'}),
       "</center>"
    );
*/


function dialogBox(display,type,msgLangId, optionalTitle, optionalData){
    var dlgWindow =  document.getElementById('dialog');

    if(!display && dlgWindow)
    {
        dlgWindow.style.display = 'none';
        return;
    }

    if(type=='upload')
    {
        var space = document.getElementById('progressSpace');
        document.getElementById('windowBox').className = 'windowBoxNormal';
        document.getElementById('msgDescription').appendChild(space);
//        document.getElementById('msgTitle').
//        document.getElementById('msgTitle').innerHTML = optionalTitle;

    }

    if(type=='wait')
    {
        document.getElementById('windowBox').className = 'windowBoxNormal';
        document.getElementById('msgDescription').innerHTML = ''
        document.getElementById('dialogImg').src = DIR+'/images/wait.gif';
        document.getElementById('dialogImg').alt = 'please wait..';
        document.getElementById('dialogCancel').value = LANG['cancel'];
        document.getElementById('msgTitle').innerHTML = LANG[msgLangId];
    }

    if(type=='error')
    {
        document.getElementById('windowBox').className = 'windowBoxNormal';
        document.getElementById('msgDescription').innerHTML = '';
        document.getElementById('dialogImg').src = DIR+'/images/error.gif';
        document.getElementById('dialogImg').alt = 'error ocurred!';
        document.getElementById('dialogCancel').value = LANG['close'];
        document.getElementById('msgTitle').innerHTML = LANG[msgLangId];
        if(optionalData != '') document.getElementById('msgDescription').innerHTML = "<p>"+optionalData+"</p>";
    }

    if(type=='info')
    {
        document.getElementById('windowBox').className = 'windowBoxWide';
        document.getElementById('dialogImg').src = DIR+'/images/info.gif';
        document.getElementById('dialogImg').alt = 'info';
        document.getElementById('dialogCancel').value = LANG['ok'];
        document.getElementById('dialogCancel').style.display = "block";

        if(msgLangId != '')
            document.getElementById('msgTitle').innerHTML = LANG[msgLangId];
        else
            if(optionalTitle != '')
                document.getElementById('msgTitle').innerHTML = optionalTitle;
        else
            document.getElementById('msgTitle').innerHTML = '';

        document.getElementById('msgDescription').innerHTML = optionalData;
    }


    dlgWindow.style.display = 'block';
}


