﻿var oBaseMsgStr;
var objTitlePopup;
var lenMsgBoxShow;
var timerMsgBoxShowID;
var timerMsgBoxShowHide;

function titleMouseOver() { 
    if (oBaseMsgStr.length != 0) {
        InitMsgBox()
    }
}

function InitMsgBox() { 
    var sreloadStr = document.forms[0].__reloadActType.value;
//    if (oBaseMsgStr.length != 0 && sreloadStr.length == 0) {
    if (oBaseMsgStr.length != 0) {
//        var cMsgObj = document.getElementById("MyHead1_LabMsg");
//        cMsgObj.innerHTML=oBaseMsgStr;
//        cMsgObj.innerText=oBaseMsgStr;

        InitMsgBoxShow(oBaseMsgStr);
    }
    document.forms[0].__reloadActType.value = '';
}

function InitMsgBoxClean() { 
    if (oBaseMsgStr.length != 0) {
//        var cMsgObj = document.getElementById("MyHead1_LabMsg");
//        cMsgObj.innerHTML="";
    }
}

function InitMsgBoxShow(s)
{
    if (s.length != 0)
    {
        lenMsgBoxShow = 0;
        window.clearInterval(timerMsgBoxShowHide);
        objTitlePopup=window.createPopup();
        var titlePopupBody = objTitlePopup.document.body;
        titlePopupBody.style.border ="solid black 1px";
        var titleContent = "";
        titleContent = titleContent + "<table style='background-color:#dcebfa;' onmouseover='parent.CHidetime();' onmouseout='parent.FHidetime();' width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'>";
        titleContent = titleContent + "<tr><td style='height:10%; border-bottom: Black thin solid;' align=center><font size = 2>訊  息</font>&nbsp;&nbsp;</td></tr>";
        titleContent = titleContent + "<tr><td style='height:90%;'><div style='font-size:10pt'>" + s + "</div></td></tr>";
        titleContent = titleContent + "</table>";    
        titlePopupBody.innerHTML = titleContent;
        ShowMsgBox();
    }
}

function MsgBox() { 
    var iTopInt;
    var iLeftInt;
	var sCintT = new Array(1);
//    sCintT = document.forms[0].__SCROLLPOS.value.split("#");
//    iTopInt = (document.body.clientHeight/2) + parseInt(sCintT[1]);
//    iLeftInt = document.body.clientWidth/2 - 100;
    iTopInt = document.documentElement.scrollTop;
    
    if(iTopInt > 400 ) {
        iTopInt = iTopInt - 150;
    }
    else {
        iTopInt = 390;
    }

    if (iTopInt > document.documentElement.clientHeight)
    {
        iTopInt = document.documentElement.clientHeight / 2;        
    }
    else
    {
        iTopInt = document.documentElement.clientHeight - iTopInt;
    }

    iLeftInt = document.documentElement.clientWidth - 200;

    lenMsgBoxShow += 5;
    if (lenMsgBoxShow > 70)
    {
        window.clearInterval(timerMsgBoxShowID);
    }
    else
    {
//        objTitlePopup.show(document.body.clientWidth - 170, 0 , 170, lenMsgBoxShow, top.document.body); 
//        objTitlePopup.show(Left (X) , Top (Y) , Width , Height , top.document.body); 
        objTitlePopup.show(iLeftInt , iTopInt , 200, lenMsgBoxShow, document.documentElement); 
    }
}


//function flashpic() {
//	var Width = 95;	var Left = 5;var Top = 5;
//	var Height =50;	if (document.all){
//		var wm = document.jsbrand;
//	    theResult.style.pixelLeft = (document.body.scrollLeft + document.body.clientWidth) - (Width + Left);
//		theResult.style.pixelTop = (document.body.scrollTop + document.body.clientHeight) - (Height + Top +15);
//		jsbrand.style.pixelLeft = (document.body.scrollLeft + document.body.clientWidth) - (Width + Left);
//		jsbrand.style.pixelTop = (document.body.scrollTop + document.body.clientHeight) - (Height + Top);
//		setTimeout("flashpic()",500);
//	}else{
//	   theResult.style.position='fixed';
//	   theResult.style.top='495';
//	   theResult.style.right='5';
//	   jsbrand.style.position='fixed';
//	   jsbrand.style.top='510';
//	   jsbrand.style.right='5';
//	   setTimeout("flashpic()",500);
//	}
//	if (document.getElementById('check').value == "1") {
//        document.getElementById('theResult').style.visibility = 'hidden';
//        var screenWidth = document.body.scrollWidth;  //取得整個螢幕的寬度 
//        var screenHeight = document.body.scrollHeight;  //取得整個螢幕的高度 
//        //document.getElementById('screen').style.width = screenWidth; 
//       // document.getElementById('screen').style.height = screenHeight;
//        //document.getElementById('screen').style.visibility = 'hidden';
//        document.getElementById('check').value = '0';
//    }
//}

function ShowMsgBox() {
    timerMsgBoxShowID = window.setInterval("MsgBox()",15); 
    FHidetime()
}

function PopupHide() {
    objTitlePopup.hide();
    CHidetime()
}

//暫停計數
function CHidetime() {
    window.clearInterval(timerMsgBoxShowHide);
}

function FHidetime() {
    timerMsgBoxShowHide = window.setInterval('PopupHide()', 2000);
}
