﻿/**
* description: BaoZang.com,Online
* author : hn-man@live.cn
* version: 1.0.10.0810
*/
Object.extend = function(destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
    return destination;
}
var Class={
	create:function(){
		return function()  {this.ini.apply(this,arguments);}
    }
}
/*
* StringBuilder
*/
if (typeof StringBuilder == "undefined" || !window.StringBuilder) {
    var StringBuilder = function(){
        this.cache = [];
        if(arguments.length)this.append.apply(this,arguments);
    }
}
StringBuilder.prototype = {
    prepend : function(){
        this.cache.splice.apply(this.cache,[].concat.apply([0,0],arguments));
        return this;
    },
    append : function(){
        this.cache = this.cache.concat.apply(this.cache,arguments);
        return this;
    },
    toString : function(){
        return this.getString();
    },
    getString : function(){
        return this.cache.join('');    
    }
}
String.prototype.stripTags= function () {return this.replace(/<\/?[^>]+>/gi, '');}; // 删除标签  
// html编码    
String.prototype.escapeHTML= function () {
    var oDiv = document.createElement('div');
    var oText = document.createTextNode(this);
    oDiv.appendChild(oText);
    return oDiv.innerHTML;
};   
// html解码   
String.prototype.unescapeHTML     = function () {
    var oDiv = document.createElement('div');
    oDiv.innerHTML = this.stripTags();
    return oDiv.childNodes[0].nodeValue;
};    
// html编码
String.prototype.encodeHTML		  = function () {
    var s = this;
	s = s.replace(/\&/gi,"&amp;");
	s = s.replace(/</gi,"&lt;");
	s = s.replace(/>/gi,"&gt;");
	s = s.replace(/\"/gi,"&quot;");
	return s;
}; 
// html解码   
String.prototype.decodeHTML		  = function () {
    var s = this;
	s = s.replace(/&lt;/gi,"<");
	s = s.replace(/&gt;/gi,">");
	s = s.replace(/&quot;/gi,"\"");
	s = s.replace(/&amp;/gi,"&");
	s = s.replace(/&nbsp;/gi," ");
	return s;
};    
// url＆html解码
String.prototype.usc_hdc = function() {
    return unescape(this.unescapeHTML());
};
// 删除字符串两边的空格         
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
};
// 删除左边的空格           
String.prototype.ltrim = function() {
    return this.replace(/(^\s*)/g, "");
};
// 删除右边的空格         
String.prototype.rtrim = function() {
    return this.replace(/(\s*$)/g, "");
};
// 字符串的长度,可以检查中文      
String.prototype.len = function() {
    var nCNLenth = 0;
    var nLenth = this.length;
    for (var i = 0; i < nLenth; i++) {
        if (this.charCodeAt(i) > 255) {
            nCNLenth += 2;
        } else {
            nCNLenth++;
        }
    }
    return nCNLenth;
};  
// 截取左边数起第几个字符,截取后用...代替         
String.prototype.left = function() {
    var i = 0,
        j = 0;
    if (this.len() <= nLen) {
        return this;
    }
    while (j < nLen) {
        if (this.charCodeAt(i) > 255) {
            j += 2;
        } else {
            j++;
        }
        i++;
    }
    return this.substring(0, i) + "..";
};
// 判断是否为数字
String.prototype.isNumeric = function () {
    var objExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    return objExp.test(this.toString()); 
}

/*
* contains the js loader
*/
var JsLoader = Class.create();
Object.extend(JsLoader, {
    load: function(sUrl, fCallback){
		var _script = document.createElement('script');
		_script.setAttribute('type', 'text/javascript');
		_script.setAttribute('src', sUrl);
		document.getElementsByTagName('head')[0].appendChild(_script);
		if ($.browser.msie){
		    _script.onreadystatechange = function(){if (this.readyState=='loaded' || this.readyState=='complete'){fCallback();}}
		}else if ($.browser.mozilla){
		    _script.onload = function(){fCallback();}
		}else{fCallback();}
	}
});          
/** 
* extension of JSON, type for jQuery 
* AUTHOR: xushengs@gmail.com 
* LICENSE: http://www.opensource.org/licenses/mit-license.php 
* WEBSITE: http://ooboy.net/ 
*/ 
(function($) { 
    // the code of this function is from  
    // http://lucassmith.name/pub/typeof.html 
    $.type = function(o) { 
        var _toS = Object.prototype.toString; 
        var _types = { 
            'undefined': 'undefined', 
            'number': 'number', 
            'boolean': 'boolean', 
            'string': 'string', 
            '[object Function]': 'function', 
            '[object RegExp]': 'regexp', 
            '[object Array]': 'array', 
            '[object Date]': 'date', 
            '[object Error]': 'error' 
        }; 
        return _types[typeof o] || _types[_toS.call(o)] || (o ? 'object' : 'null'); 
    }; 
    // the code of these two functions is from mootools 
    // http://mootools.net 
    var $specialChars = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }; 
    var $replaceChars = function(chr) { 
        return $specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16); 
    }; 
    $.toJSON = function(o) { 
        var s = []; 
        switch ($.type(o)) { 
            case 'undefined': 
                return 'undefined'; 
                break; 
            case 'null': 
                return 'null'; 
                break; 
            case 'number': 
            case 'boolean': 
            case 'date': 
            case 'function': 
                return o.toString(); 
                break; 
            case 'string': 
                return '"' + o.replace(/[\x00-\x1f\\"]/g, $replaceChars) + '"'; 
                break; 
            case 'array': 
                for (var i = 0, l = o.length; i < l; i++) { 
                    s.push($.toJSON(o[i])); 
                } 
                return '[' + s.join(',') + ']'; 
                break; 
            case 'error': 
            case 'object': 
                for (var p in o) { 
                    s.push(p + ':' + $.toJSON(o[p])); 
                } 
                return '{' + s.join(',') + '}'; 
                break; 
            default: 
                return ''; 
                break; 
        } 
    }; 
    $.evalJSON = function(s) { 
        if ($.type(s) != 'string' || !s.length) return null; 
        return eval('(' + s + ')'); 
    }; 
})(jQuery);

/*
 * 公共函数
 */
var app = Class.create();
Object.extend(app,{
    QueryString : function (paras){
	    var url = location.href;  
	    var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");  
	    var paraObj = {};  
	    for (i=0; j=paraString[i]; i++){  
		    paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);  
	    }  
	    var returnValue = paraObj[paras.toLowerCase()];  
	    if(typeof(returnValue)=="undefined"){  
		    return ""; 
	    }else{  
		    return returnValue;  
	    }
    }
});

/*
 * 用户
 */
var User = Class.create();
Object.extend(User,{
    PostDir : "/Common/Ashx/user/",
    ajaxPost: null,
    /// <summary>
    /// 登陆栏
    /// </summary>
    topbar:{
        notin : '<a href="javascript:;" onclick="User.OnPopLog()">登录</a> | <a href="http://my.baozang.com/signup/">注册</a>',
        hasin : '<span><a href="http://my.baozang.com/" title="进入我的用户中心">欢迎 {userid}, 进入我的用户中心 </a> <a href="javascript:void(0)" onclick="User.SingOut();">注销</a></span>',
        loading:'loading...'
    },
    /// <summary>
    /// 检查是否已经登陆
    /// </summary>
    isSingIn : function () {
        $("#sign").html(User.topbar.loading);
        $.ajax({
            url: User.PostDir+ "checkSign.ashx?n=" + Math.random(),
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                //alert(XMLHttpRequest.responseText);
                $("#sign").html(User.topbar.notin);
            },
            success: function(JsonData) {
                var json = $.evalJSON(JsonData)
                if (json.success == 1) {
                    $("#sign").html(User.topbar.hasin.replace("{userid}",json.BzUID));
                }
                else
                {
                    $("#sign").html(User.topbar.notin);
                }
            }
        });
    },
    /// <summary>
    /// 登陆
    /// </summary>
    /// <param name="options">Post的用户登陆数据{uin,upwd}</param>
    SingIn : function () {
       //alert(User.OnValid());
        if(User.OnValid()){
            $(".loading").show();
            User.ajaxPost =$.ajax({
                url:  User.PostDir+ "signin.ashx?n=" + Math.random(),
                async: true,
                type: "POST",
                data: { username: $("#unpop").val(), password: $("#pswpop").val() },
                complete: function() {
                    $(".loading").hide();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    $("#sign").html(User.topbar.notin);
                    alert(XMLHttpRequest.responseText);
                },
                success: function(resTxt) {
                    var json = $.evalJSON(resTxt);
                    if (resTxt == "" || resTxt.length == 0 || resTxt == null) {
                        alert("登录请求已取消");
                        return;
                    }
                    if (json.success == 1) {
                        $("#sign").html(User.topbar.hasin.replace("{userid}",json.BzUID));
                        $("#popLogin").find(".text").val("");
                        $("#cover2, #popLogin, .loading").hide();
                        $.cookie('uin', json.BzUID, { expires: 7, path: '/', domain: 'baozang.com', secure: false });
                    }
                    else {
                        alert(json.err);
                        $("#sign").html(User.topbar.notin);
                    }
                }
            });
        }

    },
    /// <summary>
    /// 退出
    /// </summary>
    SingOut : function (options) {
        $("#sign").html(User.topbar.loading);
        $.ajax({
            url: User.PostDir+"signout.ashx?n=" + Math.random(),
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.responseText);
            },
            success: function(rssTxt) {
                if (rssTxt == "1") {
                    setTimeout(function(){
                        $("#sign").html(User.topbar.notin);
                    },50);
                }
                else {
                    alert("注销失败,请重试");
                }
            }
        });
    },
    
    OnPopLog: function(){
        var pageW = document.body.clientWidth;
        var pageH = document.body.clientHeight;
        var winW = $(window).width();
        var winH = $(window).height();
        var scrlL = $(document).scrollLeft();
        var scrlT = $(document).scrollTop();
        
        $("#cover2").css({
            "width":pageW,
            "height":pageH,
            "opacity": "0.5"
        }).show();
        
        $("#popLogin").css({
            "top":"150px",
            "left":parseInt((winW-$("#popLogin").width())/2)
        }).show();
        
        $(window).bind("resize scroll", function(){
            pageW = document.body.clientWidth;
            pageH = document.body.clientHeight;
            winW = $(window).width();
            winH = $(window).height();
            scrlL = $(document).scrollLeft();
            scrlT = $(document).scrollTop();
            
            $("#cover2").css({
                "width":pageW+scrlL,
                "height":pageH,
                "opacity": "0.5"
            });
            
            if(winH>($("#popLogin").height()+150)){
                $("#popLogin").css({
                    "top":parseInt(scrlT)+150,
                    "left":parseInt((winW-$("#popLogin").width())/2)
                });
            }else if(winH>($("#popLogin").height())){
                $("#popLogin").css({
                    "top":parseInt(scrlT)+(winH-parseInt($("#popLogin").height()))/2,
                    "left":parseInt((winW-$("#popLogin").width())/2)
                });
            }else{
                $("#popLogin").css({
                    "top":parseInt(scrlT),
                    "left":parseInt((winW-$("#popLogin").width())/2)
                });
            }
        });
        
        $(".cls, #cover2").click(function(){
            if(User.ajaxPost){
                User.ajaxPost.abort();
            }
            $("#popLogin").find(".text").val("");
            $("#cover2, #popLogin, .loading").hide();
        });
        
        return false;
        
    },
    
    OnValid: function () {
        var usn = $("#unpop").val().trim();
        var psw = $("#pswpop").val().trim();
        if (usn == "" || psw == "") {
            alert("用户名或密码不能为空!");
            return false;
        }
        return true;
    }
});
// 拍卖数据
var Auction = Class.create();
Object.extend(Auction,{
    PostDir : "Common/Ashx/Auction/",
    /// <summary>
    /// 索引列表 
    /// </summary>
    /// <param name="selector">筛选容器</param>
    Index : function (selector) {
        $.getJSON(this.PostDir + "Category.Index.ashx?n=" + Math.random(), function(JosnData){
            var shtml=new StringBuilder();
            $(JosnData).each(function(i,item){
                shtml.append('<p><b>按'+item.NAME+'：</b> ');
                if(item.CHILDREN.length>0){
                    $.each(item.CHILDREN, function (n,data) {
                        shtml.append('<a href="http://auction.baozang.com/?id=' + data.ID + '" title="'+data.NAME+'" onclick="pStat.ACI('+data.ID+')">' + data.NAME + '</a> ');
                    })
                    shtml.append('<a href="#">更多&nbsp;&raquo;</a>');
                }
                else
                {
                    shtml.append('<a href="javascript:void(0)">暂无划分子类</a>');
                }
                shtml.append('</p>');
            });
            $(selector).html(shtml.toString());
        });
    },
    /// <summary>
    /// 首页的数据列表 
    /// </summary>
    /// <param name="options">操作对象
    /// options:
    ///     selector:筛选器
    ///     query : 条件
    ///     cin:    -1过滤,1大陆,0为海外
    ///     size:   条数
    /// </param>
    DefDataList: function(options) {
        $(options).each(function (index,item) {
            $.ajax({
                url: "Common/Ashx/Auction/Def.NewList.ashx?n=" + Math.random(),
                type: 'POST',
                data: {
                     query:  item.query,
                     cin:    item.cin,
                     size:   item.size
                },
                beforeSend: function() {
                    
                },
                complete: function() {

                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    $(item.selector + " tbody").html(textStatus + "\n" + errorThrown + "服务器错误");
                },
                success: function(JsonTxt) {
                    if (JsonTxt == "") return;
                    var JsonData = null;
                    try {
                        JsonData = $.evalJSON(JsonTxt);
                    } catch(ex) {
                        $(item.selector + " tbody").html(ex.description);
                        return;
                    }
                    var tRow = new StringBuilder();
                    $.each(JsonData,function (i,json) {
                        var classname=(json.ISSEVENT=="1")?' class="red-hot"':'';
                        tRow.append('<tr'+classname+'>');
                        tRow.append('    <td class="strong">'+json.COMPANY+'</td>');
                        tRow.append('    <td><a href="http://auction.baozang.com/subject,'+json.ID+'.html">'+json.AUCTION+'</a></td>');
                        tRow.append('    <td>'+json.DATE+'</td>');
                        tRow.append('    <td>'+json.CITY+'</td>');
                        tRow.append('    <td>'+json.STATE+'</td>');
                        tRow.append('    <td>'+json.CPRICE+'</td>');
                        tRow.append('</tr>');
                    });
                    $(item.selector + " tbody").html(tRow.toString());
                    $(item.selector).tablesorter();
                }
            });
        });
    }
});
/// <summary>
/// 交易商品类
/// </summary>
var Product = Class.create();
Object.extend(Product,{
    BaseDir : "Common/Ashx/Mall/",
    MallDir : "http://mall.baozang.com/list/",
    Index : function(selector) {
        $.getJSON(this.BaseDir + "Product.Category.ashx?n=" + Math.random(), function(Data){
            var shtml = new StringBuilder();
            $(Data).each(function(i,item){
                shtml.append('<p><b>'+item.SortName+'</b>');
                if(item.ChildernNode.length>0){
                    $.each(item.ChildernNode, function(n,obj){
                        if(n!=0){
                            shtml.append(' |');
                        }
                        shtml.append(' <a href="'+Product.MallDir+obj.SortID+'_1.aspx">'+obj.SortName+'</a>');
                    });
                }else{
                    shtml.append('<a href="javascript:void(0)">暂无划分子类</a>');
                }
                shtml.append('</p>');
            });
            shtml.append('<p><b>按价格查看</b> <a href="http://mall.baozang.com/s_0_%E5%B9%B4%E4%BB%A3__%E4%BD%9C%E8%80%85%E6%88%96%E8%97%8F%E5%93%81%E5%90%8D_1_1.aspx">1-1000元</a> <a href="http://mall.baozang.com/s_0_%e5%b9%b4%e4%bb%a3__%e4%bd%9c%e8%80%85%e6%88%96%e8%97%8f%e5%93%81%e5%90%8d_2_1.aspx">1001-5000元</a> <a href="http://mall.baozang.com/s_0_%e5%b9%b4%e4%bb%a3__%e4%bd%9c%e8%80%85%e6%88%96%e8%97%8f%e5%93%81%e5%90%8d_3_1.aspx">5001-10000元</a> <a href="http://mall.baozang.com/s_0_%e5%b9%b4%e4%bb%a3__%e4%bd%9c%e8%80%85%e6%88%96%e8%97%8f%e5%93%81%e5%90%8d_4_1.aspx">10000元以上</a></p>');
            $(selector).html(shtml.toString());
        });
    },
    /// <summary>
    /// 交易列表
    /// </summary>
    DefDataList : function (_size) {
		$.ajax({
            url: this.BaseDir + "Product.List.ashx?n=" + Math.random(),
            type: 'POST',
            data: {size:_size},
            beforeSend: function() {
                
            },
            complete: function() {

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                //$(item.selector + " tbody").html(textStatus + "\n" + errorThrown + "服务器错误");
            },
            success: function(JsonTxt) {
                if (JsonTxt == "") return;
                var JsonData = null;
                try {
					JsonData = $.evalJSON(JsonTxt);
                } catch(ex) {
                    $(item.selector + " tbody").html(ex.description);
                    return;
                }
                var tRow = new StringBuilder();
                tRow.append('<span class="blank_w100h8"></span>');
                $.each(JsonData,function (i,json) {
                    tRow.append('<div class="picWrapper">');
                    tRow.append('	<a href=\"http://mall.baozang.com/detail/'+json.ID+'.aspx\" class=\"imgWrap\">');
                    tRow.append('	<img src="http://mall.baozang.com/upload/image'+json.Img+'" alt="'+json.Name+'" /></a> ');
                    tRow.append('	<a href="http://mall.baozang.com/detail/'+json.ID+'.aspx">');
                    tRow.append('	'+json.Author+' '+json.Name+'');
                    tRow.append('	<p>编号：B002'+json.ID+'</p>');
                    tRow.append('	<p>价格：'+json.Price+'</p>');
                    tRow.append('	</a>');
                    tRow.append('</div>');
                });
                tRow.append('<div class="c"></div>');
                $("#MallList").html(tRow.toString());
            }
        });
    }

});

/// <summary>
/// 宝藏
/// </summary>
var Bz=Class.create();
Object.extend(Bz,{
    showOption : function (obj, wrap){
	    var opt = $(obj).html();
	    $('#'+ wrap).html(opt);
	    $("#category").val(opt);
	    $(obj).parent().parent().hide();
	    $("#globel_search").attr("action", $(obj).attr("rel"));	
	},
	// 幻灯片
    playShow : function () {
		$("#play_list a:not(:first-child)").hide();
		$("#play_info").html($("#play_list a:first-child").find("img").attr('alt'));
		$("#play_text li:first-child").css({"background":"#fff",'color':'#000'});
		$("#play_info").click(function(){window.open($("#play_list a:first-child").attr('href'), "_blank")});
		$("#play_text li").click(function() {
		    clearInterval(t);
			var i = $(this).text() - 1;
			n = i;
			if (i >= count) return;
			$("#play_info").html($("#play_list a").eq(i).find("img").attr('alt'));
			$("#play_info").unbind().click(function(){window.open($("#play_list a").eq(i).attr('href'), "_blank")})
			$("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
			$(this).css({"background":"#fff",'color':'#000'}).siblings().css({"background":"#000",'color':'#fff'});
			t = setInterval("Bz.playAuto()", 4000);
		});
		t = setInterval("Bz.playAuto()", 4000);
		$("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("Bz.playAuto()", 4000);});
    },
    // 幻灯片播放
    playAuto : function () {
		n = n >= (count - 1) ? 0 : ++n;
		$("#play_text li").eq(n).trigger('click');
    },
	/// <summary>
    /// 搜索
    /// </summary>
	clickSubmit : function () {
		var keys=$("#k").val();
		if( keys=="请输入关键字" || keys=="" ){
			alert("请输入关键字!");
			return false;
		}
		return true;
	}
});

// 期刊滚动封装类
var scrollClass=(function () {
    var scrollOffset=0;
    return {
        //点击方向按钮左右滚动
        scrolls : function (wrapper, content, offset, sumNum, showNum, direct){
 		    if(direct=="left"&&scrollOffset<=0&&scrollOffset>(-(sumNum-showNum)*offset)){
 			    scrollOffset -= offset;
 			    $(content).animate({left:scrollOffset+"px"}, 1000);
 		    }else if(direct=="right"&&scrollOffset<0&&scrollOffset>=(-(sumNum-showNum+1)*offset)){
 			    scrollOffset += offset;
 			    $(content).animate({left:scrollOffset+"px"}, 1000);
 		    }
 	    }	
    };
})();
var mScroll=Class.create();
Object.extend(mScroll,{
    settings : {
        peed : 10,      
        Space : 5,      
        Offset : 115,   //Item宽度
        fill : 0,       //整体移位
        MoveLock : false,
        MoveTimeObj:0,
        Comp : 0,
        AutoPlayObj : null,
        isAutoPlay : true,
        ScrContoObj : "",   //翻滚区域
        ContListObj : "",   //翻滚内容
        _ContListObj: ""   //备份内容
    },
    Init : function (options) {
        jQuery.extend(this.settings, options);
        $("#"+this.settings._ContListObj).html($("#"+this.settings.ContListObj).html());
        $("#"+this.settings.ScrContoObj).scrollLeft(this.settings.fill)
            .hover(function () {clearInterval(mScroll.settings.AutoPlayObj);},function () {mScroll.AutoPlay();});
        $("#"+this.settings.ContListObj+" img").hover(
            function () {
                $(this).addClass("action");
                $(this).css({"width":"106px","height":"138px"});
            },
            function () {
                $(this).removeClass("action");
                $(this).css({"width":"96px","height":"128px"});
            }
        );
        $("#"+this.settings._ContListObj+" img").hover(
            function () {
                $(this).addClass("action");
                $(this).css({"width":"106px","height":"138px"});
            },
            function () {
                $(this).removeClass("action");
                $(this).css({"width":"96px","height":"128px"});
            }
        );
        mScroll.AutoPlay();
    },
     //自动滚动
    AutoPlay : function (){
        if(!mScroll.settings.isAutoPlay) return;
        clearInterval(mScroll.settings.AutoPlayObj);
        mScroll.settings.AutoPlayObj = setInterval('mScroll.GoDown();mScroll.StopDown();',5000); //间隔时间
    },
    //上翻开始
    GoUp : function (){ 
        if(mScroll.settings.MoveLock) return;
        clearInterval(mScroll.settings.AutoPlayObj);
        mScroll.settings.MoveLock = true;
        mScroll.settings.MoveTimeObj = setInterval('mScroll.ScrUp();',mScroll.settings.Speed);
    },
    //上翻停止
    StopUp : function (){ 
        clearInterval(mScroll.settings.MoveTimeObj);
        if($("#"+mScroll.settings.ScrContoObj).scrollLeft() % mScroll.settings.Offset - mScroll.settings.fill != 0){
            mScroll.settings.Comp = mScroll.settings.fill - ($("#"+mScroll.settings.ScrContoObj).scrollLeft() % mScroll.settings.Offset);
            mScroll.CompScr();
        }else{
            mScroll.settings.MoveLock = false;
        }
        mScroll.AutoPlay();
    },
    //上翻动作
    ScrUp : function (){ 
        if($("#"+mScroll.settings.ScrContoObj).scrollLeft()<= 0){
            $("#"+mScroll.settings.ScrContoObj).scrollLeft($("#"+mScroll.settings.ScrContoObj).scrollLeft() + document.getElementById(mScroll.settings.ContListObj).offsetWidth);
        }
        document.getElementById(mScroll.settings.ScrContoObj).scrollLeft -= mScroll.settings.Space ;
    },
    //下翻
    GoDown : function (){ 
        clearInterval(mScroll.settings.MoveTimeObj);
        if(mScroll.settings.MoveLock) return;
        clearInterval(mScroll.settings.AutoPlayObj);
        mScroll.settings.MoveLock = true;
        mScroll.ScrDown();
        mScroll.settings.MoveTimeObj = setInterval('mScroll.ScrDown()',mScroll.settings.Speed);
    },
    //下翻停止
    StopDown : function (){ 
        clearInterval(mScroll.settings.MoveTimeObj);
        if($("#"+mScroll.settings.ScrContoObj).scrollLeft() % mScroll.settings.Offset - mScroll.settings.fill != 0 ){
            mScroll.settings.Comp = mScroll.settings.Offset - $("#"+mScroll.settings.ScrContoObj).scrollLeft() % mScroll.settings.Offset + mScroll.settings.fill;
            mScroll.CompScr();
        }else{
            mScroll.settings.MoveLock = false;
        }
        mScroll.AutoPlay();
    },
    //下翻动作
    ScrDown : function (){ 
        if( $("#"+mScroll.settings.ScrContoObj).scrollLeft() >= document.getElementById(mScroll.settings.ContListObj).scrollWidth){
            $("#"+mScroll.settings.ScrContoObj).scrollLeft( $("#"+mScroll.settings.ScrContoObj).scrollLeft() - document.getElementById(mScroll.settings.ContListObj).scrollWidth);
        }
        document.getElementById(mScroll.settings.ScrContoObj).scrollLeft += mScroll.settings.Space ;
    },
    CompScr : function (){
        var num;
        if(mScroll.settings.Comp == 0){
            mScroll.settings.MoveLock = false;
            return;
        }
        if(mScroll.settings.Comp < 0){ //上翻
            if(mScroll.settings.Comp < -mScroll.settings.Space){
                mScroll.settings.Comp += mScroll.settings.Space;
                num = mScroll.settings.Space;
            }else{
                num = -mScroll.settings.Comp;
                mScroll.settings.Comp = 0;
            }
            document.getElementById(mScroll.settings.ScrContoObj).scrollLeft -= num;
            setTimeout('mScroll.CompScr()',mScroll.settings.Speed);
        }else{ //下翻
            if(mScroll.settings.Comp > mScroll.settings.Space){
                mScroll.settings.Comp -= mScroll.settings.Space;
                num = mScroll.settings.Space;
            }else{
                num = mScroll.settings.Comp;
                mScroll.settings.Comp = 0;
            }
            document.getElementById(mScroll.settings.ScrContoObj).scrollLeft += num;
            setTimeout('mScroll.CompScr()',mScroll.settings.Speed);
        }
    } 
});

var Def=Class.create();
Object.extend(Def,{
	TypeMap:{
		1 : '最新预展',
		2 : '最新拍卖'
	},
    PostDir : '/Common/Ashx/',
    /// <summary>
    /// 最新拍卖消息翻转
    /// </summary>
    /// <param name="options">默认值设置</param>
    BannerLatest : function (options) {
		$.getJSON(this.PostDir + "video/Def.Banner.Laster.ashx?size="+options.uCount+"&n=" + Math.random(), function(jsonData){
			var shtml=new StringBuilder();
			$(jsonData).each(function (index,Data) {
				var url='http://exhibit.baozang.com/e,subject,2468.html';
				if(Data.CTYPE==1)
					url='http://exhibit.baozang.com/e,subject,'+Data.ID+'.html';
				else if(Data.CTYPE==2)
					url='http://auction.baozang.com/item.html?aidx='+Data.ID;
					
				shtml.append('<li><b>'+Def.TypeMap[Data.CTYPE]+':</b><a href="'+url+'"  target="_blank">'+Data.TITLE)
			    if ( Data.UDATE.length>0) {
			        shtml.append('  ('+Data.UDATE+')');
			    }
				shtml.append('</a></li>')
			});
			$(options.selector).html("<ul>"+shtml.toString()+"</ul>");
			Def.latestEvents(options);
		});
    },
    /// <summary>
    /// 最新拍卖消息翻转
    /// </summary>
    /// <param name="options">默认值设置
    /// selector:筛选器，speed：速度，timer：settimeout时间，hpx:滚动高度，mode:模式1为下，-1为上
    /// </param>
    latestEvents : function (options){
        var settings = {selector:'.latestNews',speed:100, timer:1000 ,hpx:10,mode:1};
        jQuery.extend(settings, options);
        new function (){
            $(settings.selector).find("ul:first").animate({
                marginTop:(settings.mode * settings.hpx)+"px"
            },settings.speed,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
            });
            setTimeout(arguments.callee,settings.timer);
        }
    },
    /// <summary>
    /// 首页友情连接
    /// </summary>
    DefLinks : function (options) {
	    $.getJSON(this.PostDir + "Links/Def.ashx?fdi="+options.fdi+"&size="+options.size+"&n=" + Math.random(), function(JosnData){
            var shtml=new StringBuilder();
            var shtml2=new StringBuilder();
            if (JosnData.length>0) {
                $(JosnData).each(function(i,item){
                    var str=(item.SHOWMODE=="1")?'<img src="http://'+item.IMG+'" alt="'+item.TITLE+'" />':item.TITLE;
                    if(item.SHOWMODE=="1")
                        shtml2.append('<a href="'+item.HTTPURL+'" title="'+item.TITLE+'" target="_blank"><img src="http://'+item.IMG+'" alt="'+item.TITLE+'" /></a> ');
                    else
                        shtml.append('<a href="'+item.HTTPURL+'" title="'+item.TITLE+'" target="_blank">'+item.TITLE+'</a> ');
                    
                });
                $(".colLink").show();
            }else{
                shtml.append("暂无添加友情连接数据!");
            }
            $(options.selector).html("<div>"+shtml2.toString()+"</div><div>"+shtml.toString()+"</div>");
            
        });
	},
	/// <summary>
    /// 更多页面的友情连接列表
    /// </summary>
	MoreLinks : function (options) {
	    $.getJSON("../"+this.PostDir + "Links/More.ashx?n=" + Math.random(), function(JosnData){
            var shtml=new StringBuilder();
            if (JosnData.length>0) {
                $(JosnData).each(function(i,data){
                    if(data.NODELIST.length>0)
                    {
                        shtml.append('<div><b>'+data.TITLE+'</b><br>');
                        var shtml1=new StringBuilder();
                        var shtml2=new StringBuilder();
                        $(data.NODELIST).each(function (i2,item) {
                            var str=(item.SHOWMODE=="1")?'<img src="http://'+item.IMG+'" alt="'+item.TITLE+'" />':item.TITLE;
                            if(item.SHOWMODE=="1")
                                shtml2.append('<a href="'+item.HTTPURL+'" title="'+item.TITLE+'" target="_blank"><img src="http://'+item.IMG+'" alt="'+item.TITLE+'" /></a> ');
                            else
                                shtml1.append('<a href="'+item.HTTPURL+'" title="'+item.TITLE+'" target="_blank">'+item.TITLE+'</a> ');
                        });
                        shtml.append('<div>'+shtml2.toString()+'</div><div>'+shtml1.toString()+'</div></div>');
                        delete shtml1,shtml2;
                    }
                });
            }else{
                shtml.append("暂无添加友情连接数据!");
            }
            $(options.selector).html(shtml.toString());
            
        });
	},
	/// <summary>
    /// 合作伙伴
    /// </summary>
	DefPartners : function (options) {
	    $.getJSON(this.PostDir + "Links/Def.ashx?fdi="+options.fdi+"&size="+options.size+"&n=" + Math.random(), function(JosnData){
            var shtml=new StringBuilder();
            if (JosnData.length>0) {
                $(JosnData).each(function(i,item){
                   shtml.append('<a href="'+item.HTTPURL+'" target="_blank"><img src="http://'+item.IMG+'" alt="'+item.TITLE+'" /></a>');
                });
                $(".colSpon").show();
            }else{
                shtml.append("暂无添加合作伙伴数据!");
            }
            $(options.selector).html(shtml.toString());
        });
	}
    
});
// 期刊
var Periodical=Class.create();
Object.extend(Periodical,{
	PostDir : 'Common/Ashx/Periodical/',
	//leftID,rightID,wrapper,selector,offset,sumNum,showNum
	DefShow : function (options) {
		$.getJSON(this.PostDir + "DefRemTop.List.ashx?size="+options.sumNum+"n=" + Math.random(), function(JsonData){
			var shtml=new StringBuilder();
			$(JsonData).each(function (index,Json) {
			    shtml.append('<li><a href="http://news.baozang.com/qikan/'+Json.ID+'.aspx" target="_blank"><img src="http://news.baozang.com/upload/image'+Json.IMG+'" alt="'+Json.NAME+'" /></a></li>');
			})
			var sumNum = JsonData.length;
 			$(options.selector).html(shtml.toString());
 			mScroll.Init({ScrContoObj:'cover',ContListObj:'itemswrap',_ContListObj:'itemswrap2',Offset :options.offset});
 			
 			$(options.leftID).mousedown(function(){mScroll.GoUp();})
                .mouseup(function () { mScroll.StopUp();})
                .mouseout(function () { mScroll.StopUp();}).css("cursor","pointer");					
 			$(options.rightID).mousedown(function(){mScroll.GoDown();})
                .mouseup(function () {mScroll.StopDown();})
                .mouseout(function () { mScroll.StopDown();}).css("cursor","pointer");
		});
	}
});
//滚动插件
(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
                var _this=this.eq(0).find("ul:first");
                var     lineH=_this.find("li:first").height(), //获取行高
                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                        timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                //滚动函数
                scrollUp=function(){
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                        });
                }
                //鼠标事件绑定
                _this.hover(function(){
                        clearInterval(timerID);
                },function(){
                        timerID=setInterval("scrollUp()",timer);
                }).mouseout();
        }        
})
})(jQuery);

// 统计
var pStat =(function () {
	var inner;
	return inner={
		// 索引统计
		ACI : function (iid) {
			$.ajax({url: "Common/Ashx/Stat/Auction.Index.ashx?iid="+iid+"&n="+Math.random(),async: true,success: function(ress){}});
		}
	};
})();
document.getElementsByClassName = function(className,oBox) {
	//适用于获取某个HTML区块内部含有某一特定className的所有HTML元素
	this.d= oBox || document;
	var children = this.d.getElementsByTagName('*') || document.all;
	var elements = new Array();
	for (var ii = 0; ii < children.length; ii++) {
		var child = children[ii];
		if(child.className==className)
		{
		    elements.push(child);
			continue;
		}
		var classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) 
		{
			if (classNames[j] == className) 
			{
				elements.push(child);
				continue;
			}
		}
	}
	return elements;
}

document.getElementsByType = function(sTypeValue,oBox) {
	//适用于获取某个HTML区块内部同属于某一特定type的所有HTML元素，如:input,script,link等等
	this.d= oBox || document;
	var children = this.d.getElementsByTagName('*') || document.all;
	var elements = new Array();
	for (var ii = 0; ii < children.length; ii++) {
		if (children[ii].type == sTypeValue) {
			elements.push(children[ii]);
		}
	}
	return elements;
}
function $F() {
	var elements = new Array();
	for (var ii = 0; ii < arguments.length; ii++) {
		var element = arguments[ii];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

$Cls = function (s,o){return document.getElementsByClassName(s,o);};
$Type = function (s,o){return document.getElementsByType(s,o);};
$Tag = function (s,o){
	this.d=o || document;
	return this.d.getElementsByTagName(s);
};
// UI tab
function UI_TAB(){
	var id="";
	var arr=[];
	var panelList=[];
	this.init=function(id){
		id=id;
		arr=$Tag("a",$Cls("ui-tabs-nav",$F(id))[0]);
		
		panelList=$Cls("contentLC ui-tabs-panel",$F(id));
		for(var i=0;i<arr.length;i++){
			arr[i].onclick=function(){
				activeLI(this);
				return false;
			};
		}
	}
	function activeLI(LI){
		if(LI.className=="ui-tabs-selected")
		{return;}
		else{
			var a = LI;
			var str=a.href;
			var temp_arr=str.split("#");
			var _id=temp_arr[temp_arr.length-1];
			for ( var j=0 ;j<arr.length;j++ ){
				arr[j].className="";
			}
			LI.className="ui-tabs-selected";
			for(j=0;j<panelList.length;j++){
				panelList[j].style.display="none";
			}
			$F(_id).style.display="block";
		}
	}
	this.activeIndex=function(i){
		activeLI(arr[i]);
	}
	return this;
}
/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
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
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        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;
    }
};

/*
 * Lazy Load - jQuery plugin for lazy loading images
 *
 * Copyright (c) 2007-2009 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 *
 * Version:  1.5.0
 *
 */
(function($) {

    $.fn.lazyload = function(options) {
        var settings = {
            threshold    : 0,
            failurelimit : 0,
            event        : "scroll",
            effect       : "show",
            container    : window
        };
                
        if(options) {
            $.extend(settings, options);
        }

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        var elements = this;
        if ("scroll" == settings.event) {
            $(settings.container).bind("scroll", function(event) {
                
                var counter = 0;
                elements.each(function() {
                    if ($.abovethetop(this, settings) ||
                        $.leftofbegin(this, settings)) {
                            /* Nothing. */
                    } else if (!$.belowthefold(this, settings) &&
                        !$.rightoffold(this, settings)) {
                            $(this).trigger("appear");
                    } else {
                        if (counter++ > settings.failurelimit) {
                            return false;
                        }
                    }
                });
                /* Remove image from array so it is not looped next time. */
                var temp = $.grep(elements, function(element) {
                    return !element.loaded;
                });
                elements = $(temp);
            });
        }
        
        this.each(function() {
            var self = this;
            
            /* Save original only if it is not defined in HTML. */
            if (undefined == $(self).attr("original")) {
                $(self).attr("original", $(self).attr("src"));     
            }

            if ("scroll" != settings.event || 
                    undefined == $(self).attr("src") || 
                    settings.placeholder == $(self).attr("src") || 
                    ($.abovethetop(self, settings) ||
                     $.leftofbegin(self, settings) || 
                     $.belowthefold(self, settings) || 
                     $.rightoffold(self, settings) )) {
                        
                if (settings.placeholder) {
                    $(self).attr("src", settings.placeholder);      
                } else {
                    $(self).removeAttr("src");
                }
                self.loaded = false;
            } else {
                self.loaded = true;
            }
            
            /* When appear is triggered load original image. */
            $(self).one("appear", function() {
                if (!this.loaded) {
                    $("<img />")
                        .bind("load", function() {
                            $(self)
                                .hide()
                                .attr("src", $(self).attr("original"))
                                [settings.effect](settings.effectspeed);
                            self.loaded = true;
                        })
                        .attr("src", $(self).attr("original"));
                };
            });

            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if ("scroll" != settings.event) {
                $(self).bind(settings.event, function(event) {
                    if (!self.loaded) {
                        $(self).trigger("appear");
                    }
                });
            }
        });
        
        /* Force initial check if images should appear. */
        $(settings.container).trigger(settings.event);
        
        return this;

    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */

    $.belowthefold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).height() + $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top + $(settings.container).height();
        }
        return fold <= $(element).offset().top - settings.threshold;
    };
    
    $.rightoffold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).width() + $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left + $(settings.container).width();
        }
        return fold <= $(element).offset().left - settings.threshold;
    };
        
    $.abovethetop = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top;
        }
        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };
    
    $.leftofbegin = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left;
        }
        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };
    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() */

    $.extend($.expr[':'], {
        "below-the-fold" : "$.belowthefold(a, {threshold : 0, container: window})",
        "above-the-fold" : "!$.belowthefold(a, {threshold : 0, container: window})",
        "right-of-fold"  : "$.rightoffold(a, {threshold : 0, container: window})",
        "left-of-fold"   : "!$.rightoffold(a, {threshold : 0, container: window})"
    });
    
})(jQuery);

/*
 *  jQuery Scroll to Top Control script
 *  Demo:scrolltotop.init()
 */
var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
	controlHTML: '<img src="common/images/up.gif" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
	controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';
                obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

                        }
                        catch (e) {
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}
/* 分享 */
function get_share_url(type, link_id){
	var tgt_full_url = '';
	var default_title = document.getElementById("h1title").innerHTML;
	var current_topic_title = (default_title == null) ? document.title : default_title;
	document.title = current_topic_title;
	// add target uri and self title information
	if(type == "renren"){
		tgt_full_url += "http://share.renren.com/share/buttonshare.do?link=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "qq"){
		tgt_full_url += "http://shuqian.qq.com/post?from=3&uri=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "sina"){
		tgt_full_url += "http://v.t.sina.com.cn/share/share.php?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "baidu"){
		tgt_full_url += "http://cang.baidu.com/do/add?it=";
		tgt_full_url += encodeURIComponent(document.title);
		tgt_full_url += "&iu=";
		tgt_full_url += encodeURIComponent(location.href);

	} else if(type == "google"){
		tgt_full_url += "http://google.com/bookmarks/mark?op=edit&bkmk=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
	} else if(type == "kaixin001"){
		tgt_full_url += "http://www.kaixin001.com/repaste/share.php?rurl=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&rtitle=";
		tgt_full_url += encodeURIComponent(document.title);
		tgt_full_url += "&rcontent=" + encodeURIComponent("æ´¾ä»£ç½åäº«ï¼");;
		
	} else if(type == "douban"){
		tgt_full_url += "http://www.douban.com/recommend/?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
		
	} else if(type == "taobao"){
		tgt_full_url += "http://share.jianghu.taobao.com/share/addShare.htm?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
	}
	
	var link_obj = document.getElementById(link_id);
	link_obj.target = "_blank";
	link_obj.href = tgt_full_url;
	return true;
}


// 散在外面的
// JScript 文件
//视频首页推荐图片视频切换
(function($){
    $.fn.switchPic = function(o){
        o = $.extend({
            infoWrap:null,
            clickBtn:true,
            autoSwitch:true,
            curr:0,
            start:0,
            speed:5000
        },o||{});
        
        return this.each(function(){
            var run = false;
			var a = $(this).find("a");
            var l = $(this).find("a").size();
			var info = [];
			var btn = "";
			var t;
			a.css("display","none");
			a.eq(o.start).css("display","block");
			$(o.infoWrap).append(a.eq(o.start).find("img").attr("ref"));
			
			if(o.clickBtn){
			    for(var i=0;i<l;i++){
				info.push(a.eq(i).find("img").attr("ref"));	
				    btn += '<a href="'+a.eq(i).attr("href")+'">'+i+'</a>';
			    }
			    btn = '<div class="btn">'+btn+'</div>';
			    $(o.infoWrap).append(btn);
			    $(".btn").find("a").eq(o.start).addClass("selected");
			    $(".btn").find("a").click(function(){
			        var order = $(this).text();
			        go(order);
			        return false;
			    });
			}
			
			if(o.autoSwitch){
			    o.t = setInterval(function() {
                    go(parseInt(o.curr)+1);
                }, o.speed);
			}
			
			function go(showItemOrder){
			    if(showItemOrder>=l){
			        showItemOrder = o.start;
			    }
			    if(!run) {
			        clearInterval(o.t);
			        a.fadeOut();
			        a.eq(showItemOrder).fadeIn();
			        $(o.infoWrap).find("h3").remove();
			        $(o.infoWrap).find("p").remove();
			        run = true;
			        $(o.infoWrap).prepend(a.eq(showItemOrder).find("img").attr("ref"));
			        $(".btn").find("a").removeClass("selected");
			        $(".btn").find("a").eq(showItemOrder).addClass("selected");
			        o.curr = showItemOrder;
			        run = false;
			        o.t = setInterval(function() {
                        go(parseInt(o.curr)+1);
                    }, o.speed);
			    }
			    return false;
			}
        });
    }
})(jQuery);

/* 分享 */
function get_share_url(type, link_id){
	var tgt_full_url = '';
	var default_title = document.getElementById("h1title").innerHTML;
	var current_topic_title = (default_title == null) ? document.title : default_title;
	document.title = current_topic_title;
	// add target uri and self title information
	if(type == "renren"){
		tgt_full_url += "http://share.renren.com/share/buttonshare.do?link=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "qq"){
		tgt_full_url += "http://shuqian.qq.com/post?from=3&uri=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "sina"){
		tgt_full_url += "http://v.t.sina.com.cn/share/share.php?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);

	} else if(type == "baidu"){
		tgt_full_url += "http://cang.baidu.com/do/add?it=";
		tgt_full_url += encodeURIComponent(document.title);
		tgt_full_url += "&iu=";
		tgt_full_url += encodeURIComponent(location.href);

	} else if(type == "google"){
		tgt_full_url += "http://google.com/bookmarks/mark?op=edit&bkmk=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
	} else if(type == "kaixin001"){
		tgt_full_url += "http://www.kaixin001.com/repaste/share.php?rurl=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&rtitle=";
		tgt_full_url += encodeURIComponent(document.title);
		tgt_full_url += "&rcontent=" + encodeURIComponent("æ´¾ä»£ç½åäº«ï¼");;
		
	} else if(type == "douban"){
		tgt_full_url += "http://www.douban.com/recommend/?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
		
	} else if(type == "taobao"){
		tgt_full_url += "http://share.jianghu.taobao.com/share/addShare.htm?url=";
		tgt_full_url += encodeURIComponent(location.href);
		tgt_full_url += "&title=";
		tgt_full_url += encodeURIComponent(document.title);
	}
	
	var link_obj = document.getElementById(link_id);
	link_obj.target = "_blank";
	link_obj.href = tgt_full_url;
	return true;
}
/* 收藏 */
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
/* 粘帖 */
function copyToClipBoard(){
    var clipBoardContent = location.href;
	if(window.clipboardData){
	    window.clipboardData.setData("Text", clipBoardContent);
	}else{
	     alert("您所使用的浏览器不支持此操作！\r\n可以使用Ctrl+C复制地址。");
	}
    return false;
}

// JScript 文件
//视频详细页，顶
function videohitup()
    {
        $.ajax({
            url:"/common/ashx/video/hitup.ashx?vidx="+document.getElementById("vidx").value+"&t="+new Date(),
            type:"GET",
            success: function () {
                var hits=$("#hitup").html();
                hits=parseInt(hits)+1;
                $("#hitup").html(hits);
            }
        });
    }
    
    //视频详细页，踩
function videohitdown()
    {
        $.ajax({
            url:"/common/ashx/video/hitdown.ashx?vidx="+document.getElementById("vidx").value+"&t="+new Date(),
            type:"GET",
            success: function () {
                var hits=$("#hitdown").html();
                hits=parseInt(hits)+1;
                $("#hitdown").html(hits);
            }
        });
    }

function pos(obj){
    $(".hasMenu").removeClass("selected");
    obj.addClass("selected");
	p = obj.position();
	$(".submenu").hide();
	navId = obj.attr("id");
	$("#sub_"+ navId).show();
}
function globel_header(){
    pos($("#menu8"));
    $(".hasMenu").hover(function(){
		pos($(this));
		if ($(this).attr("id")!="menu8") {
		    $("#menu8").addClass("currMenu");
		}else{
		    $("#menu8").removeClass("currMenu");
		}
	});
	$(".srcInput input").focus(function(){
	    $(this).parent().removeClass("addBg");
	}).blur(function(){
	    if($(this).val()!=""){ return; }
	    $(this).parent().addClass("addBg");
	});
}

