	document.write('<script language="javascript1.1" type="text/javascript" src="/blog/newstatics/BlogAdminMade/topic/js2/prototype.js"></script>');

	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	
	function MM_showHideLayers() { //v3.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
		obj.visibility=v; }
	}
	
	function window_onload(){
		PageWorker.render();
	}
	
	function newtemplate_process(newtemplatetip,template_name,filename_tmp){
    	var divstr='';
    	newtemplatetip='0'; 
			var r=Math.random();
			var c=template_name;
			var d=filename_tmp;
			var ajax = new Ajax.Request(
				'/blog/newstatics/BlogAdminMade/topic/blogspace/'+d+'/order_terminal.xml'+'?r='+r,
				{method:'get',
				asynchronous: false,
				onComplete: function(r){
				    if(r.status==200){
						var tmp_div,tmp1,tmp2,tmp3,tmp4;
						var xml=r.responseXML.documentElement;
						var div = xml.getElementsByTagName('div');
						for(var i=0;i<div.length;i++){
							tmp_div=div[i].firstChild.nodeValue;
							tmp1=tmp_div.split('(');
							tmp2=tmp1[0];
							tmp3=tmp1[1].substring(0,tmp1[1].length-1);
							tmp4=unescape(tmp3);
							if (tmp3!=''){ 
								var seldiv = document.getElementById(tmp2);  		
									seldiv.style.overflow='hidden';
									var ajax = new Ajax.Updater(
												seldiv,
												tmp4,
												{method:'get',
													requestHeaders:['Cache-Control','no-cache','Expires','0','If-Modified-Since','0'],
													asynchronous: true,
													evalScripts: true}
									);									
							}
						}
					}else{
						alert('　相关模板属性定义文件不存在! 错误编号:　'+r.status);
					}
				}
				}
			);
    }
    

    

function getQuery(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) return unescape(r[2]);
		var reg2 = new RegExp("/c(\\d+)/t(\\d+)","i");
     var r2=window.location.href.substr(1).match(reg2);
     if(r2!=null){
    	 return unescape(r2[2]);
    }
    return null;
}

var topic_id=getQuery('topicid');
//这里也可以直接给，而不用从参数里取
//topic_id=72;
var exe_script=function(url){
	var ajax=new Ajax.Request(
	url,
	{
		method:'get',
		requestHeaders:['Cache-Control','no-cache','Expires','0','If-Modified-Since','0'],
		asynchronous:false,
		onComplete: function(r){	
		//	alert(r.responseText);
		r.responseText.evalScripts();
		}
	}
	);
}

var loading=function(url,tdiv){
		//这里为了保证，不取到内部的cache
	var syn=true;
	if(url.indexOf('title')>-1 || url.indexOf('protal_block')>-1){
		syn=false;
	}
//	div=tdiv;
//	while($(tdiv)){break;}
	if(arguments[2]==false) syn=arguments[2];
	var ajax = new Ajax.Updater(
	{success: tdiv},
	url,
	{method:'get',
		requestHeaders:['Cache-Control','no-cache','Expires','0','If-Modified-Since','0'],
		asynchronous: syn,
//		onComplete:function(e){
//
//		},
	evalScripts: true}
	);
};

var Shake={
		init:function(obj,times,range){
				var t=obj.getStyle('margin-left');
				t=t.substring(0,t.length-2);
				this.x=parseInt(t);
				this.p=this.x;
				this.times=times;
				this.obj=obj;
				this.shaking=true;
				Shake.anim(range,1);
				this.shaking=false;
		},
		anim:function(xk,smer)
			{this.times--;
	if(this.times<0) {
		this.obj.setStyle({
 	margin:'0 '+this.p+'px'
});
return;}
 this.obj.setStyle({
 	margin:'0 '+this.x+'px'
});

 this.x =this.p+xk*smer;
 
 if(smer==1){
 	smer=-1;
 	}else{
	smer=1;}

  setTimeout('Shake.anim('+xk+','+smer+')', 100);
		}
	};

//计算当前屏幕位置
var viewport = {
						getWinWidth: function () {
						this.width = 0;
						if (window.innerWidth) this.width = window.innerWidth - 18;
						else if (document.documentElement && document.documentElement.clientWidth)
						this.width = document.documentElement.clientWidth;
						else if (document.body && document.body.clientWidth)
						this.width = document.body.clientWidth;
						},
						
						getWinHeight: function () {
						this.height = 0;
						if (window.innerHeight) this.height = window.innerHeight - 18;
						else if (document.documentElement && document.documentElement.clientHeight)
						this.height = document.documentElement.clientHeight;
						else if (document.body && document.body.clientHeight)
						this.height = document.body.clientHeight;
						},
						
						getScrollX: function () {
						this.scrollX = 0;
						if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
						else if (document.documentElement && document.documentElement.scrollLeft)
						this.scrollX = document.documentElement.scrollLeft;
						else if (document.body && document.body.scrollLeft)
						this.scrollX = document.body.scrollLeft;
						else if (window.scrollX) this.scrollX = window.scrollX;
						},
						
						getScrollY: function () {
						this.scrollY = 0;
						if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
						else if (document.documentElement && document.documentElement.scrollTop)
						this.scrollY = document.documentElement.scrollTop;
						else if (document.body && document.body.scrollTop)
						this.scrollY = document.body.scrollTop;
						else if (window.scrollY) this.scrollY = window.scrollY;
						},
						
						getAll: function () {
						this.getWinWidth(); this.getWinHeight();
						this.getScrollX(); this.getScrollY();
						if(arguments[0] && arguments[1]){
							this.div_top=this.height/2+this.scrollY-arguments[0]/2;
							this.div_left=this.width/2-arguments[1]/2;
						}
						if(arguments[2]){
							arguments[2].setStyle(
							{
								position : 'absolute', 
								top : this.div_top+'px',//要居中还要算上你的div的面积  
             		left :  this.div_left+'px'
								}
							);
						}}
						
					};

var PageWorker={

	render:function(){
		loading('/blog/topic/topic_toolbar.jspe','topic_toolbar');
		//如果是文字式的，这里就不管了
		if(topic_id!=null){
			
				exe_script('/blog/newstatics/topic/'+topic_id+'_topic_script.html');
			}
	}
};

function swapCon(n){
	try{
	for(var i=1;i<=6;i++){
		var curBtn=document.getElementById("d_"+i);
		if(n==i){
			curBtn.className="subnav2";
		}else{
			curBtn.className="subnav4";
		}
	}
}catch(e){}
}