;function SlideBox_(container, frequency, direction) { new SlideBox(container, frequency, direction); } //SlideBox function SlideBox(container, frequency, direction) { if (typeof(container) == 'string') { container = document.getElementById(container); } this.container = container; this.frequency = frequency; this.direction = direction; //this.films = []; //var divs = this.container.getElementsByTagName('div'); //for (var i = 0; i < divs.length; i++) { //if (divs.className == 'slideFilm') { this.container.onmouseover = function(self){return function(){self._mouseover()};}(this); this.container.onmouseout = function(self){return function(){self._mouseout()};}(this); //this.films[this.films.length] = divs; //} //} this._playTimeoutId = null; this._slideTimeoutId = null; this._slidable = true; this._loop(); } SlideBox.prototype = { _loop : function() { var sb = this; this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency); }, _slide : function() { var sb = this; var _slide = function() { if (!sb._slidable) return; var c = sb.container; if (sb.direction == 'top') { if (c.scrollTop < c.offsetHeight-2) { c.scrollTop += 2; } else { clearInterval(sb._slideTimeoutId); sb._loop(); var ul = c.getElementsByTagName('ul')[0]; ul.appendChild(c.getElementsByTagName('div')[0]); c.scrollTop = 0; } } else if (sb.direction == 'left') { if (c.scrollLeft < c.offsetWidth-2) { c.scrollLeft += 2; } else { clearInterval(sb._slideTimeoutId); sb._loop(); var ul = c.getElementsByTagName('ul')[0]; ul.appendChild(c.getElementsByTagName('div')[0]); c.scrollLeft = 0; } } } this._slideTimeoutId = setInterval(_slide, 10); }, _mouseover : function() { this._slidable = false; }, _mouseout : function() { this._slidable = true; } } ;//the style for contentslider document.writeln(''); //contentslider 08.12.09 var featuredcontentslider={ ajaxloadingmsg: '请稍候…', bustajaxcache: false, enablepersist: false, settingcaches: {}, buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div") for (var i=0; itotalpages)? 1 : turntopage //test for out of bound and adjust if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly return setting.currentpage=turntopage setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex this.cleartimer(setting, window["fcsfade"+setting.id]) setting.cacheprevpage=setting.prevpage if (setting.enablefade[0]==true){ setting.curopacity=0 this.fadeup(setting) } if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete) setting.onChange(setting.prevpage, setting.currentpage) } setting.contentdivs[turntopage-1].style.visibility="visible" setting.contentdivs[turntopage-1].style.display="block" if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[setting.prevpage-1], "selected", "remove") if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[turntopage-1], "selected", "add") setting.prevpage=turntopage if (this.enablepersist) this.setCookie("fcspersist"+setting.id, turntopage) }, ajaxconnect:function(setting){ var page_request = false if (window.ActiveXObject){ //IE中的 ActiveXObject 支持,对于IE7是无效的 try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else if (window.XMLHttpRequest) // Mozilla, Safari 等浏览器 page_request = new XMLHttpRequest() else return false var pageurl=setting.contentsource[1] page_request.onreadystatechange=function(){ featuredcontentslider.ajaxpopulate(page_request, setting) } document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', pageurl+bustcache, true) page_request.send(null) }, ajaxpopulate:function(page_request, setting){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(setting.id).innerHTML=page_request.responseText this.buildpaginate(setting) } }, buildpaginate:function(setting){ this.buildcontentdivs(setting) var sliderdiv=document.getElementById(setting.id) var pdiv=document.getElementById("paginate-"+setting.id) var phtml="" var toc=setting.toc var nextprev=setting.nextprev if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){ for (var i=1; i<=setting.contentdivs.length; i++){ phtml+=''+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+' ' } phtml=(nextprev[0]!=''? ' ' : '') + phtml + (nextprev[1]!=''? '' : '') pdiv.innerHTML=''+phtml+'' } var pdivlinks=pdiv.getElementsByTagName("a") var toclinkscount=0 //var to keep track of actual # of toc links for (var i=0; isetting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents) pdivlinks[i].style.display="none" //hide this toc link continue } pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link pdivlinks[i][setting.revealtype]=function(){ featuredcontentslider.turnpage(setting, this.getAttribute("rel")) return false } setting.toclinks.push(pdivlinks[i]) } else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next" pdivlinks[i].onclick=function(){ featuredcontentslider.turnpage(setting, this.className) return false } } } this.turnpage(setting, setting.currentpage, true) if (setting.autorotate[0]){ //当设置为自动轮换时,即 autorotate 为 true 时 pdiv[setting.revealtype]=function(){ return false } pdiv["onmouseover"]=function(){ featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id])// onmouseover,停止自动轮换 return true } pdiv["onmouseout"]=function(){ featuredcontentslider.autorotate(setting)// onmouseout 后,继续自动轮换 return true } sliderdiv["onmouseover"]=function(){ featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) return true } sliderdiv["onmouseout"]=function(){ featuredcontentslider.autorotate(setting) return true } setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*80) //添加轮换停留时间 this.autorotate(setting) } }, urlparamselect:function(fcsid){ var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index }, cleartimer:function(setting, timervar){ if (typeof timervar!="undefined"){ clearTimeout(timervar) clearInterval(timervar) if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div setting.contentdivs[setting.cacheprevpage-1].style.display="none" } } }, css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") else if (action=="add") el.className+=" "+targetclass }, autorotate:function(setting){ window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1]) }, getCookie:function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null }, setCookie:function(name, value){ document.cookie = name+"="+value }, iframeconnect:function(setting){ //增加iframe处理事件,支持iframe的轮换,但iframe与div的相互组合目前不能完成,即轮换内容既有iframe的内容又有div的内容的时候 var ifr = document.createElement('iframe'); ifr.id='iframeconnect'+new Date().getTime(); ifr.style.display='none'; var self = this; var got = function(){ var d = ifr.contentDocument ? ifr.contentDocument : document.frames[ifr.id].document; document.getElementById(setting.id).innerHTML=d.body.innerHTML; document.body.removeChild(ifr); self.buildpaginate(setting) }; ifr.onload=got; ifr.onreadystatechange=function(){ if(this.readyState=='complete') got(); } ifr.src = setting.contentsource[1]; document.body.insertBefore(ifr,document.body.firstChild); }, init:function(setting){ var persistedpage=this.getCookie("fcspersist"+setting.id) || 1 var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index this.settingcaches[setting.id]=setting //存储 "setting" 对象 setting.contentdivs=[] setting.toclinks=[] setting.topzindex=0 setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1)//默认显示模块 setting.prevpage=setting.currentpage setting.revealtype="on"+(setting.revealtype || "click") setting.curopacity=0 setting.onChange=setting.onChange || function(){} if (setting.contentsource[0]=="inline")//直接页面调用div this.buildpaginate(setting) if (setting.contentsource[0]=="ajax")//调用外部utf-8页面内容 this.ajaxconnect(setting) if (setting.contentsource[0]=="iframe")//调用外部页面内容,主要以iframe形式获取,获取iframe内标签,主要解决非utf-8的内容 this.iframeconnect(setting) } } ;function siteLinksSelector(site,siteLinks){ var THIS = this; this.site = document.getElementById(site); this.siteLinks = document.getElementById(siteLinks); this.site.onclick = function(){ if(THIS.siteLinks.style.display=='none'){ THIS.siteLinks.style.display='block'; THIS.site.className='tag_select_open' }else{ THIS.siteLinks.style.display='none'; THIS.site.className='tag_select' } } this.siteLinks.onmouseout = function(){ THIS.siteLinks.style.display='none'; THIS.site.className='tag_select' } this.siteLinks.onmouseover = function(){ THIS.siteLinks.style.display='block'; THIS.site.className='tag_select_open' } }