﻿/// <reference path="../jquery-1.3.2-vsdoc.js" />
jQuery.extend({
    showMessage: function(Message) {
        var messageItem = $("#showmessage");
        var hidenTimer;
        if (!messageItem[0]) {
            $("body").append("<div class='c_clew02' id='showmessage' style='display:none;'><!--[if lte IE 6]><iframe scrolling='no' frameborder='0' style='opacity: 0; filter: Alpha(Opacity=0); left:0px; border: 0px none; z-index: -1; position:absolute; display:block; height: 45px ! important; width:100%;'></iframe><![endif]--><div class='c_clew-nr' id='showmessagecontend'>" + Message + "</div></div>");
            messageItem = $("#showmessage");
        }
        //定位
        setPosition(messageItem);
        //淡入
        messageItem.fadeIn("slow");
        //清除
        hidenTimer = setTimeout(hiddenMessage, 5000);

        //定位
        function setPosition(messageItem) {
            var itemWidth = messageItem.width();

            var bodyWidth = $(window).width();

            var itemLeft = parseInt((bodyWidth - itemWidth) / 2);

            messageItem.css({
                left: itemLeft + "px"
            });
        }
        function hiddenMessage() {
            $("#showmessage").fadeOut("slow");
            clearTimeout(hiddenMessage);
        }
    }
});

jQuery.extend({
    MessageTooTipe: function(options) {
        regEvent();
        var lastSize = { width: "", height: "" };
        var empty = {};
        //默认选项
        var defaultOptions = { css: "layer", titleCss: "", contentCss: "c_clew-nr", descCss: "", title: "", content: "", desc: "", width: 225, height: 75 };
        //合并默认项和传入的参数
        var settings = $.extend(empty, defaultOptions, options);
        var iframe = "<!--[if lte IE 6]><iframe scrolling='no' frameborder='0' style='opacity: 0; filter: Alpha(Opacity=0); left:0px; border: 0px none; z-index: -1; position:absolute; display:block; height: 45px ! important; width:100%;'></iframe><![endif]-->";
        var cssInfo = { width: settings.width + "px", height: settings.height + "px" };
        //计算初始位置
        var positionInfo = InitPosition();
        //创建最外层的div,添加到body中
        var div;
        //通过name和id属性来确定显示的div
        var tipeItem = $("div[id=msgTipes][name=messageTipes]");
        if (tipeItem[0]) {
            div = tipeItem.empty().show().attr({ name: "messageTipes", id: "msgTipes" }).addClass(settings.css).css("z-index", "999").css(cssInfo).css(positionInfo).html(iframe);
        }
        else {
            //不存在这个对象，则创建
            div = $("<div />").attr({ name: "messageTipes", id: "msgTipes" }).addClass(settings.css).css("z-index", "999").css(cssInfo).css(positionInfo).html(iframe).appendTo($("body"));
        }
        //需要显示标题
        if ($.trim(settings.title).length > 0) {
            //创建标题div
            var titleDiv = $("<div />").addClass(settings.titleCss).html(settings.title).appendTo(div);
        }
        //需要显示内容
        if ($.trim(settings.content).length > 0) {
            //创建内容div
            var contentDiv = $("<div />").addClass(settings.contentCss).html(settings.content).appendTo(div);
        }
        //需要显示描述信息
        if ($.trim(settings.desc).length > 0) {
            //创建描述div
            var descDiv = $("<div />").addClass(settings.descCss).html(settings.desc).appendTo(div);
        }

        //动画效果
        var target = TargetPosition();
        div.animate({ "top": target.top }, 3000, function() {
            div.fadeOut(3000);
        });

        function InitPosition() {
            var bodyWidth = $(window).width();
            var bodyHeight = $(window).height();
            //chus
            lastSize.width = bodyWidth;
            lastSize.height = bodyHeight;
            //左右剧中
            var itemLeft = parseInt((bodyWidth - settings.width) / 2) + parseInt($(document).scrollLeft());
            //上下2/3处
            var itemTop = parseInt((bodyHeight - settings.height) / 3 * 2) + parseInt($(document).scrollTop());

            return { top: itemTop, left: itemLeft, position: "absolute" };
        }
        //移动到的目标位置
        function TargetPosition() {
            var bodyWidth = $(window).width();
            var bodyHeight = $(window).height();

            //左右剧中
            var itemLeft = parseInt((bodyWidth - settings.width) / 2) + parseInt($(document).scrollLeft());
            //上下1/3处
            var itemTop = parseInt((bodyHeight - settings.height) / 5) + parseInt($(document).scrollTop());

            return { top: itemTop, left: itemLeft };
        }

        function regEvent() {
            //此方法有问题，IE7下面会触发两次，FF没有这个问题
            $(window).resize(function(event) {
                //
                //event.stopImmediatePropagation();
                //alert($(window).height());
            });
        }
    }
});

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie   
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE   
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } 
    else { // only name given, get cookie   
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?   
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};  


///创建cookie对象
///dom 保存cookie的document对象，必需的
///name指定cookie名字，必需的
///hours 可选数字，指定cookie过期的小时数
///path 可选字符串，指定cookie的路径性质
///domain 可选字段 指定cookie的域性质
///secure 可选的bool值，true需要一个安全的cookie
///对象中的所有属性都以$开头，以区分存储在cookie中的属性值
/*
 *	示例
$(document).ready(function() {
$("#Button1").bind("click", showCookie);
$("#Button2").bind("click", removeCookie);
});

function showCookie() {
    var mycookie = new Cookie(document, 'test', 240);
    if (!mycookie.load() || !mycookie.name || !mycookie.color) {
        mycookie.name = "junelee";
        mycookie.color = "yellow";
    }

    if (mycookie.visits == null) {
        mycookie.visits = 0;
    }
    mycookie.visits++;

    mycookie.store();
    $("#show").empty().append("<font size='7' color='" + mycookie.color + "'>welcom," + mycookie.name + "</font><p>你已经访问了" + mycookie.visits + "次</p>");
}

function removeCookie() {
    var mycookie = new Cookie(document, 'test');
    mycookie.remove();
}
 */
function Cookie(dom, name, hours, path, domain, secure) {
    this.$document = dom;
    this.$name = name;
    if (hours) {
        this.$expiration = new Date(new Date().getTime() + hours * 3600000);
    }
    else {
        this.$expiration = null;
    }
    if (path) {
        this.$path = path;
    } else {
        this.$path = null;
    }
    if (domain) {
        this.$domain = domain;
    } else {
        this.$domain = null;
    }
    if (secure) {
        this.$secure = true;
    } else {
        this.$secure = false;
    }
}

///cookie的store方法
Cookie.prototype.store = function() {
    
    //首先遍历cookie对象的属性，并将cookie值连接
    //cookie将=和；作为分隔符，所以使用：和&来区分存储在单个cookie值中的状态变量
    //并对每个变量的值进行转义，防止含有非法字符
    var cookieval = '';
    for (var prop in this) {
        //忽略所以以$开头的名字和方法
        if (prop.charAt(0) == '$' | (typeof (this[prop]) == 'function')) {
            continue;
        }
        if (cookieval != '') {
            cookieval += '&';
        }
        cookieval += prop + ':' + escape(this[prop]);
    }
    //有了cookie值，就可以连接完整的cookie串，包括名字和创建cookie时指定的各种属性
    var cookie = this.$name + "=" + cookieval;
    if (this.$expiration) {
        cookie += ';expires=' + this.$expiration.toGMTString();
    }
    if (this.$path) {
        cookie += ';path=' + this.$path;
    }
    if (this.$domain) {
        cookie += ';domain=' + this.$domain;
    }
    if (this.$secure) {
        cookie += ';secure;';
    }

    //设置document.cookie对象来保存cookie
    this.$document.cookie = cookie;
}

//cookie对象的load方法
Cookie.prototype.load = function() {
    //通过document.cookie获得属于该文档的所有cookie列表
    var allCookies = this.$document.cookie;
    if (allCookies == "") {
        return false;
    }
    //从列表中提取以命名的cookie
    var start = allCookies.indexOf(this.$name + '=');
    //该页未定义cookie
    if (start == 1) {
        return false;
    }
    //跳过名字和符号
    start += this.$name.length + 1;
    var end = allCookies.indexOf(';', start);
    if (end == -1) {
        end = allCookies.length;
    }
    var cookieval = allCookies.substring(start, end);

    //分割存储cookie值，名字值对由&分割，名字和值之间由：分割
    var a = cookieval.split('&');
    for (var i = 0; i < a.length; i++) {
        a[i] = a[i].split(':');
    }
    //重新赋值
    for (var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }
    return true;
}
//移除cookie
Cookie.prototype.remove = function() {
    var cookie = this.$name + "=";
    if (this.$path) {
        cookie += ";path=" + this.$path;
    }
    if (this.$domain) {
        cookie += ";domain=" + this.$domain;
    }
    cookie += ";expires=01-Jan-80 00:00:01 GMT;";
    this.$document.cookie = cookie;
}

///web页面对象
function WebContext() {
}
//获取url参数值
WebContext.GetQueryString = function(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
}

//jquery公共方法
function JQueryMethod() {
}
//动态加载html并执行
JQueryMethod.ReadHtml = function(url, successFunction, para) {
    $.ajax({
        type: 'GET',
        url: url,
        dataType: 'html',
        success: function(data) { successFunction(data, para); }
    });
}
//转换时间日期
JQueryMethod.ConvertDateTime = function(dateTime) {
    return dateTime.getYear() + "-" + (parseInt(dateTime.getMonth())+1) + "-" + dateTime.getDate();
}
String.prototype.Trim = function() {
    var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

String.prototype.getLength = function() {
    var len = 0;
    for (var i = 0; i < this.length; i++) {
        if (this.charCodeAt(i) >= 0x4e00 && this.charCodeAt(i) <= 0x9fa5) {
            len += 2;
        }
        else {
            len++;
        }
    }
    return len;
}
String.prototype.ToDateTime = function(dateStr) {
    return new Date(dateStr.replace(/-/g, "/"));
}

Date.prototype.format = function(format) {
    var o = {
        "M+": this.getMonth() + 1,  //month
        "d+": this.getDate(),     //day
        "h+": this.getHours(),    //hour
        "m+": this.getMinutes(),  //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}
function RestrictLength(eve, maxlength) {

    var text = $(eve).val().Trim();
    var l = text.getLength();
    var len_num = text.match(/[^\x00-\xff]/ig);
    var len = len_num == null ? 0 : len_num.length;
    if (l > maxlength) {
        if (len < (maxlength / 2))
            $(eve).val(text.substring(0, maxlength - len));
        else
            $(eve).val(text.substring(0, (maxlength / 2)));
    }
}

function LengthLimit(event) {

    var maxlength = $(this).attr("maxlength") || (event.data == null ? 10 : event.data.Length);
    var text = $(this).val().Trim();
    var l = text.getLength();
    var len_num = text.match(/[^\x00-\xff]/ig);
    var len = len_num == null ? 0 : len_num.length;
    if (l > maxlength) {
        if (len < (maxlength / 2))
            $(this).val(text.substring(0, maxlength - len));
        else
            $(this).val(text.substring(0, (maxlength / 2)));
    }
}

/*
 *	时间提示
 */
// JScript 文件
function showTime() {
    var OutPutStr = "";
    var TimerMessage = new Array();
    var time = new Date();
    var date = new Date(time.toDateString());

    var vHour = time.getHours()
    var vMin = time.getMinutes()
    var vSec = time.getSeconds()

    var currenttime = vHour + "时:" + vMin + "分:" + vSec + "秒";

    TimerMessage.push({ Time: date.setHours(6, 00), Message: "距离6点还有" });
    TimerMessage.push({ Time: date.setHours(09, 00), Message: "一日之计在于晨，早餐吃好哦。" });
    TimerMessage.push({ Time: date.setHours(11, 30), Message: "距离11:30还有" });
    TimerMessage.push({ Time: date.setHours(14, 30), Message: "午餐吃饱，精力充沛，干活不累。" });
    TimerMessage.push({ Time: date.setHours(18, 00), Message: "距离晚18点还有" });
    TimerMessage.push({ Time: date.setHours(20, 00), Message: "晚餐吃少，营养调节，身体健康。" });
    TimerMessage.push({ Time: date.setHours(1, 00), Message: "马无夜草不肥，来点宵夜？" });
    if (time > TimerMessage[6].Time && time < TimerMessage[0].Time) {
        var t = new Date(TimerMessage[0].Time);
        t = t - time;
        var h = Math.floor(t / 3600000);
        var m = Math.floor((t % 3600000) / 60000)

        OutPutStr = TimerMessage[0].Message;
        if (h > 0) {
            OutPutStr = OutPutStr + h + "小时";
        }
        OutPutStr = OutPutStr + m + "分";
    }
    else if (time > TimerMessage[0].Time && time < TimerMessage[1].Time) {
        OutPutStr = TimerMessage[1].Message;
    }
    else if (time > TimerMessage[1].Time && time < TimerMessage[2].Time) {
        var t = new Date(TimerMessage[2].Time);
        t = t - time;

        var h = Math.floor(t / 3600000);
        var m = Math.floor((t % 3600000) / 60000)

        OutPutStr = TimerMessage[2].Message;
        if (h > 0) {
            OutPutStr = OutPutStr + h + "小时";
        }
        OutPutStr = OutPutStr + m + "分";
    }
    else if (time > TimerMessage[2].Time && time < TimerMessage[3].Time) {
        OutPutStr = TimerMessage[3].Message;
    }
    else if (time > TimerMessage[3].Time && time < TimerMessage[4].Time) {
        var t = new Date(TimerMessage[4].Time);
        t = t - time;
        var h = Math.floor(t / 3600000);
        var m = Math.floor((t % 3600000) / 60000)

        OutPutStr = TimerMessage[4].Message;
        if (h > 0)
            OutPutStr = OutPutStr + h + "小时";

        OutPutStr = OutPutStr + m + "分";
    }
    else if (time > TimerMessage[4].Time && time < TimerMessage[5].Time) {
        OutPutStr = TimerMessage[5].Message;
    }
    else {
        OutPutStr = TimerMessage[6].Message;
    }
    $("#div_time").html(OutPutStr);
}
window.setInterval('showTime()', 1000);

/************************************************************************/
/* common                                                               */
/************************************************************************/
function ShowMsg(div_id, mes, btn_id) {
    var item = $("#" + div_id);
    var btn = $("#" + btn_id);
    if (btn[0]) {
        var top = btn.position().top;
        var left = parseInt(btn.position().left + btn.width() + 5);
    }
    if (btn.is("input:button")) {//如果是按钮
        item.html(mes);
    }
    else {
        item.html(mes).css({ position: "absolute", top: top, left: left, "white-space": "nowrap" });
    }
    item.fadeIn("slow", function() {
        item.fadeOut(5000);
    });
}

function ValidateInput(obj, text) {
    if (obj.val() == "" || obj.val() == "输入个人或企业帐号") {
        obj.val(text);
        obj.css("background-color", 'yellow');
        obj.fadeOut('normal')
        obj.fadeIn('normal')
        obj.fadeOut('normal')
        obj.fadeIn('normal',
		function() {
		    obj.css('background-color', '');
		    obj.val(''); obj.focus();
		});
        return false;
    }
    return true;
}

//复制到粘贴板
function copyToClipBoard(txt) {
    txt += "";
    if (window.clipboardData) {
        //window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
    } else if (navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            prompt("请复制网站地址:", txt);
            //alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
            return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
            return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
    }
    alert("您已经成功复制本帖地址，请直接粘贴推荐给你的朋友！");
}

function ShowSendAddress() {
    if (confirm("您的送餐楼宇与您参加团购的送餐楼宇不符,现在修改吗？")) {
        $(document).ready(function() {
            $("#div_address").dialog({ autoOpen: false, width: 700, height: 450, title: "我的收餐地址", modal: true });
            $("#div_address").dialog("open");
            SendAddress.Init();
        });
    }
}

//公告部分添加点击量。
function AddAdHitCount(adId) {
    $.ajax({
        url: "/PageHandler.ashx",
        data: "className=AdAndNews&methodName=AddAdHitCount&parameter=" + adId,
        dataType: 'json',
        cache: false,
        async: false,
        success: function(data) {
        },
        error: function(data) {
        }
    });
}

function resizeimg(ImgD, iwidth, iheight) {
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= iwidth / iheight) {
            if (image.width > iwidth) {
                ImgD.width = iwidth;
                ImgD.height = (image.height * iwidth) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > iheight) {
                ImgD.height = iheight;
                ImgD.width = (image.width * iheight) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}

function GetUrlParam(paramName) {
    var oregex = new RegExp('[\?&]' + paramName + '=([^&]+)', 'i');
    var oMatch = oregex.exec(window.top.location.search);
    if (oMatch && oMatch.length > 1) {
        return (oMatch[1]);// decodeURIComponent(oMatch[1]);
    }
    return '';
}
///支持楼宇、店铺 展开事件
function listOprEvntBind() {

    $("a[name='a_expand']").toggle(function() {
        $(this).attr("class", "g_ico_top");
        var sid = $(this).attr("sid");
        $("p[name='p_info'][sid='" + sid + "']").removeAttr("style");
    },
     function() {
         $(this).attr("class", "g_ico_under");
         var sid = $(this).attr("sid");
         $("p[name='p_info'][sid='" + sid + "']").css("height", '40px');
     });
}
/************************************************************************/
/* flash播放                                                      */
/************************************************************************/
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion() {
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version) {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 

            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }
    return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer() {
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];

        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}

function AC_AddExtension(src, ext) {
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext + '?');
    else
        return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) {
    var str = '';
    if (isIE && isWin && !isOpera) {
        str += '<object ';
        for (var i in objAttrs) {
            str += i + '="' + objAttrs[i] + '" ';
        }
        str += '>';
        for (var i in params) {
            str += '<param name="' + i + '" value="' + params[i] + '" /> ';
        }
        str += '</object>';
    }
    else {
        str += '<embed ';
        for (var i in embedAttrs) {
            str += i + '="' + embedAttrs[i] + '" ';
        }
        str += '> </embed>';
    }
    document.write(str);
}

function AC_FL_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i = 0; i < args.length; i = i + 2) {
        var currArg = args[i].toLowerCase();

        switch (currArg) {
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i + 1];
                break;
            case "src":
            case "movie":
                args[i + 1] = AC_AddExtension(args[i + 1], ext);
                ret.embedAttrs["src"] = args[i + 1];
                ret.params[srcParamName] = args[i + 1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblClick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
            case "id":
                ret.objAttrs[args[i]] = args[i + 1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "name":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
}
///添加至收藏夹
function JSAddFavorite() {
    if (window.sidebar && "object" == typeof (window.sidebar) && "function" == typeof (window.sidebar.addPanel)) {
        //  firefox
        window.sidebar.addPanel(document.title, document.location.href, '');
    }
    else if (document.all && "object" == typeof (window.external)) {
        //  ie
        window.external.addFavorite(document.location.href, document.title);
    }
}
//格式化数据
function ForDight(Dight, How) {
    Dight = Math.round(Dight * Math.pow(10, How)) / Math.pow(10, How);
    return Dight;
}
