﻿function showDivDialog(title,content,showClose,width,height,backColor,titleBackColor,contentBackColor)
{
    if(title==null) title="&nbsp;";
    if(content==null) content="&nbsp;";
    if(width==null) width=400;
    if(height==null) height=250;
    if(backColor==null) backColor="#000000";
    if(titleBackColor==null) titleBackColor="#6B8BBD";
    if(contentBackColor==null) contentBackColor="#ECE9D8";

    var backDiv=document.getElementById("backDiv");
    var alertDiv=document.getElementById("alertDiv");
    if(backDiv && alertDiv)
    {
        backDiv.style.display="";
        alertDiv.style.display="";
    }
    else
    {
        backDiv=getElem("backDiv","div",document.body);
        alertDiv=getElem("alertDiv","div",document.body);
    }

    backDiv.style.opacity=.1; //firefox
    backDiv.style.backgroundColor=backColor;
    backDiv.style.zIndex=999999;
    backDiv.style.position="absolute";
    backDiv.style.left="0px";
    backDiv.style.top="0px";
    backDiv.style.width=document.body.clientWidth;
    backDiv.style.height=document.body.scrollHeight;
    if(getInt(backDiv.style.height) < 768) backDiv.style.height = "768px";
    backDiv.style.textAlign="center";

    alertDiv.style.backgroundColor=contentBackColor;
    alertDiv.style.zIndex=1000000;
    alertDiv.style.position="absolute";
    alertDiv.style.width=width;
    alertDiv.style.height=height;
    alertDiv.style.left=((getInt(backDiv.style.width)-getInt(alertDiv.style.width))/2) + "px";
    alertDiv.style.top =((screen.availHeight - getInt(alertDiv.style.height))/2 + document.body.scrollTop - 100) + "px";
    alertDiv.style.padding="1px";
    alertDiv.style.borderLeft="1px solid #ffffff";
    alertDiv.style.borderTop="1px solid #ffffff";
    alertDiv.style.borderRight="2px solid #888888";
    alertDiv.style.borderBottom="2px solid #888888";

    var titleDiv=getElem("titleDiv","div",alertDiv);
    titleDiv.style.backgroundColor=titleBackColor;
    //titleDiv.style.width="100%";
    titleDiv.style.height="18px";
    titleDiv.style.padding="5px";
    titleDiv.innerHTML = "<div style=\"float:left;font-size:12px;font-weight:bold;color:#ffffff;\">" + title + (showClose ? "</div><div style=\"float:right;width:16px;text-align:center;border:1px solid #999999;background-color:#ffffff;cursor:hand;\" onclick=\"closeDivDialog()\">×</div>" : "");
    titleDiv.onmousedown=function(evt){
            curMoveObj=alertDiv;
            pX=evt.pageX-getInt(curMoveObj.style.left);
            pY=evt.pageY-getInt(curMoveObj.style.top);
        }

    var contentDiv=getElem("contentDiv","div",alertDiv);
    contentDiv.style.padding="20px";
    contentDiv.style.lineHeight="150%";
    contentDiv.style.textAlign="center";
    contentDiv.innerHTML=content;
}

function closeDivDialog()
{
    var backDiv = document.getElementById("backDiv");
    var alertDiv = document.getElementById("alertDiv");
    backDiv.style.display="none";
    alertDiv.style.display="none";
}