﻿// -----------------------------------------------------------------------------------
// fis_alert()
// by fisker
// modify by lgamoy
//
var fis_o, fis_t;
function fis_alert(type, str) {
    if (type != 1 && type != 2 && type != 3 && type != "1" && type != "2" && type != "3") {
        type = 1;
    }
    if (fis_o) {
        clearInterval(fis_o);
    }
    if ($("fis_alert_1") != null) { removeAlertDiv("fis_alert_1") }
    if ($("fis_alert_2") != null) { removeAlertDiv("fis_alert_2") }
    if ($("fis_alert_3") != null) { removeAlertDiv("fis_alert_3") }

    addAlertDiv("fis_alert_" + type);
    $("fis_content_fis_alert_" + type).innerHTML = str;

    //提示框直接出现，渐变隐去
    if (fis_t) {
        window.clearTimeout(fis_t);
    }
    var hidetime = 1000 * str.length / 10;
    fis_t = window.setTimeout('hideAlertDiv(\'fis_alert_' + type + '\')', hidetime);
}
function addAlertDiv(divId) {
    var objDiv = document.createElement("div");
    objDiv.id = divId;
    with (objDiv.style) {
        position = "absolute";
        left = document.body.scrollLeft + document.documentElement.scrollLeft + screen.width / 2 - 280 + "px";
        top = document.body.scrollTop + document.documentElement.scrollTop + 250 + "px";
        opacity = "1";
        filter = "Alpha(Opacity=100)";
        zIndex = "100";
        background = "#E0F5FF";
        border = "#6CA8CC 3px solid";
        width = "370px";
        color = "#11639B";
        textAlign = "left";
        lineHeight = "25px";
        overflow = "hidden";
        fontWeight = "bold";
        padding = "5px";
        fontSize = "14px";
    }
    document.body.appendChild(objDiv);
    document.getElementById(divId).innerHTML = "<div style=\"background:url(../images/toolbar_bg.png) repeat-x;height:28px; color:#006699; width:370px; font-size:14px; \">&nbsp;提示<img style=\"float:right; margin-top:5px; cursor:pointer; margin-right:3px;\" src=\"../images/close.gif\" width=\"15\" height=\"15\" alt=\"关闭\" onclick=\"closeAlertDiv();\" /></div><div id=\"fis_content_" + divId + "\" style=\"padding:20px 10px 20px 60px; font-size:14px; background:#FFF ;\"></div>";
}

function hideAlertDiv(divId) {
    var i = 100;
    fis_o = window.setInterval(
	(function() {
	    var objDiv = $(divId);
	    if (!objDiv) return;
	    if (document.all) {
	        objDiv.style.filter = "Alpha(Opacity=" + i + ")"; //for IE	
	    } else {
	        objDiv.style.opacity = i / 100; //for FF
	    }
	    i = i - 9;
	    if (i < 20) { removeAlertDiv(divId); clearInterval(fis_o); }
	})
	, i);
}
function removeAlertDiv(divId) {
    var objDiv = $(divId);
    if (objDiv) {
        document.body.removeChild(objDiv);
    }
}

function closeAlertDiv() {
    if ($("fis_alert_1") != null) { removeAlertDiv("fis_alert_1") }
    if ($("fis_alert_2") != null) { removeAlertDiv("fis_alert_2") }
    if ($("fis_alert_3") != null) { removeAlertDiv("fis_alert_3") }
}