﻿//****************************************
//王诗波  收集整理
//2010-10-28
//****************************************

//****************************************
//加入收藏夹
//****************************************
function addCookie() { // 加入收藏夹
    if (document.all) {
        window.external.addFavorite('http://www.cheeda.com.cn/', '四川琪达实业集团有限公司');
    } else if (window.sidebar) {
    window.sidebar.addPanel('四川琪达实业集团有限公司', 'http://www.cheeda.com.cn/', "");
    }
}

//****************************************
//设置首页
//****************************************
function setHomepage() { // 设置首页
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.cheeda.com.cn/');
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config ,然后将项为signed.applets.codebase_principal_support的值改为true");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.cheeda.com.cn/');
    }
}
//****************************************
//显示或隐藏
//****************************************
function showHide(id) {
    var obj = document.getElementById(id);
    if (obj.style.display == "none")
        obj.style.display = "block";
    else
        obj.style.display = "none";
}
//****************************************
//显示箭头
//****************************************
function showArrow(objId) {
    document.getElementById(objId).style.display = "block";
}
//****************************************
//隐藏箭头
//****************************************
function hideArrow(objId) {
    document.getElementById(objId).style.display = "none";
}
//****************************************
//加载进度
//****************************************
function OpenProgress(divWidth, divHeight) {
    divWidth = document.body.scrollWidth;
    
    divHeight = document.body.scrollHeight;
    var divHeight1 = document.documentElement.clientHeight;
    if (divHeight < divHeight1)
        divHeight = divHeight1;
   
    var wordTop = divHeight / 2 - 20;    
    document.write("<div style=\"top:0px;left:0px;width:" + divWidth + "px;height:" + divHeight + "px;text-align:center;position:absolute;z-index:1000;background-color:#FFF;filter:alpha(opacity=50);\">");
    document.write("<div style=\"width:100%;margin-top:" + wordTop + "px;z-index:9999;text-align:center;\">");
    document.write("<img src=\"../images/loading.gif\" border=0 /><font color=red>正在加载数据，请稍等...</font>");
    document.write("</div>");
    document.write("</div>");
}
/*
function OpenProgress(divWidth, divHeight) {
    var wordTop = divHeight / 2 - 20;
    document.write("<div style=\"width:" + divWidth + "px;height:" + divHeight + "px;text-align:center;position:absolute;z-index:1000;background-color:#FFF;filter:alpha(opacity=50);\">");
    document.write("<div style=\"width:100%;margin-top:" + wordTop + "px;z-index:9999;text-align:center;\">");
    document.write("<img src=\"../images/loading.gif\" border=0 /><font color=red>正在加载数据，请稍等...</font>");
    document.write("</div>");
    document.write("</div>");
}
*/
//************************************************************
//打开Div层对话框
//************************************************************
var docEle = function() {
    return document.getElementById(arguments[0]) || false;
}
function openNewDiv(iWidth, iHeight, iFrameSrc, objTitle) {
    //创建页面元素
    createPageElement(objTitle);

    var _id = newDiv;
    var m = "mask";

    if (docEle(_id)) document.removeChild(docEle(_id));
    if (docEle(m)) document.removeChild(docEle(m));

    var objContentDiv = document.getElementById("div_Content");
    var objFrame = document.getElementById("iframe_Edit");
    objFrame.src = iFrameSrc;
    objFrame.width = "100%";
    objFrame.height = iHeight - 40;

    var objNewDivTitleWidth = iWidth - 50;

    //新激活图层标题内容
    var objNewDivTitle = "<div style=\"width:" + objNewDivTitleWidth + "px;float:left;text-align:left;font-weight:bold;\">";
    objNewDivTitle = objNewDivTitle + "<img src=\"../images/ICO.gif\" border=0 align=\"middle\" style=\"padding:0 5px 0 5px;\"  />";
    objNewDivTitle = objNewDivTitle + objTitle;
    objNewDivTitle = objNewDivTitle + "</div>";

    // 关闭mask和新图层
    var objTitleDiv = document.createElement("div");

    objTitleDiv.innerHTML = objNewDivTitle +
                            "<div style=\"width:40px;float:right;text-align:right;cursor:pointer;\"><span style=\"font-family:Wingdings\">x</span>关闭</div>" +
                            objContentDiv.innerHTML;
    objTitleDiv.onclick = function() {
        document.body.removeChild(docEle(_id));
        document.body.removeChild(docEle(m));
        return false;
    }

    // 新激活图层
    var newDiv = document.createElement("div");
    newDiv.id = _id;
    newDiv.style.position = "absolute";
    newDiv.style.zIndex = "9999";
    newDiv.style.width = iWidth + "px";
    newDiv.style.height = iHeight + "px";
    newDiv.style.top = "50px";
    newDiv.style.left = (parseInt(document.body.scrollWidth) - iWidth) / 2 + "px"; // 屏幕居中
    newDiv.style.background = "#EEEEEE";
    newDiv.style.border = "1px solid #0066cc";
    newDiv.style.padding = "5px";
    newDiv.appendChild(objTitleDiv);

    document.body.appendChild(newDiv);

    // mask图层
    var newMask = document.createElement("div");
    newMask.id = m;
    newMask.style.position = "absolute";
    newMask.style.zIndex = "1";
    var inewMaskHieght = document.body.offsetHeight;
    var inewMaskHieght1 = document.documentElement.clientHeight;
    if (inewMaskHieght < inewMaskHieght1)
        inewMaskHieght = inewMaskHieght1;
    newMask.style.width = document.documentElement.clientWidth; //document.body.scrollWidth + "px";
    newMask.style.height = inewMaskHieght; // document.body.scrollHeight + "px";
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#000";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";
    document.body.appendChild(newMask);
}

function closeOpenDiv(_id, m) {
    alert(_id);
    alert(m);
    document.body.removeChild(docEle(_id));
    document.body.removeChild(docEle(m));
    return false;
}
//************************************************************
//创建页面元素
//************************************************************
function createPageElement() {
    var objPageDiv1 = document.createElement("div");
    objPageDiv1.id = "newDiv";

    var objPageFrame = document.createElement("iframe");
    objPageFrame.id = "iframe_Edit";
    objPageFrame.style.border = "none";
    objPageFrame.style.margin = "0";
    objPageFrame.setAttribute("frameborder", "0");
    objPageFrame.setAttribute("scrolling", "auto");

    var objPageDiv2 = document.createElement("div");
    objPageDiv2.id = "div_Content";
    objPageDiv2.style.display = "none"

    objPageDiv2.appendChild(objPageFrame);
    document.body.appendChild(objPageDiv1);
    document.body.appendChild(objPageDiv2);
}
//************************************************************
//打开Div层对话框
//宽：400px
//高：120px
//************************************************************
function openSmallDiv(iFrameSrc, objTitle) {
    openNewDiv('400', '120', iFrameSrc, objTitle);
}
//************************************************************
//打开Div层对话框
//宽：600px
//高：300px
//************************************************************
function openMediumDiv(iFrameSrc, objTitle) {
    openNewDiv('600', '350', iFrameSrc, objTitle);
}
//************************************************************
//打开Div层对话框
//宽：800px
//高：500px
//************************************************************
function openLargeDiv(iFrameSrc, objTitle) {
    openNewDiv('800', '600', iFrameSrc, objTitle);
} 
//************************************************************
//打开Div层对话框
//宽：400px
//高：120px
//************************************************************
function openSmallDivByVertical(iFrameSrc, objTitle) {
    openNewDiv('120', '400', iFrameSrc, objTitle);
}
//************************************************************
//打开Div层对话框
//宽：600px
//高：300px
//************************************************************
function openMediumDivByVertical(iFrameSrc, objTitle) {
    openNewDiv('300', '600', iFrameSrc, objTitle);
}
//************************************************************
//打开Div层对话框
//宽：800px
//高：500px
//************************************************************
function openLargeDivByVertical(iFrameSrc, objTitle) {
    openNewDiv('500', '700', iFrameSrc, objTitle);
}
