﻿//更新时间：3-21

function addFlash(m_width, m_height, m_style, m_src, m_flashvars) {
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width=" + m_width + " height=" + m_height + " style=\"margin:0px;" + m_style + "\">");
    document.write("<param name='movie' value='" + m_src + "' />");
    document.write("<param name='quality' value='high' />");
    document.write("<param name='menu' value='false' />");
    document.write("<param name='wmode' value='transparent' /> ");
    document.write("<param name='flashvars' value='" + m_flashvars + "' /> ");
    document.write("</object>");
}

//收藏
function mark() {
    bookmark(window.location, document.title);
}
function bookmark(sURL, sTitle) {
    try {
        window.external.AddFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
//设为首页
function setHome(This) {
    This.style.behavior = 'url(#default#homepage)';
    This.setHomePage(window.location);
}


function flashNew(width, height, pics, titles, links) {
    //csdn:addFlash(width,height,"background:#000000","/content/pic.swf","pic_width="+width+"&pic_height="+height+"&pics="+pics+"&links="+links+"&texts="+titles+"&show_text=0&txtcolor=000000&bgcolor=666666&button_pos=4&stop_time=3000&border=0");
    if (titles.length > 6) {
        addFlash(width, height, "background:#eeeeee", "/content/pixviewer.swf",
            "borderwidth=" + width + "&borderheight=" + (height - 18) + "&pics=" + pics + "&links=" + links + "&texts="
            + titles + "&textheight=18&curhref=http://www.sina.com.cn");
    } else {
        addFlash(width, height, "background:#eeeeee", "/content/pixviewer.swf",
            "borderwidth=" + width + "&borderheight=" + height + "&pics=" + pics + "&links=" + links + "&texts="
            + titles + "&textheight=0&curhref=http://www.sina.com.cn");
    }
    //pics=&links=&texts=&borderwidth=306&borderheight=169&textheight=0&curhref=
}


//BannerShow
function BannerShow() {
    this.mID = null;
    this.timer = null;
    this.mHtml = "";
    this.Img = new Array();
    this.Title = new Array();
    this.Address = new Array();
    this.index = 0;
    //添加图片
    this.AddImage = function(img, title, address) {
        this.Img[this.Img.length] = img;
        this.Title[this.Title.length] = title;
        this.Address[this.Address.length] = address;
    }
    //开始播放
    this.playNext = function() {

        this.index++;
        if (this.index >= this.Img.length) this.index = 0;
        for (var i = 0; i < this.Img.length; i++) {
            if (i == this.index) {
                document.getElementById(this.mID + "img" + i).filters.blendTrans.apply();
                document.getElementById(this.mID + "img" + i).style.visibility = "visible";
                document.getElementById(this.mID + "img" + i).filters.blendTrans.play();
            } else {
                document.getElementById(this.mID + "img" + i).filters.blendTrans.apply();
                document.getElementById(this.mID + "img" + i).style.visibility = "hidden";
                document.getElementById(this.mID + "img" + i).filters.blendTrans.play();
            }
        }
    }
    //开始构建
    this.create = function(id, width, height, non_click) {
        this.mID = id;
        this.mHtml = "<div id='" + id + "' style='width:" + width + "px;height:" + height + "px;position:relative;overflow:hidden;'>";
        for (var i = 0; i < this.Img.length; i++) {
            this.mHtml = this.mHtml + "<a href='" + this.Address[i] + "' title='" + this.Title[i] + "' target='_blank'><img alt='" + this.Title[i] + "' id='" + id + "img" + i + "' src='" + this.Img[i] + "' style='width:100%;height:100%;position:absolute;top:0px;left:0px;margin:0px;FILTER: blendTrans(duration=1);border:0px;"
            if (i != 0) this.mHtml = this.mHtml + "visibility:hidden;"; //将第一个设为可见
            this.mHtml = this.mHtml + "' /></a>";
        }

        if (non_click == true) {
            this.mHtml = this.mHtml + "<div style='position:absolute;width:100%;height:100%;background:#FFFFFF;filter:alpha(style=0,opacity=1);'>您的浏览器版本过低</div>";
        }

        this.mHtml = this.mHtml + "</div>";
        document.write(this.mHtml);
    }
    //播放
    this.play = function() {
        if (this.timer == null) {
            var self = this;
            this.timer = setInterval(function() { self.playNext(); }, 5000);
        }
    }
    //停止
    this.stop = function() {
        clearInterval(this.timer);
        this.timer = null;
    }
    //调用构建


}

//动画切换:简单
function EasyBanner(width, height, images) {
    var tm = new Date();
    var banner = new BannerShow();
    var imgs = images.split("|");
    for (var i = 0; i < imgs.length; i++) {
        banner.AddImage(imgs[i], "", "/");
    }
    banner.create("abc" + tm.getTime(), width, height, true);
    banner.play();

}




///***********************************************************
//在线客服
function hideKF() {
    document.getElementById("kfdiv").style.display = "none";
}
function KF(qq, info) {
    var _self = this;
    //飘动    
    this.move = function() {
        var img = document.getElementById("kfdiv").style.top = 80 + document.documentElement.scrollTop; //80+document.body.scrollTop;
    }

    //输出对象
    var html = "<div id='kfdiv' style='top:80px;cursor:hand;position:absolute;width:100px;height:200px;right:3px; z-inde:99;background:url(\"/content/user_kf.gif\") no-repeat;' >\r\n";
    html += ("<a href='tencent://message?uin=" + qq + "' style='display:block;height:120px;border:0px solid red;'>&nbsp;</a><div style='cursor:hand;position:absolute;width:90px;height:70px;border:0px solid red;left:5px;top:115px;overflow:hidden;'>" + info + "</div>");
    html += ("<img title='点击此处关闭' src='/content/close.gif' onclick='hideKF()' style='color:blue;position:absolute;bottom:1px;left:2px;' />");
    html += ("</div>\r\n");
    document.write(html);
    //设置事件
    window.attachEvent("onscroll", _self.move);
    window.attachEvent("onresize", _self.move);
    //window.onscroll += function() { _self.move(); }
    //window.onresize += function() { _self.move(); }
    //改变背景
    this.SetBackground = function(img) {
        document.getElementById("kfdiv").style.background = "url(" + img + ") no-repeat";
    }
    //改变前影色
    this.SetForeColor = function(color) {
        document.getElementById("kfdiv").style.color = color;
    }
    //设置样式
    this.SetBackgroundIndex = function(idx) {
        switch (idx) {
            case 0:
                this.SetBackground("/content/hichina_kf.gif");
                break;
            case 1:
                this.SetBackground("/content/user_kf.gif");
                break;
            default:
                break;
        }

    }

}





//===================禁止选择网页内容，屏蔽右键==========
//调用方式：<script>DeSelect();</script>
function DeSelect() {
    this.__szft_empty = function() {
        document.selection.empty();
    }
    this.__szft_return_false = function() {
        return false;
    }
    this.__EventsBind = function() {
        try {
            document.body.oncontextmenu = this.__szft_return_false;
            document.body.ondragstart = this.__szft_return_false;
            document.body.onselectstart = this.__szft_return_false;
            document.body.onselect = this.__szft_empty;
            document.body.oncopy = this.__szft_empty;
            document.body.onbeforecopy = this.__szft_return_false;
            document.body.onmouseup = this.__szft_empty;
        }
        catch (e) {
            //屏蔽失败
        }
    }
    this.__EventsBind();
}


//获取META信息
function GetMETA(metaname) {
    var metas = document.getElementsByTagName('META');
    for (var i = 0; i < metas.length; i++) {
        if (metas[i].getAttribute('NAME').toUpperCase() == metaname.toUpperCase())
            return metas[i].getAttribute('CONTENT');
    }
    return "";
}


//String扩展
String.prototype.format = function() {
    var args = arguments;
    return this.replace(/\{(\d+)\}/g,
        function(m, i) {
            return args[i];
        });
}

String.format = function() {
    if (arguments.length == 0)
        return null;

    var str = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
}
//String扩展:替换全部
String.prototype.replaceAll = function(s1, s2) {
    return this.replace(new RegExp(s1, "gm"), s2);
}


//水印API===================================================================================================
function ApplyMask(ImgObj, width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text) {
    var masktext = "www.zyc1.com";
    if (mask_text != null) masktext = mask_text;

    var commonstyle = "position:absolute;width:100%;height:100%;left:0px;top:0px;font-family:Tahome;font-weight:bold;font-size:" + font_size + ";";
    var img = ImgObj;  //document.getElementById(imgid);
    img.style.width = "100%";
    img.style.height = "100%";
    img.style.border = "0px";

    var obj = document.createElement("span");
    obj.setAttribute("style", "width:" + width + ";height:" + height + ";border:0px solid Gray;display:inline-block;position:relative;overflow:hidden;line-height:" + line_height
                        + ";text-align:center;color:" + text_color + ";font-family:" + font_family + ";margin:0px;padding:0px;");
    img.parentNode.insertBefore(obj, img);
    obj.insertBefore(img, null);
    obj.innerHTML += "<span style='" + commonstyle + "filter:alpha(style=0,opacity=1);z-index:88;background:#FFFFFF;'></span>";
    obj.innerHTML += "<span style='filter:DropShadow(Color=#555555,OffX=1,OffY=1,Positive=1) alpha(style=0,opacity=" + font_opacity + ");  z-index:99;" + commonstyle + "'>" + masktext + "</span>";

}
//将ID为ＸＸ的图片加上水印
function ApplyByID(imgid, width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text) {
    ApplyMask(document.getElementById(imgid), width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text);
}
//将某DIV下的所有图片加上水印
function UseMasks(DivObj, width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text) {
    var cld = DivObj.childNodes;
    for (var i = 0; i < cld.length; i++) {
        try {
            if (cld[i].tagName.toLowerCase() == "img") {
                ApplyMask(cld[i], width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text);
            } else {
                UseMasks(cld[i], width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text);
            }
        }
        catch (e) { }
    }
}
//将某DIV下的所有图片加上水印
function use_mask_for_all_child_objects(DivName, width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text) {
    UseMasks(document.getElementById(DivName), width, height, line_height, text_color, font_size, font_family, font_opacity, mask_text)
}


/*
创建滚动文本对象:内容所在div的ID,创建高度，速度，是否启用调试信息
*/
function TextScroller(sourceID, divHEIGHT, speed, deubg_mode) {
    this._divHEIGHT = 50;                                                               //即将创建的容器高度
    this._sourceID = sourceID;                                                                  //源ID
    this._offHeight = document.getElementById(sourceID).scrollHeight;        //内容的高度 scrollHeight(内容实际高度) offsetHeight(可视区高度)
    this._sourceContent = document.getElementById(sourceID).innerHTML;
    this._content_div = "cnt" + sourceID;
    this._speed = 90;
    this._paused = false;
    this._deubg_mode = deubg_mode;

    if (undefined != divHEIGHT) this._divHEIGHT = divHEIGHT;
    if (undefined != speed) this._speed = speed;

    //创建对象
    this.go = function() {
        var _self = this;
        document.getElementById(sourceID).style.overflow = "hidden";
        document.getElementById(sourceID).style.position = "relative";
        document.getElementById(this._sourceID).innerHTML = "<div id='" + this._content_div + "'><div>" + this._sourceContent + "</div><div>" + this._sourceContent + "</div></div>";
        document.getElementById(this._content_div).style.position = "absolute";
        document.getElementById(this._content_div).style.top = "0px";
        document.getElementById(sourceID).style.height = "" + this._divHEIGHT + "px";

        document.getElementById(this._content_div).onmouseover = function() {
            _self._paused = true;
        };
        document.getElementById(this._content_div).onmouseout = function() {
            _self._paused = false;
        };


        //滚动控制：开始
        setInterval(function() {
            if (_self._paused) return;
            var top = parseInt(document.getElementById(_self._content_div).style.top);
            var nTop = top - 1;
            var ln = 0 - _self._offHeight; // (parseInt(_self._offHeight) * 2 - parseInt(_self._divHEIGHT));
            if (nTop < ln) nTop = 0;
            document.getElementById(_self._content_div).style.top = nTop;
            if (_self._deubg_mode != undefined) document.title = "top:" + nTop + "　contentHeight:" + _self._offHeight;
        }, this._speed);
        //滚动控制：结束

    }

    //开始
    this.go();
}



 


//图片播放
function SlidePlayer(Baseuri, Width) {
    this.objID = "ss" + ((new Date()).getTime() * 1000);
    this.width = Width == null ? "" : "width:" + Width + "px;";
    this._baseuri = Baseuri == null ? "." : Baseuri;
    this.imgs = new Array();
    this.pos = 0;
    var _this = this;
    this.push = function(img) { this.imgs.push(img); return this; }
    this.setText = function() {
        document.getElementById("{0}title".format(_this.objID)).innerText = "【{0}/{1}】点击图片播放下一张".format(
        _this.pos + 1, _this.imgs.length);

    }
    //开始播放
    this.start = function() {
        var htmlstr = "<center style='{4}'><img id='{0}' src='{2}/{1}' style='cursor:hand;border:0px;{3}' /><br ><span id='{0}title'></span></center>";
        document.write(htmlstr.format(
            this.objID, this.imgs[0], this._baseuri, this.width, "font-size:9pt;font-family:tahoma;")
        );
        this.setText();
        document.getElementById(this.objID).onclick = function() {
            _this.pos++;
            if (_this.pos >= _this.imgs.length) _this.pos = 0;
            document.getElementById(_this.objID).src = _this._baseuri + "/" + _this.imgs[_this.pos];
            _this.setText();

        };

    }

}



/**
* @classDescription 超级Marquee，可做图片导航，图片轮换
* @author Aken Li(www.kxbd.com)
* @date 2009-07-27
* @dependence jQuery 1.3.2
* @DOM
*  	<div id="marquee">
*  		<ul>
*   			<li></li>
*   			<li></li>
*  		</ul>
*  	</div>
* @CSS
*  	#marquee {width:200px;height:50px;overflow:hidden;}
* @Usage
*  	$('#marquee').kxbdSuperMarquee(options);
* @options
*		distance:200,//一次滚动的距离
*		duration:20,//缓动效果，单次移动时间，越小速度越快，为0时无缓动效果
*		time:5,//停顿时间，单位为秒
*		direction: 'left',//滚动方向，'left','right','up','down'
*		scrollAmount:1,//步长
*		scrollDelay:20//时长，单位为毫秒
*		isEqual:true,//所有滚动的元素长宽是否相等,true,false
*		loop: 0,//循环滚动次数，0时无限
*		btnGo:{left:'#goL',right:'#goR'},//控制方向的按钮ID，有四个属性left,right,up,down分别对应四个方向
*		eventGo:'click',//鼠标事件
*		controlBtn:{left:'#goL',right:'#goR'},//控制加速滚动的按钮ID，有四个属性left,right,up,down分别对应四个方向
*		newAmount:4,//加速滚动的步长
*		eventA:'mouseenter',//鼠标事件，加速
*		eventB:'mouseleave',//鼠标事件，原速
*		navId:'#marqueeNav', //导航容器ID，导航DOM:<ul><li>1</li><li>2</li><ul>,导航CSS:.navOn
*		eventNav:'click' //导航事件
*/
(function($) {

    $.fn.kxbdSuperMarquee = function(options) {
        var opts = $.extend({}, $.fn.kxbdSuperMarquee.defaults, options);

        return this.each(function() {
            var $marquee = $(this); //滚动元素容器
            var _scrollObj = $marquee.get(0); //滚动元素容器DOM
            var scrollW = $marquee.width(); //滚动元素容器的宽度
            var scrollH = $marquee.height(); //滚动元素容器的高度
            var $element = $marquee.children(); //滚动元素
            var $kids = $element.children(); //滚动子元素
            var scrollSize = 0; //滚动元素尺寸
            var _type = (opts.direction == 'left' || opts.direction == 'right') ? 1 : 0; //滚动类型，1左右，0上下
            var scrollId, rollId, isMove, marqueeId;
            var t, b, c, d, e; //滚动动画的参数,t:当前时间，b:开始的位置，c:改变的位置，d:持续的时间，e:结束的位置
            var _size, _len; //子元素的尺寸与个数
            var $nav, $navBtns;
            var arrPos = [];
            var numView = 0; //当前所看子元素
            var numRoll = 0; //轮换的次数
            var numMoved = 0; //已经移动的距离

            //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度
            $element.css(_type ? 'width' : 'height', 10000);
            //获取滚动元素的尺寸
            var navHtml = '<ul>';
            if (opts.isEqual) {
                _size = $kids[_type ? 'outerWidth' : 'outerHeight']();
                _len = $kids.length;
                scrollSize = _size * _len;
                for (var i = 0; i < _len; i++) {
                    arrPos.push(i * _size);
                    navHtml += '<li>' + (i + 1) + '</li>';
                }
            } else {
                $kids.each(function(i) {
                    arrPos.push(scrollSize);
                    scrollSize += $(this)[_type ? 'outerWidth' : 'outerHeight']();
                    navHtml += '<li>' + (i + 1) + '</li>';
                });
            }
            navHtml += '</ul>';

            //滚动元素总尺寸小于容器尺寸，不滚动
            if (scrollSize < (_type ? scrollW : scrollH)) return;
            //克隆滚动子元素将其插入到滚动元素后，并设定滚动元素宽度
            $element.append($kids.clone()).css(_type ? 'width' : 'height', scrollSize * 2);

            //轮换导航
            if (opts.navId) {
                $nav = $(opts.navId).append(navHtml).hover(stop, start);
                $navBtns = $('li', $nav);
                $navBtns.each(function(i) {
                    $(this).bind(opts.eventNav, function() {
                        if (isMove) return;
                        if (numView == i) return;
                        rollFunc(arrPos[i]);
                        $navBtns.eq(numView).removeClass('navOn');
                        numView = i;
                        $(this).addClass('navOn');
                    });
                });
                $navBtns.eq(numView).addClass('navOn');
            }

            //设定初始位置
            if (opts.direction == 'right' || opts.direction == 'down') {
                _scrollObj[_type ? 'scrollLeft' : 'scrollTop'] = scrollSize;
            } else {
                _scrollObj[_type ? 'scrollLeft' : 'scrollTop'] = 0;
            }

            if (opts.isMarquee) {
                //滚动开始
                //marqueeId = setInterval(scrollFunc, opts.scrollDelay);
                marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
                //鼠标划过停止滚动
                $marquee.hover(
					function() {
					    clearInterval(marqueeId);
					},
					function() {
					    //marqueeId = setInterval(scrollFunc, opts.scrollDelay);
					    clearInterval(marqueeId);
					    marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
					}
				);

                //控制加速运动
                if (opts.controlBtn) {
                    $.each(opts.controlBtn, function(i, val) {
                        $(val).bind(opts.eventA, function() {
                            opts.direction = i;
                            opts.oldAmount = opts.scrollAmount;
                            opts.scrollAmount = opts.newAmount;
                        }).bind(opts.eventB, function() {
                            opts.scrollAmount = opts.oldAmount;
                        });
                    });
                }
            } else {
                if (opts.isAuto) {
                    //轮换开始
                    start();

                    //鼠标划过停止轮换
                    $marquee.hover(stop, start);
                }

                //控制前后走
                if (opts.btnGo) {
                    $.each(opts.btnGo, function(i, val) {
                        $(val).bind(opts.eventGo, function() {
                            if (isMove == true) return;
                            opts.direction = i;
                            rollFunc();
                            if (opts.isAuto) {
                                stop();
                                start();
                            }
                        });
                    });
                }
            }

            function scrollFunc() {
                var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollLeft' : 'scrollTop';

                if (opts.isMarquee) {
                    if (opts.loop > 0) {
                        numMoved += opts.scrollAmount;
                        if (numMoved > scrollSize * opts.loop) {
                            _scrollObj[_dir] = 0;
                            return clearInterval(marqueeId);
                        }
                    }
                    var newPos = _scrollObj[_dir] + (opts.direction == 'left' || opts.direction == 'up' ? 1 : -1) * opts.scrollAmount;
                } else {
                    if (opts.duration) {
                        if (t++ < d) {
                            isMove = true;
                            var newPos = Math.ceil(easeOutQuad(t, b, c, d));
                            if (t == d) {
                                newPos = e;
                            }
                        } else {
                            newPos = e;
                            clearInterval(scrollId);
                            isMove = false;
                            return;
                        }
                    } else {
                        var newPos = e;
                        clearInterval(scrollId);
                    }
                }

                if (opts.direction == 'left' || opts.direction == 'up') {
                    if (newPos >= scrollSize) {
                        newPos -= scrollSize;
                    }
                } else {
                    if (newPos <= 0) {
                        newPos += scrollSize;
                    }
                }
                _scrollObj[_dir] = newPos;

                if (opts.isMarquee) {
                    marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
                } else if (t < d) {
                    if (scrollId) clearTimeout(scrollId);
                    scrollId = setTimeout(scrollFunc, opts.scrollDelay);
                } else {
                    isMove = false;
                }

            };

            function rollFunc(pPos) {
                isMove = true;
                var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollLeft' : 'scrollTop';
                var _neg = opts.direction == 'left' || opts.direction == 'up' ? 1 : -1;

                numRoll = numRoll + _neg;
                //得到当前所看元素序号并改变导航CSS
                if (pPos == undefined && opts.navId) {
                    $navBtns.eq(numView).removeClass('navOn');
                    numView += _neg;
                    if (numView >= _len) {
                        numView = 0;
                    } else if (numView < 0) {
                        numView = _len - 1;
                    }
                    $navBtns.eq(numView).addClass('navOn');
                    numRoll = numView;
                }

                var _temp = numRoll < 0 ? scrollSize : 0;
                t = 0;
                b = _scrollObj[_dir];
                //c=(pPos != undefined)?pPos:_neg*opts.distance;
                e = (pPos != undefined) ? pPos : _temp + (opts.distance * numRoll) % scrollSize;
                if (_neg == 1) {
                    if (e > b) {
                        c = e - b;
                    } else {
                        c = e + scrollSize - b;
                    }
                } else {
                    if (e > b) {
                        c = e - scrollSize - b;
                    } else {
                        c = e - b;
                    }
                }
                d = opts.duration;

                //scrollId = setInterval(scrollFunc, opts.scrollDelay);
                if (scrollId) clearTimeout(scrollId);
                scrollId = setTimeout(scrollFunc, opts.scrollDelay);
            }

            function start() {
                rollId = setInterval(function() {
                    rollFunc();
                }, opts.time * 1000);
            }
            function stop() {
                clearInterval(rollId);
            }

            function easeOutQuad(t, b, c, d) {
                return -c * (t /= d) * (t - 2) + b;
            }

            function easeOutQuint(t, b, c, d) {
                return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
            }

        });
    };
    $.fn.kxbdSuperMarquee.defaults = {
        isMarquee: false, //是否为Marquee
        isEqual: true, //所有滚动的元素长宽是否相等,true,false
        loop: 0, //循环滚动次数，0时无限
        newAmount: 3, //加速滚动的步长
        eventA: 'mousedown', //鼠标事件，加速
        eventB: 'mouseup', //鼠标事件，原速
        isAuto: true, //是否自动轮换
        time: 5, //停顿时间，单位为秒
        duration: 50, //缓动效果，单次移动时间，越小速度越快，为0时无缓动效果
        eventGo: 'click', //鼠标事件，向前向后走
        direction: 'left', //滚动方向，'left','right','up','down'
        scrollAmount: 1, //步长
        scrollDelay: 10, //时长
        eventNav: 'click'//导航事件
    };

    $.fn.kxbdSuperMarquee.setDefaults = function(settings) {
        $.extend($.fn.kxbdSuperMarquee.defaults, settings);
    };

})(jQuery);


function FtMarquee(ElementID, ItemWidth, directionType, btnGosJson) {
    $('#' + ElementID).kxbdSuperMarquee({
        distance: ItemWidth == null ? 200 : ItemWidth,
        time: 3,
        btnGo: btnGosJson == null ? { left: '#goL', right: '#goR'} : btnGosJson,
        direction: directionType == null ? 'right' : directionType
    });
}











function PagedElementV2(matchExp, sButtonsID, pageSize, fnCallback) {
    this.mExp = matchExp;
    this.mButtonsID = sButtonsID;
    this.mPageSize = (pageSize == null ? 5 : pageSize);
    this.mItemCount = 0;
    this.mPageCount = 0;
    this.mCallback = fnCallback;
    this.lastPos = -1; //上次显示的页，未使用
    this.InitParam = function () {
        //计算子无素数量
        var _temp_c = 0;
        $(this.mExp).each(function () { _temp_c++; });
        this.mItemCount = _temp_c;
        if (this.mItemCount == 0) return;
        //计算页码
        this.mPageCount = parseInt(this.mItemCount / this.mPageSize);
        if (this.mItemCount % this.mPageSize > 0) this.mPageCount++;
        //全部隐藏
        $(this.mExp).hide();
    };
    this.InitPageButton = function (p) {
        //if (document.getElementById(this.mButtonsID) == null) return; 
        var bid = String.format("#{0}", this.mButtonsID);
        if (($(bid)).length == 0) { alert("分页容器元素未指定或未找到!"); return; }
        for (var i = 1; i <= this.mPageCount; i++) {
            var button = document.createElement("input");
            $(button).attr("type", "button");
            $(button).attr("rel", i);
            $(button).attr("value", i);
            $(button).toggleClass("selected", (i == p));
            var _this = this;
            var pos = i;
            $(button).click(function () {
                var value = parseInt($(this).attr("rel"));
                _this.ShowPage(value); //if (_this.mCallback != null) _this.mCallback(value);
            });
            $(bid).append(button);
        }
    }
    this.ShowPage = function (pos) {
        if (this.mItemCount == 0) return;
        //显示此页
        var _begin = (pos - 1) * this.mPageSize;
        var _end = _begin + this.mPageSize - 1;
        if (_end >= (this.mItemCount)) _end = this.mItemCount;

        var _temp_c = 0;
        $(this.mExp).each(function () {
            var vis = ((_temp_c >= _begin) && (_temp_c <= _end));
            if (vis)
                $(this).fadeIn();
            else {
                if ($(this).css("display") != "none") $(this).hide();
            }
            _temp_c++;
        });
        var pghtml = String.format("<!--{0}~{1}-->", _begin, _end);
        var bid = String.format("#{0}", this.mButtonsID);
        $(bid).html(pghtml);
        this.InitPageButton(pos);
        this.lastPos = pos; //上次显示的页
        if (this.mCallback != null) this.mCallback(pos);
    };
    this.InitParam();
}


/*   对UL对象实现分页处理
sID:        源UL的ID
sButtonsID: 按钮所在的容器ID,默认为pages
pageSize:   每页长度，默认为10
childExp:   匹配子元素的表达式，默认为匹配所有LI
*/
function PagedElement(sID, sButtonsID, pageSize, childExp,fnCallback) {
    if (childExp == null) childExp = /<li(.+?)<\/li>/igm;
    this._items = $("#" + sID).html().match(childExp);
    this._sourceID = sID;
    this._sButtonsID = (sButtonsID == null ? "pages" : sButtonsID);
    this._pageSize = (pageSize == null ? 10 : pageSize);
    this._pageCount = 1;
    //计算页数 
    if (this._pageSize > 0) this._pageCount = this._items.length / this._pageSize;
    if (this._items.length % this._pageSize > 0) this._pageCount++;
    //转到某页
    this.ShowPage = function (p) {
        var s = (p - 1) * this._pageSize;
        var e = s + this._pageSize;
        if (e > this._items.length - 1) e = this._items.length - 1;
        var htmls = "";
        for (var i = s; i <= e; i++) htmls += this._items[i];
        $("#" + this._sourceID).html(htmls);
        this.ShowPageNums(p);
        if (fnCallback != null) fnCallback();
    }
    //生成页码
    this.ShowPageNums = function (p) {
        if (document.getElementById(this._sButtonsID) == null) {
            //alert("PagedUL生成分页失败：ID为'" + this._pageSize + "'的元素不存在");
            return;
        }
        $("#" + this._sButtonsID).html("");
        for (var i = 1; i <= this._pageCount; i++) {
            var button = document.createElement("input");
            if (i == p) {
                button.setAttribute("className", "selected"); //Int
                button.setAttribute("class", "selected"); //Int
            }
            button.setAttribute("type", "button");
            button.setAttribute("value", i);
            button.setAttribute("rel", i);
            var _this = this;
            button.onclick = function () { _this.ShowPage(this.rel); }
            document.getElementById(this._sButtonsID).appendChild(button);
        }

    }
}
//var page = new PagedElement("NL", "pages", 20);
//page.ShowPage(1);




//将对象设为标签页(tabsID:对象id,clickMode:点击模式) 窗口中带tHead类的为标签按钮,tPage为标签页
function MakeTabView(tabsID, clickMode, fnCallback, PlayTime) {
    //统计标签数量
    var _total = 0;
    var _style = " margin:0px;padding:0px;list-style-type:none;list-style-position:outside;display:inline;";
    $("#" + tabsID + " .tHead li").each(function () {
        this.setAttribute("style", _style);
        _total++
    });
    var ulid = "#" + tabsID + " ul.tabHead";
    $(ulid).css("cursor", "hand");
    $(ulid).css("margin", "0px");
    $(ulid).css("padding", "0px");
    $(ulid).css("padding-left", "5px");
    $(ulid).css("list-style-type", "none");
    $(ulid).css("list-style-position", "outside");


    var _pos_i = 0;
    //指定标签页顺序(IE9下会有兼容问题) 
    $("#" + tabsID + " .tPage").each(function () { this.setAttribute("_page_order", _pos_i); _pos_i++; });
    //绑定标签按钮事件
    _pos_i = 0;
    $("#" + tabsID + " .tHead li").each(function () {
        var _pos = _pos_i;
        if (clickMode == true)
            this.onclick = function () {
                TabViewSwitch(tabsID, _pos, _total);
                if (fnCallback != null) fnCallback(_pos);
                return false;
            }
        else
            this.onmouseover = function () {
                TabViewSwitch(tabsID, _pos, _total);
                if (fnCallback != null) fnCallback(_pos);
                return false;
            }
        _pos_i++;
    });
    TabViewSwitch(tabsID, 0, _total);
    if ((PlayTime != null) && (PlayTime > 0)) PlayTab(tabsID, PlayTime);
}

//切换
function TabViewSwitch(tabsID, index, max) {
    //window.status = (tabsID + "," + index + "," + max);
    var _pos_i = 0;
    $(String.format("#{0} .tHead li", tabsID)).each(function () {
        this.visibility = "hidden"; //让它隐藏再显示，解决ie8下不自动重绘的问题
        $(this).toggleClass("selected", index == _pos_i);
        //this.setAttribute("class", index == _pos_i ? "selected" : "");
        //this.setAttribute("className", index == _pos_i ? "selected" : "");
        this.visibility = "visibility";
        _pos_i++;
    });  
    _pos_i = 0;
    $(String.format("#{0} .tPage", tabsID)).each(function () {
        if (_pos_i == index)
            $(this).fadeIn('slow');
        else
            $(this).fadeOut('slow');
        //this.style.display = (_pos_i == index ? "" : "none");
        _pos_i++;
    });

    

}
//Tab页播放
function PlayTab(tabID, TimeSpan) {
    var tb = new TabPlayer(tabID, TimeSpan);
}
function TabPlayer(tabID, TimeSpan) {
    this._TabID = tabID;
    this._TabCount = 0;
    this.GetPos = function () {
        var _i = 0;
        var _sel = -1;
        $("#" + this._TabID + " .tHead li").each(function () {
            if (_sel > -1) return;
            if ($(this).hasClass("selected")) _sel = _i;
            //if (this.getAttribute("class").indexOf("selected") > -1) _sel = _i;
            //if (this.getAttribute("className").indexOf("selected") > -1) _sel = _i;
            _i++;
        });
        return _sel;
    }
    this.PlayNext = function () {
        var pos = this.GetPos() + 1;
        if (pos >= this._TabCount) pos = 0;
        TabViewSwitch(this._TabID, pos, this._TabCount);
    }
    this._Init = function () {
        var _i = 0;
        $("#" + this._TabID + " .tHead li").each(function () { _i++; });
        this._TabCount = _i;

        var _this = this;
        setInterval(function () {
            _this.PlayNext();
        }, TimeSpan == null ? 4000 : TimeSpan);
    }
    this._Init();
}
 


//上传文件，并设置指定控件的值.targetID为要设置值的控件
function AjaxUpload(targetID, callback) {
    var u = "/Member/UploadFunc/" + targetID + "?" + (new Date()).getTime();
    var v = window.showModalDialog(u, null, "dialogHeight:90px;dialogWidth:330px;scroll:no;");
    if (v != null) {
        if (targetID != null) $("#" + targetID).attr("value", v);
        if (callback != null) callback(v);
    }
    return false;
}


function SetFckValue(objID) {
    var _htm = FCKeditorAPI.GetInstance(objID).GetXHTML();
    $("#" + objID).val(_htm);
    return true;
}





function mousePosition(ev) {
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    } return { x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
        y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}

function StartPreView(jqSelector,previewHtml) {
    var pvid = "#sys_pv_window";
    //创建窗口
    if (document.getElementById("sys_pv_window")==null) {
        var pvwin = document.createElement("span");
        pvwin.setAttribute("id", "sys_pv_window");
        pvwin.setAttribute("alt", "yes");
        document.body.appendChild(pvwin);
        //初始属性 
        $(pvid).css("position", "absolute");
        $(pvid).css("display", "block");
        $(pvid).css("margin", "0px");
        $(pvid).css("padding", "0px");
        $(pvid).css("top", "5px");
        $(pvid).css("left", "5px");
        $(pvid).css("text-align", "left");
        $(pvid).css("z-index", "9999");
        //$(pvid).css("border", "1px solid #FAFAFA"); 
    }
    //事件绑定
    $(jqSelector).mouseover(function (ev) {
        ev = ev || window.event;
        var mousePos = mousePosition(ev);

        $(pvid).css("top", mousePos.y + 5);
        $(pvid).css("left", mousePos.x + 5);
        window.status = $(pvid).css("left") + ":" + $(pvid).css("top");
        if (previewHtml == null) previewHtml = "<img src='{0}' style='width:300px' />";
        $(pvid).html(String.format(previewHtml, this.src));
        $(pvid).fadeTo('slow', 0.9);
    }).mouseleave(function () { $(pvid).hide(); });
}



//网页弹出层
var jcDivInited = false;
function PopupContent(digContentSelector, NoClose) {
    var h = $(document).height();
    var w = $(document).width();
    //初始化
    if (!jcDivInited) {
        jcDivInited = true;
        $("body").append("<div id='jcMask' style='z-index:9991;background:#000000;position:absolute;left:0px;top:0px;width:100%;height:100%;overflow:hidden;filter:alpha(style=0,opacity=50);opacity:0.5;display:none;' title=''></div>");
        $("body").append("<div id='jcDialog' style='z-index:9991;background:#FFFFFF;border:0px solid #283C52;position:absolute;left:0px;top:0px;overflow:hidden;filter:alpha(style=0,opacity=90);opacity:0.9;display:none;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; '></div>");
        $("#jcMask").css("height", h);
        if (NoClose != true) {
            $("#jcMask").click(ClosePopupContent);
            $("#jcMask").attr('title', '点击此空白处关闭对话框');
        }
    }
    $(digContentSelector).appendTo($("#jcDialog"));
    $("#jcMask").fadeIn(100);
    $("#jcDialog").css("top", 80 + document.documentElement.scrollTop);
    $("#jcDialog").css("left", (w - $("#jcDialog").width()) / 2);
    $("#jcDialog").fadeIn(100);
}
function ClosePopupContent() {
    $("#jcDialog").fadeOut(100, function () {
        $("#jcMask").fadeOut(100);
    });
}


