﻿// JScript File

var msgbox;
var progressCounting = 10;
var filter;
var divInner;
var divTitle;
var divMsg;
            


function revealEffect_show(objid, transition)
{

var obj = document.getElementById(objid);

if (obj!=null)
    {
    if (obj.style.visibility=='visible') {revealEffect_hide(obj, transition)};

    var origfilter = obj.style.filter;

    obj.style.filter='revealTrans(duration=1, transition=' + transition + ')';
    obj.filters.revealTrans.apply();
    obj.style.visibility='visible';
    obj.filters.revealTrans.play();
    obj.style.filter = origfilter;
    obj.style.zIndex = 0;
    };
}

function revealEffect_hide(objid, transition)
{
var obj = document.getElementById(objid);

if (obj!=null)
    {
    var origfilter = obj.style.filter;
    obj.style.filter="revealTrans(duration=2, transition="  + transition + ")";
    obj.filters.revealTrans.apply();
    obj.style.visibility="hidden";
    obj.filters.revealTrans.play();
    obj.style.filter = origfilter;
    }
}

function findAboluteLeft(obj) 
{
    if (obj!=null){    
        if (obj.TagName!='BODY')
            {
            return obj.offsetLeft + findAboluteLeft(obj.offsetParent);
            }
        else 
        {return 0;}
        
    } else {return 0;}
}

function findAboluteTop(obj) 
{
    if (obj!=null){    
        if (obj.TagName!='BODY')
            {
            return obj.offsetTop + findAboluteTop(obj.offsetParent);
            }
        else 
        {return 0;}
        
    } else {return 0;}
}



function ShowHint(taskid, hintid, frameid, titleid, link, width)
{
    var pnl_hint = document.getElementById(hintid);
    var pnl_task = document.getElementById(taskid);
    var fme_hint = document.getElementById(frameid);
    var span_title = document.getElementById(titleid);
        
    
    if ((pnl_hint!=null)&&(pnl_task!=null))
        {
        fme_hint.src = '';
                
        var x = 0;
        var y = 0;
        
        
        x = findAboluteLeft(pnl_task);
        y = findAboluteTop(pnl_task);
                                
        pnl_hint.style.zIndex = 1;            
        
        fme_hint.src = link;
                 
         var windowwidth = 0, windowheight = 0;
          if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            windowwidth = window.innerWidth;
            windowheight = window.innerHeight;
          } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            windowwidth = document.documentElement.clientWidth;
            windowheight = document.documentElement.clientHeight;
          } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            windowwidth = document.body.clientWidth;
            windowheight = document.body.clientHeight;
          }
     
        
        if (x + width > windowwidth - 16){
            pnl_hint.style.posLeft = x - width;
            }
        else {
            pnl_hint.style.posLeft = x + 100;
        }
        
        
          
        if (y + 200 > windowheight){
            pnl_hint.style.posTop = y - 200;
            }
        else {
            pnl_hint.style.posTop = y;
        }
        
               
                        
        revealEffect_show(pnl_hint.id, 4);
        
        
        };                
}

function displayblock(width)
{
    
    setfilter();
        
    var windowwidth = 0, windowheight = 0;
          if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            windowwidth = window.innerWidth;
            windowheight = window.innerHeight;
          } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            windowwidth = document.documentElement.clientWidth;
            windowheight = document.documentElement.clientHeight;
          } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            windowwidth = document.body.clientWidth;
            windowheight = document.body.clientHeight;
          }
          
         
     if (msgbox != null) {
     
        
            msgbox.style.visibility = 'visible';        
            msgbox.style.posLeft = (windowwidth - width) / 2;
            msgbox.style.posTop = (windowheight - 100) / 2;
            

     }

}
function setfilter() {

        var d = document.getElementById("pnl_main");
        
        var l = d.offsetLeft;
        var t = d.offsetTop;        
        var w = d.offsetWidth + document.body.scrollLeft;
        var h = document.body.offsetHeight + document.body.scrollTop;
        
        var ww = window.screen.width;
        var wh = window.screen.height;
        
        if (ww > w) {w =ww;}
        if (wh > h) {h =wh;}
        
        
            if (typeof(w) == 'number') {
                w = w + 'px';
            }
            
            if (typeof(h) == 'number') {
                h = h + 'px';
            }

            if (typeof(l) == 'number') {
                l = l + 'px';
            }
            
            if (typeof(t) == 'number') {
                t = t + 'px';
            }
            
        if (d!=null) {
        
            filter = document.createElement("DIV");

            filter.style.width = w;
            filter.style.height =h;
            
            filter.style.position = "absolute";
            filter.style.left = l;
            filter.style.top = t;
            filter.style.backgroundColor = "#999999";
            filter.style.opacity = .6;
            filter.style.filter = "alpha(opacity=60)";
                    
            d.appendChild(filter);
            
            
        }
}



function progressMsg(msg)
{
    if (divMsg!=null) {
        if (progressCounting>=0)
            {
                divMsg.innerText = divMsg.innerText + '.';
                progressCounting = progressCounting - 1;
            }
        else {
            progressCounting = 10;
            divMsg.innerText = msg;
        }
        setTimeout('progressMsg(\'' + msg + '\');', 1000);
    }
    
}

function pleasewait(msg) {

    displayMsgBox('INFORMATION', msg, '', true);
    
    setTimeout('progressMsg(\'' + msg + '\');', 1000);

}

function closeMsgBox(){
        
    if (msgbox!=null) {
    
        msgbox.style.visibility = 'hidden';
    }
    if (filter!=null) {
        
        filter.style.visibility = 'hidden';
    }
}

function displayMsgBox(title, msg, scriptafter, noOKbutton) {

        if (title=='') title='INFORMATION';
        
        if (msgbox==null) {
            msgbox = document.createElement("DIV");
            msgbox.id = 'messageblock';
            msgbox.className = 'messageblock';
            msgbox.style.position = 'absolute';
            msgbox.style.filter = 'Glow(Color=#999999, Strength=1);';
                    
            divInner = document.createElement("DIV");
            divInner.className = 'messageinner';
        
            divTitle =document.createElement("DIV");
            divTitle.className = 'messagetitle';
        
            divMsg = document.createElement("DIV");
            divMsg.id='messagecontent';
            divMsg.className = 'messagedetails';
            divInner.appendChild(divTitle);
            divInner.appendChild(divMsg);
            divInner.appendChild(document.createElement("BR"));
            divInner.appendChild(document.createElement("BR"));
        
            btnOK = document.createElement("INPUT");
            btnOK.value = "OK"
            btnOK.type = 'button';
            btnOK.id = 'messagebutton';
            btnOK.className = 'Button1';
            btnOK.style.width = '100px';
            divInner.appendChild(btnOK);
            
            
            msgbox.appendChild(divInner);
            document.body.appendChild(msgbox);    
        
        }
        
        msgbox.style.visibility = 'hidden';    
        divTitle.innerText = title;                
        divMsg.innerText = msg;        
       
       
        if (noOKbutton!=null) {
        
            btnOK.style.visibility = 'hidden';
            btnOK.disabled = true;
            setTimeout('displayblock(400);', 0);
        
        
            msgbox.onclick =  null;
            btnOK.onclick = null; 
        }
        else {
            btnOK.style.visibility = 'visible';
            btnOK.disabled = false;
            setTimeout('displayblock(400);btnOK.focus();', 0);
        
        
            msgbox.onclick =  new Function("closeMsgBox();" + scriptafter);
            btnOK.onclick = new Function("closeMsgBox();" + scriptafter);  
            
        }
        

}
