﻿
/*

AS OF 7/21/09 THIS IS HOW IT WORKS - JS
two divs go into the global master

 <div id="dropinboxv2cover">
        <div id="dropinboxv2">
            this is overwritten with an error message            
        </div>
    </div>
    
then a hidden field goes into the global master

<asp:HiddenField ID="hf_ErrorMessage" runat="server" />

finally a javascript snippet is added to the global master at the very bottom of the page to trigger it to be fired
evertime the page is loaded

 <script>CheckErrors();</script>
 
 There are images that are displayed Exclamation64.png
 
 AND one CSS file 3c_ErrorBox.css
 
*/
    
var dropboxleft=0 //set left position of box (in px)
var dropboxtop=0 //set top position of box (in px)
var dropspeed=15 //set speed of drop animation (larger=faster)
var displaymode="always"


if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()* displaymode)
var ie=document.all
var dom=document.getElementById

function initboxv2()
{
    
    //if (!dom&&!ie)return
    crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
    crossbox=(dom)?document.getElementById("dropinboxv2"): document.all.dropinboxv2
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    if (crossbox != null)
    {
        crossbox.height=crossbox.offsetHeight
        crossboxcover.style.height=parseInt(crossbox.height)+"px"
        crossbox.style.top=crossbox.height*(-1)+"px"
        crossboxcover.style.left=dropboxleft+"px"
        crossboxcover.style.top=dropboxtop+"px"
        crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
        dropstart=setInterval("dropinv2()",50)
    }
   
}

function dropinv2()
{
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    if (parseInt(crossbox.style.top)<0)
    {
        crossboxcover.style.top=scroll_top+dropboxtop+"px"
        crossbox.style.top=parseInt(crossbox.style.top)+dropspeed+"px"
     }
    else
    {
        clearInterval(dropstart)
        crossbox.style.top=0
      //  auto_hide_drop_start = setTimeout("dismissboxv2()",10000);
        
        
    }
}

function raiseinv2()
{
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    crossbox=(dom)?document.getElementById("dropinboxv2"): document.all.dropinboxv2
    crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
    if (crossbox != null)
    {
        if (parseInt(crossbox.style.top) > -250)
        {
            crossboxcover.style.top=scroll_top - dropboxtop+"px"
            crossbox.style.top=parseInt(crossbox.style.top)- dropspeed+"px"
         }
        else
        {
            clearInterval(raisestart)
            crossbox.style.top=0
            crossboxcover.style.visibility="hidden";
            document.getElementById("dropinboxv2").innerHTML = "";
            
        }
    }
}

function dismissboxv2()
{
    if (document.getElementById("ctl00_hf_ErrorMessage") != null)
    {
        document.getElementById("ctl00_hf_ErrorMessage").value ="";
    }
    if (document.getElementById("ctl00_hf_InformationMessage") != null)
    {
        document.getElementById("ctl00_hf_InformationMessage").value ="";
    }
    if (window.dropstart)
    {
        clearInterval(dropstart);
    }
    if (window.auto_hide_drop_start) 
    {
        clearTimeout(auto_hide_drop_start);
    }
    raisestart=setInterval("raiseinv2()",50);
    //alert("raise started");
    
}

function truebody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) 
{
    var search = Name + "="
    var returnvalue = ""
    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1) 
        {
            offset += search.length
            end = document.cookie.indexOf(";", offset)
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

function CheckErrors(pDisplayNow) 
{
    lhf_ErrorMessage = document.getElementById("ctl00_hf_ErrorMessage");
    if (lhf_ErrorMessage != null )
    {
        if (lhf_ErrorMessage.value != "")
        {
                lDisplayPane = document.getElementById("dropinboxv2");
                if (lDisplayPane != null )
                {
                    lDisplayPane.innerHTML = "<div style=\"text-align:right; width:100%;\"><a href=\"javascript:dismissboxv2();\"><img src=\"../images/close.gif\" /></a>;</div>";
                    lDisplayPane.innerHTML +="<div style=\"text-align:center; width:100%; margin-top:-20px;\"><table align=\"center\"><tr><td><img src=\"../images/Exclamation64.png\" />&nbsp;</td><td style=\"vertical-align:top;\"><br/>"+ lhf_ErrorMessage.value+"</td></tr></table></div>";
                    
                    if (pDisplayNow)
                    {
                       initboxv2();
                    }
                    else
                    {
                        if (window.addEventListener)window.addEventListener("load", initboxv2, false)
                        else if (window.attachEvent)window.attachEvent("onload", initboxv2)
                        else if (document.getElementById || document.all) window.onload=initboxv2
                    }
                }
        }
    }
    else 
    {
        alert("ctl00_hf_ErrorMessage not found");
    }
    
}

function CheckInformation(pDisplayNow) 
{
    lhf_InformationMessage = document.getElementById("ctl00_hf_InformationMessage");
    if (lhf_InformationMessage != null )
    {
        if (lhf_InformationMessage.value != "")
        {
                lDisplayPane = document.getElementById("dropinboxv2");
                if (lDisplayPane != null )
                {
                    lDisplayPane.innerHTML = "<div style=\"text-align:right; width:100%;\"><a href=\"javascript:dismissboxv2();\"><img src=\"../images/close.gif\" /></a>;</div>";
                    lDisplayPane.innerHTML +="<div style=\"text-align:center; width:100%; margin-top:-20px;\"><table align=\"center\"><tr><td><img src=\"../images/Information64.png\" />&nbsp;</td><td style=\"vertical-align:top;\"><br/>"+ lhf_InformationMessage.value+"</td></tr></table></div>";
                    
                    if (pDisplayNow)
                    {
                       initboxv2();
                    }
                    else
                    {
                        if (window.addEventListener)window.addEventListener("load", initboxv2, false)
                        else if (window.attachEvent)window.attachEvent("onload", initboxv2)
                        else if (document.getElementById || document.all) window.onload=initboxv2
                    }
                }
        }
    }
    else 
    {
        alert("ctl00_hf_InformationMessage not found");
    }
    
}


