/**
*BX 全局包 1.0.11
*编码：utf-8版本
*作者：bigtreexu
*网站：http://www.bigtreexu.com
*/
/*___BX GLOABLE___*/
var BX={
	version:'1.0.10.A',
	encoding:'utf-8',
	author:'bigtreexu'
};
BX.namespace=function(ns){
	if(!ns||!ns.length) {
		return null;
	}
	var _pr=ns.split('.');
	var _nx=BX;
	for(var i=0;i!=_pr.length;i++) {
		_nx[_pr[i]]=_nx[_pr[i]]||{};
		_nx=_nx[_pr[i]];
	}
}

/*___Predigest Application___*/
function $O(el) {
	if(!el) {
		return null;
	} else if(typeof el=='string') {
		return document.getElementById(el);
	} else if(typeof el=='object') {
		return el;
	}
}
/**
*将id，对象，id数组，对象数组加工成对应的对象数组
*@param 	{String||Object||Array} els id，对象，id数组，对象数组
*@return 	{Array} 对象数组
*/
function $A(els){
	var _els=[];
	if(els instanceof Array) {
		for(var i=0;i!=els.length;i++) {
			_els[_els.length]=$O(els[i]);
		}
	} else if(typeof els=='object'&&typeof els['length']!='undefined'&&els['length']>0) {
		for(var i=0;i!=els.length;i++) {
			_els[_els.length]=$O(els[i]);
		}
	} else {
		_els[0]=$O(els);
	}
	return _els;
}
/*___Init___*/
BX.namespace('Dom');
/**
*BX DOM包 1.0.0
*utf-8版本
*http://www.bigtreexu.com
*/
BX.Dom={
	_batch:function(el,func) {
		var _el=$A(el);
		for(var i=0;i!=_el.length;i++) {
			if(_el[i]) {
				func(_el[i]);
			}
		}
	},
	getMouseXY:function(e) {
		var _x=_y=0;
		_x=document.documentElement.scrollLeft;
		_y=document.documentElement.scrollTop;
		if(e.clientX||e.clientY) {
			_x+=e.clientX;
			_y+=e.clientY;
		} else if(e.pageX||e.pageY) {
			_x+=e.pageX;
			_y+=e.pageY;
		}
		return [_x,_y];
	},
	getXY:function(el) {
		var _x=_y=0;
		while(el) {
			_x+=el.offsetLeft;
			_y+=el.offsetTop;
			el=el.parentElement;
		}
		return [_x,_y];
	},
	getWH:function(el) {
		return [el.offsetWidth,el.offsetHeight];
	},
	setOpacity:function(els,val) {
		var _run=function(el) {
			el.style.MozOpacity=''+val/100;
			el.style.filter='Alpha(Opacity='+val+')';
		}
		this._batch(els,_run);
	},
	hide:function(els) {
		var _run=function(el) {
			el.style.display='none';
		}
		this._batch(els,_run);
	},
	show:function(els) {
		var _run=function(el) {
			el.style.display='block';
		}
		this._batch(els,_run);
	},
	getClass:function(el) {
		if($O(el)) {
			return $O(el).className;
		} else {
			return;
		}
	},
	setClass:function(els,val) {
		var _run=function(el) {
			el.className=val;
		}
		this._batch(els,_run);
		
	},
	addClass:function(els,val) {
		if(!val) {
			return;
		}
		var _run=function(el) {
			var _cln=el.className.split(' ');
			for(var i=0;i!=_cln.length;i++) {
				if(_cln[i]==val) {
					return;
				}
			}
			if(el.className.length>0) {
				el.className=el.className+' '+val;
			} else {
				el.className=val;
			}
		}
		this._batch(els,_run);
	},
	hasClass:function(el,val) {
		var _bl=false;
		if($O(el)) {
			if(!el.className){return;}
			var _cln=el.className.split(' ');
			for(var i=0;i!=_cln.length;i++) {
				if(_cln[i]==val) {
					_bl=true;
					break;
				}
			}
		}
		return _bl;
	},
	removeClass:function(els,val) {
		if(!val) {
			return;
		}
		var _run=function(el) {
			var _cln=el.className.split(' ');
			var _s='';
			for(var i=0;i!=_cln.length;i++) {
				if(_cln[i]!=val) {
					_s+=_cln[i]+' ';
				}
			}
			if(_s==' ') {
				_s='';
			}
			if(_s.length!=0) {
				_s=_s.substr(0,_s.length-1);
			}
			el.className=_s;
		}
		this._batch(els,_run);
	},
	replaceClass:function(els,vala,valb) {
		if(!vala||!valb) {
			return;
		}
		var _run=function(el) {
			var _cln=el.className.split(' ');
			for(var i=0;i!=_cln.length;i++) {
				if(_cln[i]==vala) {
					_cln[i]=valb;
				}
			}
			el.className=_cln.join(' ');
		}
		this._batch(els,_run);
	},
	setStyle:function(els,styleName,styleValue) {
		var _run=function(el) {
			el.style[styleName]=styleValue;
		}
		this._batch(els,_run);
	},
	getStyle:function(el,styleName) {
		return el.style[styleName];
	},
	getElementsByClassName:function(parentEl,className,tagName){
		if(!parentEl||!className){
			return null;
		}
		var els=cds=[];
		cds=$O(parentEl).childNodes;
		className=className.toUpperCase();
		for(var i=0;i<cds.length;i++){
			var _type=cds[i].nodeType;
			if(_type!=3&&_type!=8&&cds[i].className.toUpperCase()==className){
				if(!tagName||cds[i].nodeName.toUpperCase()==tagName.toUpperCase()){
					els[els.length]=cds[i];
				}
			}
		}
		return els;
	}
}

var O=BX.Dom;

(function (window, undefined) {
    if (window.islide) {
        return;
    }
    var islide = {},
	rfocusable = /^(?:button|input|object|select|textarea)$/i;
	var isPhotoImageLoaded = false;
	var staSign = true;
    Function.prototype.bind = function () {
        if (!arguments.length) return this;
        var _ = this,
            $ = Array.prototype.slice.call(arguments),
            A = $.shift();
        return function () {
            return _.apply(A, $.concat(Array.prototype.slice.call(arguments)))
        }
    };
    var removeListener;
    window.addListener = function (list, name, fn) {
        var bind, unbind, id = "EVENT";
        if (document.attachEvent) {
            bind = function (el, eventName, _fn) {
                _fn[id] = function () { _fn(event, el); };
                el.attachEvent('on' + eventName, _fn[id]);
            }
            unbind = function (el, eventName, _fn) {
                el.detachEvent('on' + eventName, _fn[id]);
            }
        } else if (document.addEventListener) {
            bind = function (el, eventName, _fn) {
                _fn[id] = function (e) { _fn(e, el); };
                el.addEventListener(eventName, _fn[id], false);
            }
            unbind = function (el, eventName, _fn) {
                el.removeEventListener(eventName, _fn[id], false);
            }
        }
        else {
            bind = function (el, eventName, _fn) {
                el['on' + eventName] = _fn;
            }
            unbind = function (el, eventName, _fn) {
                el['on' + eventName] = null;
            }
        }
        window.addListener = function (list, name, fn) {
            if (Object.prototype.toString.apply(list) != "[object Array]")
                list = [list];
            var i = -1, len = list.length;
            while (++i < len) {
                bind(list[i], name, fn);
            }
        };
        removeListener = window.removeListener = function (list, name, fn) {
            if (Object.prototype.toString.apply(list) != "[object Array]")
                list = [list];
            var i = -1, len = list.length;
            while (++i < len) {
                unbind(list[i], name, fn);
            }
        };
        addListener(list, name, fn);
    }

    function addStylesheetRules(rules) {
        var style = document.createElement('style');

        document.body.appendChild(style);
        if (!window.createPopup) { /* For Safari */
            style.appendChild(document.createTextNode(''));
        }
        var s = document.styleSheets[document.styleSheets.length - 1];
        for (var selector in rules) {
            if (s.insertRule) {
                s.insertRule(selector + '{' + rules[selector] + '}', s.cssRules.length);
            } else { /* IE */
                s.addRule(selector, rules[selector], -1);
            }
        }
    }

    var photoViewMode = {
        "loop": function (index) {//loop
            var t = this;
			index = parseInt(index);
            return {
                prev: index > 1 ? '#p=' + (index - 1) : '#p=' + (t.size ),
                next: index < t.size ? '#p=' + (index + 1) : '#p=1'  
            };
        },
        "skip": function (index) {//continue;
            var t = this;
			index = parseInt(index);
            return {
				prev: index > 1 ? '#p=' + (index - 1) : '#p=' + (t.size ),
				next: index < t.size  ? '#p=' + (index + 1) : '#p=endpage'
            };
        }
    };

    islide.Gallery = function (options) {
        var t = this  ;
		this._timer =0 ;		
        var o = this.o = {  //for easy using
        	 activeThumbCls:"activeThumbCls", photoViewMode:photoViewMode.loop,   
             'btnOrig':$O('btnOrig') , 'showallPic':$O('showallPic'), 'photoIndex':$O('photoIndex'),
             'picDiv':$O('picDiv'), 'photoView':$O('photoView'), 'photoPrev':$O('photoPrev'), 'photoNext':$O('photoNext'), 'photo':$O('photo'), 'photoPrevLoading':$O('photoPrevLoading'), 'picList_b':$O('picList_b'),
             'photoLoading':$O('photoLoading'), 'photoDesc':$O('photoDesc'),
             'boxScrl':$O('scrl'),'thumb':$O('thumb'), 'bar':$O('bar'), 'btnScrlPrev':$O('scrlPrev'), 'btnScrlNext':$O('scrlNext'), 'scrlPrev_b':$O('scrlPrev_b'), 'scrlNext_b':$O('scrlNext_b'),
             'moretab':$O('moretab'), 'imageListView':$O('imageListView'), 'showslidePic':$O('showslidePic'), 'photoTitle':$O('photoTitle')
        }
        if (!options.activeThumbCls) {
            var rules = {};
            rules["." + o.activeThumbCls] = "border:1px solid #F9DF53;";
            addStylesheetRules(rules);
        }
        for (var i in o) {
            (options[i] && (o[i] = options[i]));
        }

		t.data =options.data || [];
        t.turn = photoViewMode[options.photoViewMode];

        t.photoIndex = {};
        t.photoInfo = [];

		o.thumbs =[];
		(function(){
			var list =  o.thumb.getElementsByTagName("li"),len= list.length;
			for(var i = 0;i<len;i++){
				o.thumbs.push(list[i]);
			}			
		})();
		 
        t.size = t.data.length;
		t.offsetSize = o.thumbs.length;
		t.loadlazyQuene = []; 
		for(var i =  t.offsetSize  ; i < t.size;i++){
			t.loadlazyQuene.push(t.data[i]);
		}
        
	
        var pWidth = o.photoView.offsetWidth,
		pHeight = o.photoView.offsetHeight;
        uWidth = o.thumbs[0].offsetWidth,
		tWidth = uWidth * t.size,
		tCntWidth = o.thumb.parentNode.offsetWidth,
		tNum = Math.floor(tCntWidth / uWidth);

        tCntWidth = uWidth * tNum;
        O.setStyle(o.photoView, "width", pWidth + 'px');
        O.setStyle(o.thumb, "width", (tWidth+2) + 'px');//ie6兼容增加2px
        O.setStyle(o.boxScrl, "width", (tCntWidth + o.btnScrlPrev.offsetWidth * 2) + 'px');

        var bCntWidth = o.bar.parentNode.offsetWidth,
		bWidth = Math.max(36, Math.min(tCntWidth * bCntWidth / tWidth, bCntWidth));

        O.setStyle(o.bar, "width", bWidth + 'px');

        var i = -1, len = t.size;
 
        while (++i < len) {
            var self = t.data[i],
			
			id = self.img.substr(self.img.lastIndexOf('/')+1,self.img.lastIndexOf('.')-self.img.lastIndexOf('/')-1);
			var mult = Math.max(0, Math.min(i - Math.floor((tNum + 1) / 2) + 1, t.size - tNum));

            t.photoInfo.push({
                id: id,
                title: self.title,
                desc: self.desc,
                img: self.img,
                timg: self.timg,
                listimg: self.listimg,
                pos: uWidth * mult,
                picwidth:self.picwidth,
                picheight:self.picheight,
                morelink:self.morelink
            });
            t.photoIndex[id] = i+1;
        }

        t.bar = new islide.Scroll(o.thumb, 'x', o.bar);

        addListener([o.btnScrlPrev, o.btnScrlNext, o.bar], 'click', function (event, dom) {
            event.preventDefault ? event.preventDefault() : (event.returnValue = false);
        });
		addListener([o.btnScrlPrev, o.btnScrlNext ], 'dblclick', function (event, dom) {  // for clear selection area
             window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
        });
        

        addListener(o.btnScrlPrev, 'mousedown', t.bar.start.bind(t.bar, 'forward'))
        addListener(o.btnScrlPrev, 'mouseup', t.bar.stop.bind(t.bar));
        addListener(o.btnScrlPrev, 'mouseout', t.bar.stop.bind(t.bar));
        addListener(o.btnScrlNext, 'mousedown', t.bar.start.bind(t.bar, 'backward'));
        addListener(o.btnScrlNext, 'mouseup', t.bar.stop.bind(t.bar));
        addListener(o.btnScrlNext, 'mouseout', t.bar.stop.bind(t.bar));

        var alist = [o.photoPrev, o.photoNext];
        i = -1, len = o.thumbs.length;  //add event for loaded li
        while (++i < len) {
            Array.prototype.push.call(alist, o.thumbs[i].getElementsByTagName("a")[0]);
        }
        addListener(alist, 'click', function (event, dom) {
            var oHash = t.parseObj(dom.href);

            if (oHash.p) {
                event.preventDefault ? event.preventDefault() : (event.returnValue = false);
                t.showPhoto(oHash.p).changeHash('p=' + oHash.p);
            }
        });
        
		addListener(o.photoPrevLoading, 'load', function (ev, dom) {
            var oHash = t.parseObj(o.photoNext.href);
            if (oHash.p) {
                (new Image).src = t.photoInfo[parseInt(oHash.p) - 1].timg;
            }
        });


		var oHash = t.parseObj(window.location.hash);
		
		if(!oHash.p){
			staSign = false;
			t.changeHash("p=1");
		}
		
        //load left img 	
       
		(function(){	
			 var obj,  oFragmeng = document.createDocumentFragment(); //创建文档碎片; 
			 while((obj =t.loadlazyQuene.shift())!=null){
				var li = document.createElement("li");
				var a  = document.createElement("a"),
					id = obj.img.substr(obj.img.lastIndexOf('/')+1,obj.img.lastIndexOf('.')-obj.img.lastIndexOf('/')-1);     
								
					a.href = "#p=" + (t.size - t.loadlazyQuene.length);
					a.hidefocus = true ;
					a.innerHTML = "<img src=\""+obj.img + "\"/>" ;
					li.appendChild(a);
					o.thumbs.push(li); 
					oFragmeng.appendChild(li);       	 	           	 	   
					addListener( a , 'click' , function (event, dom) {     		   	  	
							var oHash = t.parseObj(dom.href);			            		
							if (oHash.p) {
								event.preventDefault ? event.preventDefault() : (event.returnValue = false);
								t.showPhoto(oHash.p).changeHash('p=' + oHash.p);
								
							}
						});  					 
				} 
			o.thumb.appendChild(oFragmeng);   	
		})(); 
		t.showPhoto(oHash.p);
		//load sta
		islide.Gallery.prototype.loadSta();

        addListener(document, 'keydown', function (ev, dom) {
            if (!rfocusable.test((ev.target || ev.srcElement || document).nodeName)) {
                switch (ev.keyCode) {
                    case 37:
                        var href = o.photoPrev.getAttribute('href'),
						oHash = t.parseObj(href);

                        if (oHash.p) {
                            t.showPhoto(oHash.p).changeHash('p=' + oHash.p);	
                        } else {
                            window.location.href = href;
                        }
                        break;
                    case 39:
                        var href = o.photoNext.getAttribute('href'),
						oHash = t.parseObj(href);

                        if (oHash.p) {
                            t.showPhoto(oHash.p).changeHash('p=' + oHash.p);
                        } else {
                            window.location.href = href;
                        }
                        break;
                }
            }
        });

        /** start for full mode---begin**/    
	  	var  ul  = document.createElement("ul");
	  	for(var j=0 ; j  < t.size ; j++ ){
	  		var photo =t.photoInfo[j],  li = document.createElement("li"), i =document.createElement("i"),a =document.createElement("a"),img =document.createElement("img");
	  		img.src =photo.listimg;
	  		a.href="#p="+(j+1);
	  		a.target="";
			addListener(a,"click", t.changeListMode.bind(t,j));
			a.appendChild(img);
			li.appendChild(i)
			li.appendChild(a);
			ul.appendChild(li);
		}
		o.imageListView.appendChild(ul);
        addListener(o.showallPic,"click",t.changeListMode.bind(t));
        addListener(o.showslidePic,"click",t.changeListMode.bind(t))
        /** start for full mode---end**/ 
    };

    islide.Gallery.prototype = {
		//加载图片页统计脚本
		loadSta : function() {
			return;
			var head = document.getElementsByTagName('head');
			var staScript = document.createElement('script');
			var staUrl = "";	
			staScript.setAttribute('src', staUrl);
			staScript.setAttribute('type', 'text/javascript');
			head[0].appendChild(staScript);
		},
        showPhoto: function (id) {
			if (id=="endpage") {
				$(".endpage").show(), $(".sw-player").hide()
			}
            var t = this,
			index = isNaN(id) ? 1 : (parseInt(id ) < 1 ? 1 : (parseInt(id )> t.size? t.size : parseInt(id )) ),			
			info = t.photoInfo[index-1],
			turn = t.turn(index);			
			if(t.o.moretab.style.display == "block") {
				t.o.moretab.style.display = "none";
				t.o.picDiv.style.display = "block";
			}
            
            if (info.timg != t.o.photo.src || index ==1) {
                t.o.photoIndex.innerHTML = index;
                if (info.picheight) t.o.photoView.style.height = info.picheight + "px";	
				t.o.photoPrevLoading.width = info.picwidth;
                t.o.photoPrevLoading.height =info.picheight;
				t.o.photoPrevLoading.src = info.timg ? info.timg : info.img;
				$O('photoimg').innerHTML= "<img src='"+info.timg+"' id='photo' style='filter:alpha(opacity=100);'/>";
                t.o.photoDesc.innerHTML = (info.morelink=='')? info.desc : info.desc + "<a href="+info.morelink+" target='_blank'>[详细]</a>";
                t.o.photoTitle.innerHTML = info.title;
                t.o.photoPrev.href = turn.prev;
                t.o.photoNext.href = turn.next;
                t.bar.onStart = function () {
                    var cur = O.getElementsByClassName(t.o.thumb, t.o.activeThumbCls),o= t.o;
                    (cur && O.removeClass(cur[0],  o.activeThumbCls));
                    O.addClass( o.thumbs[index-1],  o.activeThumbCls); 
                    if(index==1){
                    	o.scrlPrev_b.className="no";
                    	//o.photoPrev.title = "上一图集";
                    }else if(t.size==index ){
                    	o.scrlNext_b.className="no";
                    	//o.photoNext.title = "下一图集";
                    }else{
                    	o.scrlPrev_b.className="";
                    	o.scrlNext_b.className="";
                    	//o.photoPrev.title = "上一张，支持 '← '翻页";
                    	//o.photoNext.title = "下一张，支持 '→ '翻页";
                    }
                    if(t.size<=5){
                    	o.scrlPrev_b.className="no";
                    	o.scrlNext_b.className="no";
                    	o.scrlPrev_b.style.cursor="default";
                    	o.scrlNext_b.style.cursor="default";
                    	o.bar.className="drag_no";
                    }
                };
				t.bar.scrollTo(info.pos); 
				t.o.btnOrig && (t.o.btnOrig.href = info.timg);
            }
            return t;
        },

        resize: function ($img, size) {
            $img.removeAttribute('width');
            $img.removeAttribute('height');
            size = size || {};

            var rw = size.width ? $img.width / size.width : 0,
			rh = size.height ? $img.height / size.height : 0;

            if (rw > 1 || rh > 1) {
                rw > rh ? $img.width = size.width : $img.height = size.height;
            }
        },

        parseObj: function (hash) {
            var rhash = /[#&]([^&=]+)=([^&=]+)/ig,
			a = rhash.exec(hash),
			o = {};

            while (a) {
                o[a[1]] = a[2];
                a = rhash.exec(hash);
            }

            return o;
        },

        changeHash: function (hash) {
            window.location.hash = hash;
			//load sta
			if(staSign == true){
				islide.Gallery.prototype.loadSta();
			}
			staSign = true;
            return this;
        },

        stats: function () {
            'function' === typeof vjEventTrack && vjEventTrack();
            'function' === typeof neteaseTracker && neteaseTracker();
        },
		listAnimate:function(){		 
			 var  that=this, _style = that.o.imageListView.style, from = parseInt(_style.left), to = (that.currentPageIndex )*(-900);
			 if(from < to ){
					if(from + that.ms < to){
						_style.left = (from + that.ms) +"px";
						}else{
						_style.left = to + "px"; 
						clearInterval(that._timer);
					}
			 }else{
					if(from - that.ms >  to){
						_style.left = (from - that.ms) +"px";
						}else{
						_style.left = to + "px"; 
						clearInterval(that._timer);
					}
			 }
		},
		changeListMode:function(){
			var that = this, o = that.o, picDiv = o.picDiv,imageListView= o.imageListView,moretab= o.moretab,picList_b = o.picList_b,
			thumb=o.thumb,list_li=imageListView.getElementsByTagName("li"), thumb_li= thumb.getElementsByTagName("li"),
			showallPic= o.showallPic,btnOrig= o.btnOrig,
			e = arguments[arguments.length-2] || e || window.event;
			e &&(e.preventDefault ? e.preventDefault() : (e.returnValue = false));
			if(moretab.style.display == "none") {
				$(".swpt-extra").addClass("slide-wrap-show-list"), $(".swpt-mode-list").hide(), $(".swpt-mode-hp").show(), $(".photoNews").hide();
				moretab.style.display="block";
				var allIndex  = 0;
				 
				for(var i=0; i < thumb_li.length ;i++){
					if(thumb_li[i].className == o.activeThumbCls){
						allIndex=i;
						list_li[i].className = o.activeThumbCls;
					}else{
						list_li[i].className ="";
					}					
				}
			}else{
				$(".swpt-extra").removeClass("slide-wrap-show-list"), $(".swpt-mode-hp").hide(), $(".swpt-mode-list").show(), $(".photoNews").show();
				moretab.style.display="none";
				var index = arguments[0]; 
				if(index != undefined  && typeof index =='number'){
					var li = o.thumbs[index],dom = li.getElementsByTagName('a')[0],oHash = that.parseObj(dom.href),p = that.photoInfo[parseInt(index-1)];
					if (oHash.p) {
						that.showPhoto(oHash.p).changeHash('p=' + oHash.p);
					}
					that.bar.scrollTo(p.pos);			
				}
			}  
		}
    }
 
    var scrollMode = {
        forward: function (lpf) {
            var t = this, pos = t._bPos - lpf;
            pos = (pos > 0 ? pos : 0);
            t._setPos(pos);
            (pos == 0 && t.stop());
        },
        backward: function (lpf) {
            var t = this, pos = t._bPos + lpf;
            pos = (pos < t._bRange ? pos : t._bRange);
            t._setPos(pos);
            (pos == t._bRange && t.stop());
        }
    };

    islide.Scroll = function (body, axis, handle) {
        if (!arguments.length) {
            return;
        }

        var t = this;
        t.constructor = arguments.callee;

        t._axis = axis == 'y' ? 'y' : 'x';
        t._fix = t._axis == 'x' ? {
            pos: 'left',
            offsetSize: 'offsetWidth',
            pageAxis: 'pageX',
            offsetPos: 'offsetLeft',
            scrollPos: 'scrollLeft'
        } : {
            pos: 'top',
            offsetSize: 'offsetHeight',
            pageAxis: 'pageY',
            offsetPos: 'offsetTop',
            scrollPos: 'scrollTop'
        };

        t.fps = 13;
        t.lpf = 10;
        t.speed = 40;

        t._body = body;
        t._bCnt = body.parentNode;
        t._bPos = 0;
        t._bRange = Math.max(0, t._body[t._fix.offsetSize] - t._bCnt[t._fix.offsetSize]);

        if (handle !== undefined) {
            t._handle = handle;
            t._hCnt = handle.parentNode;
            t._hPos = 0;
            t._hRange = Math.max(0, t._hCnt[t._fix.offsetSize] - t._handle[t._fix.offsetSize]);

            t.bhRate = t._hRange ? t._bRange / t._hRange : 0;

            var mouse = new islide.Mouse(t._handle);
            mouse.mouseStart = t._mouseStart.bind(t);
            mouse.mouseDrag = t._mouseDrag.bind(t);
            mouse.mouseStop = t._mouseStop.bind(t);
            addListener(t._hCnt, 'click', t._mouseClick.bind(t));
        }
    };
	var fixEvent = function(event){
           var  eObject ={};
           var doc = document.documentElement, body = document.body;
           if(event.pageX){
           		eObject['pageX']   =  event.pageX;
           		eObject['pageY']   =  event.pageY;
           }else{
				eObject['pageX'] = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft  || body && body.clientLeft || 0);
				eObject['pageY'] = event.clientY + (doc && doc.scrollTop  ||  body && body.scrollTop  || 0) - (doc && doc.clientTop  || body && body.clientTop  || 0);

           }  
           return eObject;                  
	}

    islide.Scroll.prototype = {
        start: function (toward, length) {
            var t = this;
            if (t._timer == undefined) {
                toward = toward == 'forward' ? 'forward' : 'backward';
                t._move = scrollMode[toward];
                var params = {
                    length: isNaN(length) ? -1 : parseInt(length)
                };
                t._timer = setInterval(t._scroll.bind(t, params), t.fps);
                t.onStart && t.onStart();
            }
        },
        stop: function () {
            var t = this;
            if (t._timer !== undefined) {
                clearTimeout(t._timer);
                t._timer = undefined;
                t.onStop && t.onStop();
            }
            return this;
        },
        scrollTo: function (length) {
            var t = this, distance = length - t._bPos;
            distance < 0 ? t.stop().start('forward', -1 * distance) : t.stop().start('backward', distance);
        },
        _scroll: function (params) {
            var t = this, lpf = t.lpf;
            if (params.length !== 0) {
                if (params.length > 0) {
                    lpf = Math.min(t.lpf * Math.ceil(params.length / t.speed), params.length);
                    params.length -= lpf;
                }
                t._move(lpf);
            } else {
                t.stop();
            }
        },
        _setPos: function (pos) {
            var t = this;
            t._bPos = pos;
            t._bCnt[t._fix.scrollPos] = t._bPos;
            if (t._handle) {
                t._hPos = t.bhRate ? pos / t.bhRate : 0;
                if(t._hPos == 0){
                	$O("scrlPrev_b").className = "no";
                }else{
                	$O("scrlPrev_b").className = "";
                }
                $O("scrlNext_b").className = "";
                if(t._hPos >=t._hRange){
            		$O("scrlNext_b").className = "no";
            		$O("scrlPrev_b").className = "";
                }
                if(t._hRange==0){
                    $O("scrlNext_b").className = "no";
            		$O("scrlPrev_b").className = "no";
            		$O("scrlPrev_b").style.cursor="default";
                    $O("scrlNext_b").style.cursor="default";
                }
                O.setStyle(t._handle, t._fix.pos, t._hPos + 'px');
            }
        },
        _mouseStart: function (event) {
            var t = this;
            t._diffPos = fixEvent(event)[t._fix.pageAxis] - t._handle[t._fix.offsetPos];
            return true;
        },
        _mouseDrag: function (event) {
            var t = this, pos = Math.max(0, Math.min(event['clientX'] - t._diffPos, t._hRange));
			 
            t._setPos(pos * t.bhRate);
            return false;
        },
        _mouseStop: function (event) {
            return false;
        },
        _mouseClick: function (event) {
            var t = this, cnt = t._hCnt, cPos = cnt[t._fix.offsetPos];
            while (cnt.offsetParent) {
                cnt = cnt.offsetParent;
                cPos += cnt[t._fix.offsetPos];
            }
            t.scrollTo((fixEvent(event)[t._fix.pageAxis] - t._handle[t._fix.offsetSize] / 2 - cPos) * t.bhRate);
        }
    };

    islide.Mouse = function (element) {
        var t = this;
        element = $O(element);
        addListener(element, 'mousedown', t._mouseDown.bind(t));
        addListener(element, 'click', function (event) {
            if (t._preventClickEvent) {
                t._preventClickEvent = false;
                event.cancelBubble = true;
                return false;
            }
        });

        if (navigator.userAgent.indexOf("MSIE") > -1) {
            this._mouseUnselectable = element.getAttribute('unselectable');
            element.setAttribute('unselectable', 'on');
        }
        this.started = false;
    };
    islide.Mouse.prototype = {
        _mouseDown: function (event) {
            var t = this;
			
            t._mouseStarted && t._mouseUp(event);
            t._mouseDownEvent = event;
			
            var btnIsLeft = event.which ? (event.which  == 1):(event.keyCode==0);
			 
            if (!btnIsLeft || !this.mouseCapture(event)) {
                return true;
            }

            if (t._mouseDistanceMet(event)) {
                t._mouseStarted = (t.mouseStart(event) !== false);
                if (!t._mouseStarted) {
                    event.preventDefault ? event.preventDefault() : (event.returnValue = false);
                    return true;
                }
            }
            t._mouseMoveDelegate = t._mouseMove.bind(t);
            t._mouseUpDelegate = t._mouseUp.bind(t);
			 
            addListener(document, 'mousemove', t._mouseMoveDelegate)
            addListener(document, 'mouseup', t._mouseUpDelegate);
            event.preventDefault ? event.preventDefault() : (event.returnValue = false);
            return true;
        },
        _mouseMove: function (event) {
            var t = this;
			
            if (navigator.userAgent.indexOf("MSIE") > -1 && !event.button) {
                return t._mouseUp(event);
            }
			
            if (t._mouseStarted) {
			
                t.mouseDrag(event);
                return event.preventDefault ? event.preventDefault() : (event.returnValue = false);
            }
			 
            t._mouseStarted = t.mouseStart(t._mouseDownEvent, event) !== false;
            t._mouseStarted ? t.mouseDrag(event) : t._mouseUp(event);
            return !t._mouseStarted;
        },
        _mouseUp: function (event) {
            var t = this;
            removeListener(document, 'mousemove', t._mouseMoveDelegate)
            removeListener(document, 'mouseup', t._mouseUpDelegate);
            if (t._mouseStarted) {
                t._mouseStarted = false;
                t._preventClickEvent = (event.target == t._mouseDownEvent.target);
                t.mouseStop(event);
            }
            return false;
        },
        _mouseDistanceMet: function (event) {
            var t = this;
            return Math.max(Math.abs(t._mouseDownEvent.clientX - fixEvent(event)['pageX']), Math.abs(t._mouseDownEvent.clienY - fixEvent(event)['pageY'])) >= 0;
        },
        mouseStart: function (event) { },
        mouseDrag: function (event) { },
        mouseStop: function (event) {},
        mouseCapture: function (event) { return true; }
    };
    window["islide"] = islide;
})(window);

$(function(){
	if (typeof e_data=='undefined' || e_data=='') {
		$(".sw-loading").css("background-image","url()"), SAXUE.popTip('载入图集失败');
		return
	}
	var obj = eval(e_data), _pics = [];
	$("#thumb").html('<li><a href="#p=1" hidefocus="true"><img src="'+obj[0].url+'" /></a></li>');
	var q = "", o = "";
	for(var i=0, l=obj.length; i<l; i++){
		if (obj[i].tag == '') {
			obj[i].tag = s_title;
		}
		if (obj[i].desc == '') {
			obj[i].desc = obj[i].tag;
		}
		if (i==0 && isslide!=1) {
			_pics[i] = {title:obj[i].tag, desc:obj[i].desc, timg:obj[i].url, img:obj[i].url, listimg:obj[i].url, picwidth:'', picheight:'', morelink:s_url}
		} else {
			_pics[i] = {title:obj[i].tag, desc:obj[i].desc, timg:obj[i].url, img:obj[i].url, listimg:obj[i].url, picwidth:'', picheight:'', morelink:''}
		}
		if (q != "") {
			q += "|"
		}
		q += obj[i].url;
		if (o != "") {
			o += "-jsToflaShsTr-"
		}
		o += encodeURIComponent(obj[i].tag) + "#　　" + encodeURIComponent(obj[i].desc.replace(/<.*?>/g, ""))
	}
	$("#photoNum").html(l);
	// 幻灯显示
	new islide.Gallery({
		photoViewMode:"skip", activeThumbCls:"current", data:_pics
	}); 
	// 全屏显示
	var y = saxue_skin_url+"/images/gallery.swf";
	var w = "fullscreenObj";
	var f = $("#articleText").html();
	if (f=="") {
		f = s_intro
	}
	f = encodeURIComponent(f);
	var p = {
		mylinkpic: q,
		mytxt: o,
		infotxt: s_title,
		longtext: f
	};
	var v = {};
	v.quality = "high";
	v.bgcolor = "#000000";
	v.allowscriptaccess = "always";
	v.allowfullscreen = "true";
	v.wmode = "transparent";
	var h = {};
	h.id = w;
	h.name = w;
	h.align = "middle";
	swfobject.embedSWF(y, "SI_FullScreenFlash", "90", "16", "10", "", p, v, h);
	$(".sw-loading").css("background-image","url()"), $(".sw-loading .sw-player").css("visibility","visible");
	$('#J_Fav').bind('click', SAXUE.doFav), $('#J_Top').bind('click', SAXUE.doTop), $('#J_Down').bind('click', function(e) {
		e && e.preventDefault();
		SAXUE.doDown(e,aid,'slide')
	});
	// 百度分享
	if (s_thumb.indexOf("http://")!=0){
		s_thumb = saxue_url + s_thumb
	}
	window._bd_share_config={"common":{"bdSnsKey":{},"bdText":s_intro,"bdUrl":s_url,"bdPic":s_thumb,"bdMini":"2","bdMiniList":false,"bdStyle":"1","bdSize":"16"},"share":{"bdSize":16}};
	with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
});