﻿//要引用prototype.js框架
//对话框
var DialogBox = {
    _self: this,
    iWidth: null,
    iHeight: null,
    msgBoxWidth: 700,
    msgBoxHeight: 500,
    bgObj: null,
    MsgBox: null,
    content: null,
    title: "对话框",
    contentInfo: "请选择要删除的邮件",
    className: null,
    topMargin: null,
    leftMargin: null,
    isDisableSelect: true,
    displayObjList: null,
    showObject: null,
    topTitle: null, //上面的显示标题
    zIndex: 98,
    init: function(_title, _contentInfo)
    {
        this.title = _title;
        this.contentInfo = _contentInfo;
    },

    //创建覆盖层
    createOverlay: function()
    {
        if (this.iWidth == null)
        {
            this.iWidth = Math.max(document.body.scrollWidth, document.documentElement.offsetWidth);
        }
        if (this.iHeight == null)
        {
            this.iHeight = Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight);
        }
        this.bgObj = document.createElement("div");
        var bgObjId = 'overlayBoxBgObj';
        this.bgObj.setAttribute('id', bgObjId); //Common.getAutomaticNum
        with (this.bgObj.style)
        {
            position = "absolute";
            top = "0px";
            background = "#777";
            filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=20)";
            opacity = "0.2";
            left = "0px";
            margin = "0px";
            width = this.iWidth + "px";
            height = this.iHeight + "px";
            zIndex = this.zIndex;
        }
        if (!$(bgObjId)) document.body.appendChild(this.bgObj);
        //隐藏Select
        if (this.isDisableSelect)
        {
            this.disableSelect();
        }
    },

    createMsgBox: function(isMove, isShowDelete)
    {
        var msgBoxLeft = Math.max(parseInt((document.body.clientWidth - this.msgBoxWidth) / 2), 0);
        var msgBoxTop = Math.max(parseInt((document.documentElement.clientHeight - this.msgBoxHeight) / 2), 0) + document.documentElement.scrollTop;
        if (this.topMargin != null)
        {
            msgBoxTop = this.topMargin;
        }

        if ($("DialogBoxMsgBox") != null) { Element.remove("DialogBoxMsgBox"); }
        this.MsgBox = document.createElement("div");
        this.MsgBox.setAttribute("id", "DialogBoxMsgBox");
        this.MsgBox.className = "DialogBox";
        with (this.MsgBox.style)
        {
            position = "absolute";
            width = this.msgBoxWidth + "px";
            height = this.msgBoxHeight + "px";
            left = msgBoxLeft + "px";
            top = msgBoxTop + "px";
            zIndex = this.zIndex + 1;
        }

        //上面
        this.topTitle = document.createElement("div");
        this.topTitle.className = "top";
        var topLeft = document.createElement("div");
        topLeft.className = "left";
        var topCenter = document.createElement("div");
        topCenter.className = "center";

        topCenter.style.width = (this.msgBoxWidth - 26) + "px";

        var topInfo = document.createElement("div");
        topInfo.className = "info";
        var topInfoText = document.createTextNode(this.title);
        topInfo.appendChild(topInfoText);
        var topClose = document.createElement("div");
        topClose.className = "close";
        if (isShowDelete)
        {
            var topA = document.createElement("a");
            topA.href = "javascript:void(0)";
            topA.onclick = this.close;
            topClose.appendChild(topA);
        }
        topCenter.appendChild(topInfo);
        topCenter.appendChild(topClose);
        var topRight = document.createElement("div");
        topRight.className = "right";
        this.topTitle.appendChild(topLeft);
        this.topTitle.appendChild(topCenter);
        this.topTitle.appendChild(topRight);
        this.MsgBox.appendChild(this.topTitle);

        //中间
        this.content = document.createElement("div");
        this.content.className = "content";
        this.content.setAttribute("id", "MsgBoxContentId");
        if (this.getIEVersion() == "IE7")
        {
            this.content.style.width = (this.msgBoxWidth - 2) + "px";
        }
        else
        {
            this.content.style.width = this.msgBoxWidth + "px";
        }
        this.content.style.height = (this.msgBoxHeight - 29 - 2) + "px";
        this.MsgBox.appendChild(this.content);


        //下面
        var bottom = document.createElement("div");
        bottom.className = "bottom";
        var bottomLeft = document.createElement("div");
        bottomLeft.className = "left";
        var bottomCenter = document.createElement("div");
        bottomCenter.className = "center";
        bottomCenter.style.width = (this.msgBoxWidth - 4) + "px";
        var bottomRight = document.createElement("div");
        bottomRight.className = "right";
        bottom.appendChild(bottomLeft);
        bottom.appendChild(bottomCenter);
        bottom.appendChild(bottomRight);
        this.MsgBox.appendChild(bottom);
        if (isMove)
        {
            this.DragObject(this.topTitle, this.MsgBox);
        }

        document.body.appendChild(this.MsgBox);
    },

    openWindow: function(url, windowName, theWidth, theHeight)
    {
        this.iWidth = Math.max(document.body.scrollWidth, document.documentElement.offsetWidth);
        this.iHeight = Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight);
        this.createOverlay();
        if (typeof (windowName) != "undefined")
        {
            this.title = windowName;
        }
        if (typeof (theWidth) != "undefined" && typeof (theHeight) != "undefined")
        {
            this.msgBoxWidth = parseInt(theWidth);
            this.msgBoxHeight = parseInt(theHeight);
        }
        this.createMsgBox(true, true);

        var iframe = document.createElement("iframe");
        iframe.setAttribute("id", "iframeDialog");
        iframe.setAttribute("name", "iframeDialog");
        iframe.setAttribute("src", url);
        iframe.setAttribute("width", "100%");
        iframe.setAttribute("height", "100%");
        iframe.setAttribute("frameborder", "0", 0);
        iframe.setAttribute("border", 0);

        this.content.appendChild(iframe);

        iframe.focus();
    },

    open: function(oContainer, windowName, theWidth, theHeight)
    {
        if (typeof (oContainer) == "undefined" || document.getElementById(oContainer) == null) { return; }

        this.showObject = document.getElementById(oContainer);

        this.displayObjList = document.getElementById(oContainer).getElementsByTagName("select");


        this.iHeight = Math.max(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight), (Element.getDimensions(oContainer).height + 45));
        this.iWidth = Math.max(Math.max(document.body.scrollWidth, document.documentElement.offsetWidth), (Element.getDimensions(oContainer).width + 30));
        this.createOverlay();
        if (typeof (windowName) != "undefined")
        {
            this.title = windowName;
        }
        if (typeof (theWidth) != "undefined" && typeof (theHeight) != "undefined")
        {
            this.msgBoxWidth = parseInt(theWidth);
            this.msgBoxHeight = parseInt(theHeight);
        }
        else
        {
            this.msgBoxWidth = Element.getDimensions(oContainer).width + 30;
            this.msgBoxHeight = Element.getDimensions(oContainer).height + 45;
        }
        this.createMsgBox(false, true);
        this.topTitle.style.cursor = "default";
        var padding = (this.msgBoxWidth - Element.getDimensions(oContainer).width) / 2;
        var ContainerLeft = Math.max(parseInt((document.body.clientWidth - this.msgBoxWidth) / 2), 0) + padding;
        var ContainerTop = Math.max(parseInt((document.documentElement.clientHeight - this.msgBoxHeight) / 2), 0) + document.documentElement.scrollTop + 35;
        if (this.topMargin != null)
        {
            ContainerTop = this.topMargin + 35;

        }
        with ($(oContainer).style)
        {
            position = "absolute";
            zIndex = this.zIndex + 2;
            display = "";
            left = ContainerLeft + "px";
            top = ContainerTop + "px";
        }

        Element.show(oContainer);
    },

    alert: function(windowName, theWidth, theHeight, xmlContent)
    {
        this.iWidth = Math.max(document.body.scrollWidth, document.documentElement.offsetWidth);
        this.iHeight = Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight);
        this.createOverlay();
        if (typeof (windowName) != "undefined")
        {
            this.title = windowName;
        }
        if (typeof (theWidth) != "undefined" && typeof (theHeight) != "undefined")
        {
            this.msgBoxWidth = parseInt(theWidth);
            this.msgBoxHeight = parseInt(theHeight);
        }
        this.createMsgBox(true, true);

        Element.update(this.content, xmlContent);

        var button = document.createElement("div");
        button.className = "button";
        var input = document.createElement("input");
        input.type = "button";
        input.value = "确定";
        button.appendChild(input);
        this.content.appendChild(button);
        input.onclick = this.close;
    },

    close: function()
    {
        event.cancelBubble = true;
        Element.remove("DialogBoxMsgBox");
        Element.remove("overlayBoxBgObj");
        if (DialogBox.showObject != null)
        {
            Element.hide(DialogBox.showObject);
        }

        //显示Select
        if (DialogBox.isDisableSelect)
        {
            DialogBox.enableSelect();
        }
    },

    //获取IE的版本
    getIEVersion: function()
    {
        if (navigator.userAgent.indexOf("MSIE") > -1)
        {
            if (navigator.appVersion.match(/7./i) == '7.')
            {
                return "IE7";
            }
            if (navigator.appVersion.match(/6./i) == '6.')
            {
                return "IE6";
            }
        }
        else
            return "others";
    },

    //禁用Select控件,displayObjList表示除此之外
    disableSelect: function()
    {
        //禁用所有Select控件
        var selectList = document.getElementsByTagName("select");
        for (var i = 0; i < selectList.length; i++)
        {
            disabledSelectId(selectList[i]);
        }

        //启用容器内的Select控件
        if (this.displayObjList != null && this.displayObjList.length > 0)
        {
            for (var j = 0; j < this.displayObjList.length; j++)
            {
                enabledSelectId(this.displayObjList[j]);
            }
        }

        this.setIframeSelect(false);

        function disabledSelectId(selectId)
        {
            selectId.style.visibility = "hidden";
        }

        function enabledSelectId(selectId)
        {
            selectId.style.visibility = "visible";
        }
    },
    //启用Select控件
    enableSelect: function()
    {
        var selectList = document.getElementsByTagName("select");
        for (var i = 0; i < selectList.length; i++)
        {
            selectList[i].style.visibility = "visible";
        }
        this.setIframeSelect(true);

    },

    //设置子框架的Select是否显示
    setIframeSelect: function(isShow)
    {
        if (window.frames.length > 0)
        {
            for (var i = 0; i < window.frames.length; i++)
            {
                try
                {
                    var childSelectList = window.frames[i].document.getElementsByTagName("select");
                    for (var j = 0; j < childSelectList.length; j++)
                    {
                        if (isShow)
                        {
                            childSelectList[j].style.visibility = "visible";
                        }
                        else
                        {
                            childSelectList[j].style.visibility = "hidden";
                        }
                    }
                }
                catch (oError)
                {
                }
            }
        }
    },

    DragObject: function(dragObj, moveObj)
    {
        var startX;
        var startY;
        var IsMoveAble = false;
        var top;
        var left;
        dragObj.onmousedown = function()
        {
            this.setCapture();
            IsMoveAble = true;
            startX = event.x - moveObj.style.pixelLeft;
            startY = event.y - moveObj.style.pixelTop;
        }
        dragObj.onmousemove = function()
        {
            if (IsMoveAble)
            {
                left = event.x - startX;
                top = event.y - startY;
                moveObj.style.pixelLeft = Math.max(left, -(moveObj.offsetWidth - 20));
                moveObj.style.pixelTop = Math.max(top, 0);
            }
        }
        dragObj.onmouseup = function()
        {
            this.releaseCapture();
            IsMoveAble = false;
        }
    }
}

//IsShowSelect是否显示"请选择"选项
function parentToChildSingleSelect(nodesList, parentSelect, childSelect, hiddenParentValue, hiddenChildValue, IsShowSelect)
{
    var parentSelect = $(parentSelect);
    var childSelect = $(childSelect);
    var hiddenParentValue = $(hiddenParentValue);
    var hiddenChildValue = $(hiddenChildValue);

    //设置初始值
    var parentValue = nodesList[0].Id;
    var childValue = nodesList[0].Children[0].Id;
    if (IsShowSelect)
    {
        parentValue = -1;
        childValue = -1;
    }

    //只设定子节点，根据子节点获取父节点
    if (hiddenChildValue.value != "" && hiddenParentValue.value == "")
    {
        hiddenParentValue.value = findParentByChild(hiddenChildValue.value).Id;
    }
    if (hiddenParentValue.value != "")
    {
        parentValue = hiddenParentValue.value;
    }
    else
    {
        hiddenParentValue.value = parentValue;
    }
    if (hiddenChildValue.value != "")
    {
        childValue = hiddenChildValue.value;
    }
    else
    {
        hiddenChildValue.value = childValue;
    }

    //添加父
    Utils.clearSelectOptionsList(parentSelect);
    if (IsShowSelect)
    {
        Utils.addSelectOption(parentSelect, "-1", "请选择");
    }
    for (var i = 0; i < nodesList.length; i++)
    {
        Utils.addSelectOption(parentSelect, nodesList[i].Id, nodesList[i].Title);
    }
    parentSelect.value = parentValue;

    parentSelect.onchange = function()
    {
        hiddenParentValue.value = parentSelect.value;
        var childNode = findChild(parentSelect.value);
        if (childNode != null)
        {
            var list = findChild(parentSelect.value).Children;
            addChildSelect(list);
            hiddenChildValue.value = list[0].Id;
        }
        else
        {
            Utils.clearSelectOptionsList(childSelect);
        }
        if (IsShowSelect)
        {
            hiddenChildValue.value = -1;
        }
    }

    //添加子
    var childNode = findChild(parentValue);
    if (childNode != null)
    {
        var childList = childNode.Children;
        addChildSelect(childList);
    }
    childSelect.value = childValue;

    function addChildSelect(childenList)
    {
        Utils.clearSelectOptionsList(childSelect);
        if (IsShowSelect)
        {
            Utils.addSelectOption(childSelect, "-1", "请选择");
        }
        for (var i = 0; i < childenList.length; i++)
        {
            Utils.addSelectOption(childSelect, childenList[i].Id, childenList[i].Title);
        }
    }

    childSelect.onchange = function()
    {
        hiddenChildValue.value = childSelect.value;
    }

    //根据父节点查找子节点
    function findChild(Id)
    {
        var Node = null;
        for (var i = 0; i < nodesList.length; i++)
        {
            if (nodesList[i].Id == Id)
            {
                Node = nodesList[i];
                return Node;
            }
        }
        return Node;
    }

    //根据子节点查找父节点
    function findParentByChild(Id)
    {
        var Node = null;
        for (var i = 0; i < nodesList.length; i++)
        {
            for (var j = 0; j < nodesList[i].Children.length; j++)
            {
                if (nodesList[i].Children[j].Id == Id)
                {
                    Node = nodesList[i];
                    return Node;
                }
            }
        }
        return Node;
    }
}
/*===========ButtonContainer===============*/
function showButtonContainer(oThis, showDivId, ButtonContainer)
{
    if ($(ButtonContainer).disabled) return;

    Element.cleanWhitespace(showDivId);
    var elementPosition = Utils.GetEelmentPosition(oThis);
    var e = Utils.getWidthHeight(oThis);
    var div = Utils.getWidthHeight(showDivId);
    $(showDivId).style.position = "absolute";

    var l = elementPosition.left;
    var t = elementPosition.top + e.height;
    if (div.width > elementPosition.right)
    {
        l = Math.min(elementPosition.left, (elementPosition.left - div.width + e.width));
    }
    if (div.height > elementPosition.bottom)
    {
        t = Math.min(elementPosition.top, (elementPosition.top - div.height));
    }

    Element.setStyle(showDivId, { top: t, left: l });
    Element.toggle(showDivId);

    function closeDiv()
    {
        if (event.srcElement != oThis)
        {
            event.cancelBubble = true;
            Element.hide(showDivId);
        }
    };

    Event.observe(document, "click", closeDiv);
}

/*===========Combox===============*/
function ComboBox(oThis, showDivId)
{
    Element.cleanWhitespace(showDivId);
    var elementPosition = Utils.GetEelmentPosition(oThis);
    var e = Utils.getWidthHeight(oThis);
    var div = Utils.getWidthHeight(showDivId);
    $(showDivId).style.position = "absolute";

    var offsetMaxHeight = Math.max(elementPosition.top, elementPosition.bottom);
    if (div.height > offsetMaxHeight)
    {
        $(showDivId).style.height = (offsetMaxHeight - 10) + "px";
    }

    var l = elementPosition.left;
    var t = elementPosition.top + e.height - 1;
    if (div.width > elementPosition.right)
    {
        l = Math.min(elementPosition.left, (elementPosition.left - div.width + e.width));
    }
    if (div.height > elementPosition.bottom)
    {
        t = Math.min(elementPosition.top, (elementPosition.top - div.height));
    }

    Element.setStyle(showDivId, { top: t, left: l });
    Element.toggle(showDivId);

    var children = $(showDivId).childNodes;
    for (var i = 0; i < children.length; i++)
    {
        Event.observe(children[i], "click", click);
        function click()
        {
            oThis.firstChild.value = this.firstChild.innerText;
        }
        Event.observe(children[i], "mouseover", mouseover);
        function mouseover()
        {
            this.style.backgroundColor = "blue";
            this.style.color = "#FFF";
        }
        Event.observe(children[i], "mouseout", mouseout);
        function mouseout()
        {
            this.style.backgroundColor = "#FFF";
            this.style.color = "#000";
        }
        if (oThis.firstChild.value == children[i].firstChild.innerText)
        {
            children[i].style.backgroundColor = "blue";
            children[i].style.color = "#FFF";
        }
        else
        {
            children[i].style.backgroundColor = "#FFF";
            children[i].style.color = "#000";
        }
    }

    function closeDiv()
    {
        if (event.srcElement != oThis && event.srcElement != $(showDivId))
        {
            event.cancelBubble = true;
            Element.hide(showDivId);
            Event.stopObserving(document, "click", closeDiv);
        }
    };

    Event.observe(document, "click", closeDiv);
}

/*===========HeadIco===============*/
function HeadIco(oThis, showDivId, HiddenValueId)
{
    Element.cleanWhitespace(showDivId);
    var elementPosition = Utils.GetEelmentPosition(oThis);
    var e = Utils.getWidthHeight(oThis);
    var div = Utils.getWidthHeight(showDivId);
    $(showDivId).style.position = "absolute";

    var offsetMaxHeight = Math.max(elementPosition.top, elementPosition.bottom);
    if (div.height > offsetMaxHeight)
    {
        $(showDivId).style.height = (offsetMaxHeight - 10) + "px";
    }

    var l = elementPosition.left;
    var t = elementPosition.top + e.height - 1;
    if (div.width > elementPosition.right)
    {
        l = Math.min(elementPosition.left, (elementPosition.left - div.width + e.width));
    }
    if (div.height > elementPosition.bottom)
    {
        t = Math.min(elementPosition.top, (elementPosition.top - div.height)) - 1;
        l = l - 1;
    }

    Element.setStyle(showDivId, { top: t, left: l });
    Element.toggle(showDivId);

    var children = $(showDivId).childNodes;
    for (var i = 0; i < children.length; i++)
    {
        Event.observe(children[i], "click", click);
        function click()
        {
            oThis.firstChild.src = this.src;
            $(HiddenValueId).value = this.src;
        }
        if (children[i].src == oThis.firstChild.src)
        {
            children[i].style.backgroundColor = "#0033CC";
        }
        else
        {
            children[i].style.backgroundColor = "#FFF";
        }
    }

    function closeDiv()
    {
        if (event.srcElement != oThis && event.srcElement != $(showDivId))
        {
            event.cancelBubble = true;
            Element.hide(showDivId);
            Event.stopObserving(document, "click", closeDiv);
        }
    };

    Event.observe(document, "click", closeDiv);
}

/*
=========上传控件======================
*/
function fileUploadAdd(upLoadFile, showFileNameList, validateMode, validateFileType, fileCount, HiddenFieldFileNameList)
{
    var upLoadFile = $(upLoadFile);
    var showFileNameList = $(showFileNameList);
    var FileTypeList = validateFileType.split(","); //文件类型如："jpg,gif" 不区分大小写
    var ValidateMode = validateMode; //Allow,Forbid
    var HiddenFileNameList = null
    if (HiddenFieldFileNameList != "undefined")
    {
        //隐藏文件名列表
        HiddenFileNameList = $(HiddenFieldFileNameList);
    }

    var inputCssClass = "file";
    var fileShowCssClass = "fileNameItem";
    var fileNameCssName = "fileName";
    var deleteCssName = "deleteIco";

    //创建一个节点
    AddNode();

    //添加上传控件类
    function uploadClass(sId, sName, sClassName)
    {
        this.Id = sId;
        this.Name = sName;
        this.Hidefocus = true;
        this.ClassName = sClassName;

        this.add = function()
        {
            var input = document.createElement("input");
            input.setAttribute("id", this.Id);
            input.setAttribute("name", this.Name);
            input.setAttribute("type", "file");

            input.onchange = function()
            {
                addHideInput(input);
            }
            input.className = this.ClassName;
            input.hidefocus = true;

            return input;
        }
    }

    //显示文件名的类
    function showFileNameClass(sId, sName, sClassName, sFileClassName, sDeleteClassName)
    {
        this.Id = sId;
        this.Name = sName;
        this.ClassName = sClassName;
        this.FileClassName = sFileClassName;
        this.DeleteClassName = sDeleteClassName;

        this.add = function()
        {
            var fielNameContainer = document.createElement("div");
            fielNameContainer.setAttribute("id", this.Id);
            fielNameContainer.className = this.ClassName;

            var nobr = document.createElement("nobr");

            var fileName = document.createElement("span");
            fileName.className = this.FileClassName;
            var txt = document.createTextNode(this.Name);
            fileName.appendChild(txt);

            var deleteIco = document.createElement("a");
            deleteIco.title = "移除";
            deleteIco.href = "javascript:void(0)";
            deleteIco.className = this.DeleteClassName;

            fielNameContainer.appendChild(fileName);
            fielNameContainer.appendChild(deleteIco);

            deleteIco.onclick = function()
            {
                //删除文件名
                if (HiddenFileNameList != null)
                {
                    SetHiddenFileNameList(sName, "del");
                }
                deleteFileName(fielNameContainer);
            }
            nobr.appendChild(fielNameContainer);
            return nobr;
        }
    }

    function addHideInput(inputUploadObj)
    {
        if (checkFileType(inputUploadObj))
        {
            //移除节点
            Element.remove(inputUploadObj);
            //重新添加新节点
            AddNode();

            window.alert("该文件不允许上传!!!");
            return;
        }

        var aInputUploadList = getAllUploadInput();

        //最大个数
        if (fileCount != 0 && aInputUploadList.length > fileCount)
        {
            //移除节点
            Element.remove(inputUploadObj);
            //重新添加新节点
            AddNode();

            window.alert("已经达到允许上传文件的最大个数!");
            return;
        }
        //如果存在
        if (CheckUploadFileIsExist(inputUploadObj, aInputUploadList))
        {
            //移除节点
            Element.remove(inputUploadObj);
            //重新添加新节点
            AddNode();

            window.alert("该文件已经存在!请无重复添加!");
            return;
        }
        //如果不存在
        else
        {
            //获取上传的文件名
            var fileName = GetUploadFileName(inputUploadObj);
            //设置上传控件隐藏
            inputUploadObj.style.display = "none";

            //将文件名显示
            var fielNameContainerId = inputUploadObj.id.split("_")[0] + "_fileName";
            var showFileName = new showFileNameClass(fielNameContainerId, fileName, fileShowCssClass, fileNameCssName, deleteCssName)
            //upLoadFile.appendChild(showFileName.add());

            showFileNameList.appendChild(showFileName.add());

            //添加到名称字符串
            if (HiddenFileNameList != null)
            {
                SetHiddenFileNameList(fileName, "add");

            }

            //添加新的上传控件
            AddNode();
        }
    }

    //创建一个新的节点
    function AddNode()
    {
        //添加新节点
        var num = Utils.getAutomaticNum(20) + "_input";
        var uploadInput = new uploadClass(num, num, inputCssClass)
        upLoadFile.appendChild(uploadInput.add());
    }

    //获取所有的上传控件
    function getAllUploadInput()
    {
        var aInputUploadList = [];
        var InputList = upLoadFile.getElementsByTagName("input");
        for (var i = 0; i < InputList.length; i++)
        {
            if (InputList[i].type == "file")
            {
                aInputUploadList[aInputUploadList.length] = InputList[i];
            }
        }

        return aInputUploadList;
    }

    //检测上传的文件名是否已经存在
    function CheckUploadFileIsExist(inputObj, FileUploadList)
    {
        for (var i = 0; i < FileUploadList.length; i++)
        {
            if (inputObj.value == FileUploadList[i].value && inputObj.id != FileUploadList[i].id)
            {
                return true;
                break;
            }
        }
        return false;
    }

    //获取文件的名称
    function GetUploadFileName(inputObj)
    {
        var Filename = "";
        var FilePath = inputObj.value;

        var pos = FilePath.lastIndexOf('\\') + 1;
        var strLen = FilePath.length;
        var FilenameAll = FilePath.substring(pos, strLen); //带后缀的文件名
        Filename = FilenameAll;
        return Filename;
    }

    //删除
    function deleteFileName(fielNameContainer)
    {
        var inputId = fielNameContainer.id.split("_")[0] + "_input";
        if (fielNameContainer)
            Element.remove(fielNameContainer);
        if ($(inputId))
            Element.remove($(inputId));
    }

    //设置文件名字符串
    function SetHiddenFileNameList(theFileName, active)
    {
        var nameStr = HiddenFileNameList.value;
        if (active == "add")
        {
            if (nameStr != "")
            {
                nameStr += "|" + theFileName;
            }
            else
            {
                nameStr = theFileName;
            }
            HiddenFileNameList.value = nameStr;
        }
        else
        {
            var nameList = nameStr.split("|");
            var newList = new Array();
            for (var k = 0; k < nameList.length; k++)
            {
                if (theFileName != nameList[k])
                {
                    newList.push(nameList[k]);
                }
            }
            if (newList.length > 0)
            {
                HiddenFileNameList.value = newList.join("|");
            }
            else
            {
                HiddenFileNameList.value = "";
            }
        }
    }

    //-------------------------------------------------
    //检测文件类型
    function checkFileType(obj)
    {
        if (!obj || !obj.value) return false;

        var fileType = obj.value.substring((obj.value.lastIndexOf(".") + 1), obj.value.length);

        if (ValidateMode == "Allow")
        {
            for (var i = 0; i < FileTypeList.length; i++)
            {
                if (FileTypeList[i].toLowerCase().indexOf(fileType.toLowerCase()) != -1)
                {
                    return false;
                    break;
                }
            }
            return true;
        }
        if (ValidateMode == "Forbid")
        {
            for (var i = 0; i < FileTypeList.length; i++)
            {
                if (FileTypeList[i].toLowerCase().indexOf(fileType.toLowerCase()) != -1)
                {
                    return true;
                    break;
                }
            }
            return false;
        }
    }
}

///demo显示框架，demo1实际内容，demo2空的内容，speed移动速度，
///direction方向(left,right,top,bootom)
function Marquee(demo, demo1, demo2, speed, direction)
{
    var MarqueeDirection = function() { };
    switch (direction.toLowerCase())
    {
        case "left":
            MarqueeDirection = function()
            {
                MarqueeLeft(demo, demo1, demo2);
            }
            break;
        case "right":
            MarqueeDirection = function()
            {
                MarqueeRight(demo, demo1, demo2);
            }
            break;
        case "top":
            MarqueeDirection = function()
            {
                MarqueeTop(demo, demo1, demo2);
            }
            break;
        case "bottom":
            MarqueeDirection = function()
            {
                MarqueeBottom(demo, demo1, demo2);
            }
            break;
        default:
            var MarqueeDirection = function()
            {
                MarqueeLeft(demo, demo1, demo2);
            }
            break
    }

    demo2.innerHTML = demo1.innerHTML;
    var MyMar = setInterval(MarqueeDirection, speed)

    demo.onmouseover = function()
    {
        clearInterval(MyMar);
    }
    demo.onmouseout = function()
    {
        MyMar = setInterval(MarqueeDirection, speed);
    }

    //向左移动
    function MarqueeLeft(demo, demo1, demo2)
    {
        if (demo.scrollLeft >= demo2.offsetWidth)
        {
            demo.scrollLeft -= demo1.offsetWidth;
        }
        else
        {
            demo.scrollLeft++;
        }
    }

    //向右移动
    function MarqueeRight(demo, demo1, demo2)
    {
        if (demo.scrollLeft <= 0)
        {
            demo.scrollLeft += demo1.offsetWidth;
        }
        else
        {
            demo.scrollLeft--;
        }
    }

    //向上移动
    function MarqueeTop(demo, demo1, demo2)
    {
        if (demo.scrollTop >= demo2.offsetTop)
        {
            demo.scrollTop -= demo1.offsetHeight;
        }
        else
        {
            demo.scrollTop++;
        }
    }

    //向下移动
    function MarqueeBottom(demo, demo1, demo2)
    {
        if (demo.scrollTop <= demo2.offsetTop)
        {
            demo.scrollTop += demo1.offsetHeight;
        }
        else
        {
            demo.scrollTop--;
        }
    }
}

/*-----------------------------*/
/*
"年月日"日期选择类
*/
function YearMonthDaySelect(yearSelect, monthSelect, daySelect, dateValue, beginYear, endYear, isShowSelect)
{
    var year = $(yearSelect);
    var month = $(monthSelect);
    var day = $(daySelect);
    var initValue = $(dateValue);
    var IsShowSelect = isShowSelect;

    var dateArry = initValue.value.split("-");
    var theYear = dateArry[0];
    var theMonth = dateArry[1];
    var theDay = dateArry[2];

    for (var i = beginYear; i <= endYear; i++)
    {
        Utils.addSelectOption(year, i, i);
    }

    for (var i = 1; i <= 12; i++)
    {
        Utils.addSelectOption(month, i, i);
    }
    if (theYear != "") year.value = theYear;
    if (theMonth != "") month.value = theMonth;

    var daySize = getDayByYearAndMonth(year.value, month.value);
    for (var i = 1; i <= daySize; i++)
    {
        Utils.addSelectOption(day, i, i);
    }
    if (theDay != "") day.value = theDay;

    year.onchange = function()
    {
        changeYear(year.value);
    }

    month.onchange = function()
    {
        changeMonth(month.value);
    }

    day.onchange = function()
    {
        changeDay();
    }

    function changeYear(selectedValue)
    {
        var currentMonth = month.value;
        Utils.clearSelectOptionsList(month);
        Utils.clearSelectOptionsList(day);
        for (var i = 1; i <= 12; i++)
        {
            Utils.addSelectOption(month, i, i);
        }
        month.value = currentMonth;

        var daySize = getDayByYearAndMonth(year.value, month.value);
        for (var i = 1; i <= daySize; i++)
        {
            Utils.addSelectOption(day, i, i);
        }

        initValue.value = year.value + "-" + month.value + "-" + day.value;
    }

    function changeMonth(selectedValue)
    {
        Utils.clearSelectOptionsList(day);
        var YearSelectValue = year.value;
        var MonthSelectValue = selectedValue;
        var daySize = getDayByYearAndMonth(YearSelectValue, MonthSelectValue);
        for (var i = 1; i <= daySize; i++)
        {
            Utils.addSelectOption(day, i, i);
        }

        initValue.value = year.value + "-" + month.value + "-" + day.value;
    }

    function changeDay()
    {
        initValue.value = year.value + "-" + month.value + "-" + day.value;
    }

    //检测是否是平年
    function isPinYear(year)
    {
        if ((year % 4) == 0 && ((year % 100 != 0) || (year % 400 == 0)))
            return true;
        else
            return false;
    }

    function getDayByYearAndMonth(theYear, theMonth)
    {
        var MonHead = new Array(12);
        MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
        MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;

        if (isPinYear(theYear))
            MonHead[1] = 28;
        else
            MonHead[1] = 29;

        for (var i = 0; i < MonHead.length; i++)
        {
            if ((parseInt(theMonth) - 1) == i)
            {
                return MonHead[i];
                break;
            }
        }
    }
}

/*-----------------------------*/
/*
年月选择
*/
function YearMonthSelect(yearSelect, monthSelect, dateValue, beginYear, endYear, isShowSelect)
{
    var year = $(yearSelect);
    var month = $(monthSelect);
    var initValue = $(dateValue);
    var IsShowSelect = isShowSelect;

    var dateArry = initValue.value.split("-");
    var theYear = dateArry[0];
    var theMonth = dateArry[1];
    for (var i = beginYear; i <= endYear; i++)
    {
        Utils.addSelectOption(year, i, i);
    }

    for (var i = 1; i <= 12; i++)
    {
        Utils.addSelectOption(month, i, i);
    }
    if (theYear != "") year.value = theYear;
    if (theMonth != "") month.value = theMonth;

    year.onchange = function()
    {
        changeYear(year.value);
    }

    month.onchange = function()
    {
        changeMonth(month.value);
    }

    function changeYear(selectedValue)
    {
        var currentMonth = month.value;
        Utils.clearSelectOptionsList(month);
        for (var i = 1; i <= 12; i++)
        {
            Utils.addSelectOption(month, i, i);
        }
        month.value = currentMonth;

        initValue.value = year.value + "-" + month.value + "-" + 1;
    }

    function changeMonth(selectedValue)
    {
        initValue.value = year.value + "-" + month.value + "-" + 1;
    }
}

/*
======================元素控件的类=====================
*/
//Checkbox类
//funcEvent事件函数
function checkboxClass(funcEvent, Id, Name, Titile)
{
    this.Id = Id;
    this.Name = Name;
    this.Title = Titile;
    this.IsChecked = false;
    this.IsDisabled = false;

    this.add = function()
    {
        var label = document.createElement("label");

        var input = document.createElement("input");
        input.setAttribute("id", this.Id);
        input.setAttribute("name", this.Name);
        input.setAttribute("title", this.Title);
        input.setAttribute("type", "checkbox");


        input.onclick = function()
        {
            funcEvent(input);
        }

        label.appendChild(input);

        var txt = document.createTextNode(this.Title);
        label.appendChild(txt);

        input.checked = this.IsChecked;
        input.disabled = this.IsDisabled;

        return label;
    }
}

/*
======================
*/
//radio类
//funcEvent事件函数
function radioClass(funcEvent, Id, Name, Titile)
{
    this.Id = Id;
    this.Name = Name;
    this.Title = Titile;
    this.IsChecked = false;
    this.IsDisabled = false;

    this.add = function()
    {
        var label = document.createElement("label");
        var input = null;
        if (this.IsChecked)
        {
            input = document.createElement("<input name='" + this.Name + "' checked='checked' />");
        }
        else
        {
            input = document.createElement("<input name='" + this.Name + "' />");
        }
        input.setAttribute("id", this.Id);
        input.setAttribute("title", this.Title);
        input.setAttribute("type", "radio");
        input.setAttribute("onclick", funcEvent);

        label.appendChild(input);

        var txt = document.createTextNode(this.Title);
        label.appendChild(txt);

        return label;
    }
}

/*
选项卡
*/
function setTabMenu(oMenu, ContentId, MenuContainer, ContentContainer)
{
    var menulist = document.getElementById(MenuContainer).firstChild.cells;
    var contentList = document.getElementById(ContentContainer).childNodes;
    for (var i = 0; i < menulist.length; i++)
    {
        if (menulist[i] == oMenu)
        {
            menulist[i].className = "active";
        }
        else
        {
            menulist[i].className = "normal";
        }
    }

    for (var i = 0; i < contentList.length; i++)
    {
        if (contentList[i].id == ContentId)
        {
            contentList[i].className = "active";
            contentList[i].style.display = "";
        }
        else
        {
            contentList[i].className = "normal";
            contentList[i].style.display = "none";
        }
    }
}

function setVerticalTabMenu(oMenu, ContentId, MenuContainer, ContentContainer)
{
    var menulist = document.getElementById(MenuContainer).childNodes;
    var contentList = document.getElementById(ContentContainer).childNodes;
    for (var i = 0; i < menulist.length; i++)
    {
        if (menulist[i] == oMenu)
        {
            menulist[i].className = "active";
        }
        else
        {
            menulist[i].className = "normal";
        }
    }

    for (var i = 0; i < contentList.length; i++)
    {
        if (contentList[i].id == ContentId)
        {
            contentList[i].className = "active";
            contentList[i].style.display = "";
        }
        else
        {
            contentList[i].className = "normal";
            contentList[i].style.display = "none";
        }
    }
}

function TabOnMouseOver(oThis)
{
    if (oThis.className == "active")
    {
        return;
    }
    oThis.className = "mouseover";
}
function TabOnMouseOut(oThis)
{
    if (oThis.className == "active")
    {
        return;
    }
    oThis.className = "normal";
}

/*
/////////显示提示层
*/
function showhintinfo(obj, objleftoffset, objtopoffset, title, info, objheight, showtype, objtopfirefoxoffset)
{
    var p = getposition(obj);

    if ((showtype == null) || (showtype == ""))
    {
        showtype == "up";
    }
    document.getElementById('hintiframe' + showtype).style.height = objheight + "px";
    document.getElementById('hintinfo' + showtype).innerHTML = info;
    document.getElementById('hintdiv' + showtype).style.display = 'block';

    if (objtopfirefoxoffset != null && objtopfirefoxoffset != 0 && !isie())
    {
        document.getElementById('hintdiv' + showtype).style.top = p['y'] + parseInt(objtopfirefoxoffset) + "px";
    }
    else
    {
        if (objtopoffset == 0)
        {
            if (showtype == "up")
            {
                document.getElementById('hintdiv' + showtype).style.top = p['y'] - document.getElementById('hintinfo' + showtype).offsetHeight - 40 + "px";
            }
            else
            {
                document.getElementById('hintdiv' + showtype).style.top = p['y'] + obj.offsetHeight + 5 + "px";
            }
        }
        else
        {
            document.getElementById('hintdiv' + showtype).style.top = p['y'] + objtopoffset + "px";
        }
    }
    document.getElementById('hintdiv' + showtype).style.left = p['x'] + objleftoffset + "px";

    function getposition(obj)
    {
        var r = new Array();
        r['x'] = obj.offsetLeft;
        r['y'] = obj.offsetTop;
        while (obj = obj.offsetParent)
        {
            r['x'] += obj.offsetLeft;
            r['y'] += obj.offsetTop;
        }
        return r;
    }

    function isie()
    {
        if (navigator.userAgent.toLowerCase().indexOf('msie') != -1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
//隐藏提示层
function hidehintinfo()
{
    document.getElementById('hintdivup').style.display = 'none';
    document.getElementById('hintdivdown').style.display = 'none';
}

/**************************************************
名称: 图片轮播类
创建时间: 2007-11-12
示例:
页面中已经存在名为imgPlayer(或者别的ID也行)的节点.
PImgPlayer.addItem( "test", "http://www.pomoho.com", "http://static.pomoho.com/static/samesong/images/logo5.jpg");
PImgPlayer.addItem( "test2", "http://www.pomoho.com.cn", "http://static.pomoho.com/static/samesong/images/logo4.jpg");
PImgPlayer.addItem( "test3", "http://www.pomoho.com.cn", "http://static.pomoho.com/static/samesong/images/logo3.jpg");
PImgPlayer.init( "imgPlayer", 200, 230 );
备注:
适用于一个页面只有一个图片轮播的地方.
***************************************************/
var PImgPlayer = {
    _timer: null,
    _items: [],
    _container: null,
    _index: 0,
    _imgs: [],
    intervalTime: 5000, //轮播间隔时间
    init: function(objID, w, h, time)
    {
        this.intervalTime = time || this.intervalTime;
        this._container = document.getElementById(objID);
        this._container.style.display = "block";
        this._container.style.width = w + "px";
        this._container.style.height = h + "px";
        this._container.style.position = "relative";
        this._container.style.overflow = "hidden";
        //this._container.style.border = "1px solid #fff";
        var linkStyle = "display: block; TEXT-DECORATION: none;";
        if (document.all)
        {
            linkStyle += "FILTER:";
            linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') ";
            linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') ";
            linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )";
            linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()";
            linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)";
            linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )";
            linkStyle += "progid:DXImageTransform.Microsoft.Inset ()";
            linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )";
            linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )";
            linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )";
            linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )";
            linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )";
            linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )";
            linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )";
            linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )";
            linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )";
            linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()";
            linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )";
            linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )";
            linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )";
            linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )";
            linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%";
        }
        //
        var ulStyle = "margin:0;width:" + w + "px;position:absolute;z-index:999;right:5px;FILTER:Alpha(Opacity=30,FinishOpacity=90, Style=1);overflow: hidden;bottom:-1px;height:16px; border-right:1px solid #fff;";
        //
        var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
        //
        var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体';opacity: 0.6;";
        baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
        baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
        //
        var ulHTML = "";
        for (var i = this._items.length - 1; i >= 0; i--)
        {
            var spanStyle = "";
            if (i == this._index)
            {
                spanStyle = baseSpacStyle + "background:#ff0000;";
            } else
            {
                spanStyle = baseSpacStyle + "background:#000;";
            }
            ulHTML += "<li style=\"" + liStyle + "\">";
            ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\"" + spanStyle + "\" onclick=\"PImgPlayer.play(" + i + ");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i + 1) + "</span>";
            ulHTML += "</li>";
        }
        //
        var html = "<a href=\"" + this._items[this._index].link + "\" title=\"" + this._items[this._index].title + "\" target=\"_blank\" style=\"" + linkStyle + "\"></a><ul style=\"" + ulStyle + "\">" + ulHTML + "</ul>";
        this._container.innerHTML = html;
        var link = this._container.getElementsByTagName("A")[0];
        link.style.width = w + "px";
        link.style.height = h + "px";
        link.style.background = 'url(' + this._items[0].img + ') no-repeat center center';
        //
        this._timer = setInterval("PImgPlayer.play()", this.intervalTime);
    },
    addItem: function(_title, _link, _imgURL)
    {
        this._items.push({ title: _title, link: _link, img: _imgURL });
        var img = new Image();
        img.src = _imgURL;
        this._imgs.push(img);
    },
    play: function(index)
    {
        if (index != null)
        {
            this._index = index;
            clearInterval(this._timer);
            this._timer = setInterval("PImgPlayer.play()", this.intervalTime);
        } else
        {
            this._index = this._index < this._items.length - 1 ? this._index + 1 : 0;
        }
        var link = this._container.getElementsByTagName("A")[0];
        if (link.filters)
        {
            var ren = Math.floor(Math.random() * (link.filters.length));
            link.filters[ren].Apply();
            link.filters[ren].play();
        }
        link.href = this._items[this._index].link;
        link.title = this._items[this._index].title;
        link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center';
        //
        var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
        var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体'; opacity: 0.6;";
        baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
        baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
        var ulHTML = "";
        for (var i = this._items.length - 1; i >= 0; i--)
        {
            var spanStyle = "";
            if (i == this._index)
            {
                spanStyle = baseSpacStyle + "background:#ff0000;";
            } else
            {
                spanStyle = baseSpacStyle + "background:#000;";
            }
            ulHTML += "<li style=\"" + liStyle + "\">";
            ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\"" + spanStyle + "\" onclick=\"PImgPlayer.play(" + i + ");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i + 1) + "</span>";
            ulHTML += "</li>";
        }
        this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML;
    },
    mouseOver: function(obj)
    {
        var i = parseInt(obj.innerHTML);
        if (this._index != i - 1)
        {
            obj.style.color = "#ff0000";
        }
    },
    mouseOut: function(obj)
    {
        obj.style.color = "#fff";
    }
}

Object.Create = function(o)
{
    var F = function()
    {
    }
   ;
    F.prototype = o;
    return new F();
}


/**************************************************
名称: Flash图片轮播类
创建时间: 2010-4-21
示例:
var obj1 = Object.Create(FlashFocusImage);
obj1.focusWidth = 500;
obj1.focusHeight = 400;
obj1.textHeight = 18;
obj1.flashFile = "/Flash/FocusImage.swf";
obj1.picList = "图片地址1|图片地址2|图片地址3";
obj1.linklist = "链接地址1|链接地址2|链接地址3";
obj1.textList = "文本1|文本2|文本3";;
obj1.Play();
***************************************************/
var FlashFocusImage = new Object();
FlashFocusImage = {
    focusWidth: 350, focusHeight: 200, textHeight: 18, flashFile: "/Flash/FocusImage.swf", picList: null, linklist: null, textList: null,
    Play: function()
    {
        var pics = this.picList;
        var links = this.linklist;
        var texts = this.textList;
        var focus_width = this.focusWidth;
        var focus_height = this.focusHeight;
        var text_height = this.textHeight;
        var swf_height = focus_height + text_height;
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + focus_width + '" height="' + swf_height + '">');
        document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="' + this.flashFile + '"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
        document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
        document.write('<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">');
        document.write('<embed src="' + this.flashFile + '" FlashVars="pics=' + pics + '&links=' + links + '&texts=' + texts + '&pic_width=' + focus_width + '&pic_height=' + focus_height + ' quality="high" width="' + focus_width + '" height="' + swf_height + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
    }
}



/**************************************************
名称: Flash图片轮播类
创建时间: 2010-4-21
示例:
FocusImageShow.imgList = "a.jpg|b.jpg|c.jpg|d.jpg";
FocusImageShow.urlList = "1.htm|2.htm|3.htm|4.htm";
FocusImageShow.width = 600;
FocusImageShow.height = 400;
FocusImageShow.Play();
***************************************************/
var FocusImageShow = {
    $: function(v)
    {
        return document.getElementById(v)
    },
    getEles: function(id, ele)
    {
        return this.$(id).getElementsByTagName(ele);
    },
    width: 350, height: 200, imgList: null, urlList: null, imgArray: new Array(), urlArray: new Array(), imageID: "FocusImageShow_imageID", urlID: "FocusImageShow_urlID", NumberID: "FocusImageShow_NumberID", count: null, isFirstShow: true, currentNumber: 0, timeHandle: null, timeDuration: 5000,
    ChangeImage: function()
    {
        if (this.isFirstShow)
        {
            this.isFirstShow = false;
        }
        else if (document.all)
        {
            //如果是IE
            this.$(this.imageID).filters[0].Apply();
            this.$(this.imageID).filters[0].Play(duration = 2);
        }
        this.$(this.imageID).src = this.imgArray[this.currentNumber];
        this.$(this.urlID).href = this.urlArray[this.currentNumber];

        for (var i = 0; i < this.count; i++)
        {
            document.getElementById(this.NumberID + i).className = 'FocusImageShow-Normal';
        }

        document.getElementById(this.NumberID + this.currentNumber).className = 'FocusImageShow-Active';

        this.currentNumber++;
        if (this.currentNumber >= this.count)
        {
            this.currentNumber = 0;
        }
        this.timeHandle = window.setTimeout("FocusImageShow.ChangeImage()", this.timeDuration);

    },
    _ChangeImage: function(num)
    {
        this.currentNumber = num;
        window.clearInterval(this.timeHandle);
        this.ChangeImage();

    },
    Play: function()
    {
        this.imgArray = this.imgList.split("|");
        this.urlArray = this.urlList.split("|");
        this.count = this.imgArray.length;

        document.write('<style rel="stylesheet" type="text/css">');
        document.write('.FocusImageShow-Normal{padding:1px 7px;border-left:#cccccc 1px solid;}');
        document.write('a.FocusImageShow-Normal:link,a.FocusImageShow-Normal:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
        document.write('a.FocusImageShow-Normal:active,a.FocusImageShow-Normal:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
        document.write('.FocusImageShow-Active{padding:1px 7px;border-left:#cccccc 1px solid;}');
        document.write('a.FocusImageShow-Active:link,a.FocusImageShow-Active:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
        document.write('a.FocusImageShow-Active:active,a.FocusImageShow-Active:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
        document.write('</style>');

        document.write('<div style="width:' + this.width + 'px;height:' + this.height + 'px;overflow:hidden;text-overflow:clip;">');
        document.write('<div><a id="' + this.urlID + '" target="_blank"><img id="' + this.imageID + '" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width=' + this.width + ' height=' + this.height + ' /></a></div>');
        document.write('<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%;text-align:right;top:-12px;position:relative;height:12px;padding:0px;margin:0px;border:0px;">');

        for (var i = 0; i < this.count; i++)
        {
            document.write('<span><a href="javascript:FocusImageShow._ChangeImage(' + i + ');" id="' + (this.NumberID + i) + '" class="FocusImageShow-Normal">' + (i + 1) + '</a></span>');
        }
        document.write('</div></div>');
        this.ChangeImage();
    }
}

