﻿function playSpecial(url) {
    if (/zhuanti_(\d+)\.html$/i.test(url)) {
        url = 'zhuanti_subject_' + RegExp.$1 + '_0.html';
    } 
   
   alert(url); 
    window.open(url); 
}

var PicSwitch ={
bigs:$$('#BigPicShowCnt div.BigPicElement'),
buttons:$$('#BigPicShowCnt div.Buttons span'),
lastIndex:-1,
init:function (){if (this.bigs.total() <= 1) return;if(JSAF.Browser.isMS&&JSAF.Browser.version>=4) { this.effectE = $('EffectCnt'); this.effect = true;}this.buttons.click(this.clickButton.bindAsEventListener(this)); /*$$('#BigPicShowCnt').mouseover(function(){PicSwitch.stop()}); $$('#BigPicShowCnt').mouseout(function(){PicSwitch.auto()});  */this.show(0);this.auto()}, 
filterApply: function () {
	var filter = this.randomFilter();
	this.effectE.style.filter = 'progid:DXImageTransform.Microsoft.' + filter + '()';
	try{this.effectE.filters[0].apply();}catch(e){}
},
filterPlay: function () {
	try{this.effectE.filters[0].play();}catch(e){}
},
filters: 'Barn|Blinds|CheckerBoard|Fade|GradientWipe|Inset|Iris|Pixelate|RadialWipe|RandomBars|RandomDissolve|Slide|Spiral|Stretch|Strips|Wheel|Zigzag|RevealTrans'.split('|'),
randomFilter: function(){return this.filters[Math.floor(Math.random()*this.filters.length)];},
clickButton:function (event){var index = parseInt($$(event).$('element').innerHTML); this.stop();this.show(index - 1);this.auto();},
stop:function (){if (this.interval){clearInterval(this.interval); this.interval = null}},
auto:function (){if (this.interval) return; this.interval = setInterval(this.next.bind(this),3000)}, 
next:function (){var curIndex = (this.lastIndex+1) % this.bigs.total(); this.show(curIndex)}, 
show:function (index){
if(this.effect) this.filterApply();
if (this.lastIndex >= 0) this.hide(this.lastIndex); this.bigs.css('visibility:visible', index); 
if(this.effect) this.filterPlay();
this.buttons.item(this.realIndex(index)).className = 'ActiveButton'; this.lastIndex = index}, 
realIndex:function (index){return this.bigs.total() - index - 1}, 
hide:function (index){this.bigs.css( 'visibility:hidden', index);this.buttons.item(this.realIndex(index)).className = ''}
}; 
	
var BlockSwitch = {
btpl: ['<div class="WithBarS" style="top:0px;left:{0}px;width:{1}px;display:none">','<div class="BarRight">','<div class="BarLeft">','<div class="Title" style="color:#fff;margin-top:1px;margin-left:{2}">','{3}', '</div>','</div>','</div>','<div class="BarBottom"></div>','</div>'].join('\n'),
_c: {},
_ids:[],                        
init: function () {var tpl = this.btpl;for (var i = 0; i < arguments.length; i ++) {var id = '#' + arguments[i];this._ids.push(id);$$(id).mouseover(this.stop.bind(this, id)).mouseout(this.auto.bind(this, id));var box = $$(id + ' .RealBox').item(0);this._c[id] = {};var spaceWidth = $$('div.Space[0]', box).$('offsetWidth');var titles = $$('div.Title', box);this._c[id]['titles'] = titles;this._c[id]['bodys'] = $$('div.Body', box);var marginLefts = titles.$('offsetLeft');var widths = titles.$('offsetWidth');for (var j = 0; j < marginLefts.length; j ++) {var _2 = j == 0 ? 0 : spaceWidth;var _0 = marginLefts[j] - _2;var _1 = widths[j] + _2 + spaceWidth;var node = tpl.format(_0, _1, _2, titles.html(null, j));box.appendChild($$(node));titles.item(j).onmouseover = this.show.bind(this, id, j);}this._c[id]['tips'] = $$('div.WithBarS', box);this._c[id]['last'] = -1;this.show(id, 0);this.auto();}},
auto: function (id) {
if (id && !this._ids.include(id)) {
    this._ids.push(id);
}
if(this.interval) return;this.interval=setInterval(this.next.bind(this), 4000)},
next: function () {
    for (var i = 0; i < this._ids.length; i ++) {
        var o = this._c[this._ids[i]];
        if (o.bodys.total()==0) continue; 
        this.show(this._ids[i], (o.last + 1) % o.bodys.total());
   }     
},
stop: function (id) {
if (id) {
    var ids = [];
    for (var i = 0; i < this._ids.length; i ++) {
        if (this._ids[i] != id) ids.push(this._ids[i]);
   }  
   this._ids = ids;
}
if (this._ids.length != 0) return;
if(this.interval){clearInterval(this.interval);this.interval=null}
},
show: function (id, i) {var o = this._c[id]; if(o.bodys.total() == 0) return;if (o.last !== -1) {o.tips.$('hide()', null, o.last);o.bodys.$('hide()', null, o.last);}o.tips.$('show()', null, i);o.bodys.$('show()', null, i);o.last = i;}
};

var HotWordTip={
	ajaxUrlTpl:'gethotwords.ashx?prefix={0}',
	lineTpl:'<a href="/s?wd={0}" title="{1}" class="HotWordTipLineA"><div class="HotWordTipLine"><div class="HotWordTipWord">{2}</div><div class="HotWordTipTotal">约有{3}人搜索</div></div></a>',
	qing:{},
	getResult:function(w){if(this.qing[w])return;this.qing[w]=true;var f=function(t){sr._results[w]=eval('('+t.responseText+')');HotWordTip.setResult(w);};new JSAF.Ajax.Simple(this.ajaxUrlTpl.format(w.encode()),{method:'get',onSuccess:f})},
	setResult:function(w){if(w!=this.curWord)return;var o=sr._results[w];if(o.result.length==0){tip.setText('body','没有相关搜索：（');return}var ss=[];var n = o.result.length; n = n > 9 ? 9 : n;for(var i=0;i<n;i++){var r=o.result[i];ss.push(this.lineTpl.format(r[0].encode(),r[0],r[0].truncate(18),r[1]))}tip.setText('body',ss.join(''))},
	showHotSearch:function(event){
		if (tip.checkShow(event)) return;
		w = $$(event).$('element').innerHTML;
		tip.sets.beforeShow = this.beforeShow.bind(this, w);
		},
	beforeShow: function(w) {
		this.curWord = w;
		tip.setText('title', '<span class="Head">' + '相关的热门搜索'.truncate(18) + '</span>');
		if(sr._results[w]){this.setResult(w)}else{tip.setText('body','结果加载中...');
			this.getResult(w);
			this.setted=false}
	},
	hide:function(){
		this.curWord=false;tip.hide();tip.sets.beforeShow=null;}
};
if (!window.Tip) {
	var Tip = {};	
}
Tip.showMore = function (event, e) {
		if (!tip.checkShow(event)) {
			var info = $$('div', e).html();
			var body = '<img src="' + info[0] + '" align="left"/>' + info[1];
			tip.setTextForAll({
				'title': '<span class="Head">' + e.title.truncate(16) + '</span>',
				'body': body
			});	
		}
};	
Tip.hide = function () { tip.hide(); };



