document.charset = "gb2312";
var menuOffX=0	
var menuOffY=18	
var vBobjects = new Array();
var fo_shadows=new Array();
var linkset=new Array();
var boardid=0;
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers
var xslDoc;
var cache={};
var xmlhttp = HttpObj();
var forumpath="./"
function HttpObj(){
	var xmlhttp = null;
	try{
		xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
	}catch(e){
		try{
			xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
		}catch(e){
			try{
				xmlhttp= new XMLHttpRequest();
			}catch(e){}
		}
	}
	if (xmlhttp) return xmlhttp;
}
function MM_findObj(n, d) {
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 && d.getElementById) x=d.getElementById(n); return x;

} 
function fetch_object(idname, forcefetch)
{
	if (typeof(vBobjects[idname]) == "undefined")
	{
		vBobjects[idname] = MM_findObj(idname);
	}
	return vBobjects[idname];
}

function ie_y(e){  
	var t=e.offsetTop;  
	while(e=e.offsetParent){  
		t+=e.offsetTop;  
	}  
	return t;  
}  
function ie_x(e){  
	var l=e.offsetLeft;  
	while(e=e.offsetParent){  
		l+=e.offsetLeft;  
	}  
	return l;  
}  
function ie_dropshadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		var rect = document.createElement('div');
		var rs = rect.style
		rs.position = 'absolute';
		rs.left = (el.style.posLeft + i) + 'px';
		rs.top = (el.style.posTop + i) + 'px';
		rs.width = el.offsetWidth + 'px';
		rs.height = el.offsetHeight + 'px';
		rs.zIndex = el.style.zIndex - i;
		rs.backgroundColor = color;
		var opacity = 1 - i / (i + 1);
		rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
		fo_shadows[fo_shadows.length] = rect;
	}
}
function ie_clearshadow()
{
	for(var i=0;i<fo_shadows.length;i++)
	{
		if (fo_shadows[i])
			fo_shadows[i].style.display="none"
	}
	fo_shadows=new Array();
}


function contains_ns6(a, b) {
	while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
	return false;
}

function hidemenu(){
	if (window.menuobj)
		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
	ie_clearshadow()
}

function dynamichide(e){
	e=fixE(e);

	if (ie4&&!menuobj.contains(e.toElement))
		hidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		hidemenu()
}

function delayhidemenu(){
	if (ie4||ns6||ns4)
		delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
	if (window.delayhide)
		clearTimeout(delayhide)
}

function highlightmenu(e,state){
	if (document.all)
		source_el=event.srcElement
	else if (document.getElementById)
		source_el=e.target
	if (source_el.className=="menuitems"){
		source_el.id=(state=="on")? "mouseoverstyle" : ""
	}
	else{
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems"){
				source_el.id=(state=="on")? "mouseoverstyle" : ""
			}
		}
	}
}

function fixE(e){var e;e=e?e:(window.event?window.event:null);return e}

if (ie4||ns6)
document.onclick=hidemenu
function doSClick() {
	var targetId, srcElement, targetElement, imageId, imageElement;
	srcElement = window.event.srcElement;
	targetId = srcElement.id + "content";
	targetElement = document.all(targetId);
	imageId = srcElement.id;
	imageId = imageId.charAt(0);
	imageElement = document.all(imageId);
	if (targetElement.style.display == "none") {
		imageElement.src = "Skins/Default/minus.gif"
		targetElement.style.display = "";
	} else {
		imageElement.src = "Skins/Default/plus.gif"
		targetElement.style.display = "none";
	}
}
function doClick() {
	var targetId, srcElement, targetElement;
	srcElement = window.event.srcElement;
	targetId = srcElement.id + "_content";
	targetElement = document.all(targetId);
	if (targetElement.style.display == "none") {
		srcElement.src = "Skins/Default/minus.gif"
		targetElement.style.display = "";
	} else {
		srcElement.src = "Skins/Default/plus.gif"
		targetElement.style.display = "none";
	}
}
function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}
function imgzoom(img,maxsize){
	var a=new Image();
	a.src=img.src
	if(a.width > maxsize * 4)
	{
		img.style.width=maxsize;
	}
	else if(a.width >= maxsize)
	{
		img.style.width=Math.round(a.width * Math.floor(4 * maxsize / a.width) / 4);
	}
	return false;
}

//图片自动调整的模式，1为按比例调整 ，2 按大小调整。
var resizemode=2;
function imgresize(o){
	if (resizemode==2 || o.onmousewheel){
		if(o.width > 500 ){
			o.style.width='500px';
		}
		if(o.height > 800){
			o.style.height='800px';
		}
	}
	else{
		var parentNode=o.parentNode.parentNode
		if (parentNode){
			if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
		}
		else{
			var parentNode=o.parentNode
			if (parentNode){
				if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
			}
		}
	}
}
function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}
function boardbarover(obj)
{
	obj.className = obj.className.indexOf("mainbarhover")>0? "mainbar":"mainbar mainbarhover";
}
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}

function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}
function postUrl(poststyle,act,bid,stype){
	var thisUrl ="post.asp?poststyle="+poststyle+"&action="+act+"&boardid="+bid+"&stype="+stype;
	return thisUrl; 
}

function close_postform(){
			var obj=document.getElementById("post_div");
			if (obj.style.display!="none"){
			obj.style.display="none";
			document.getElementById("post_iframe").src="";
			}
}

function post_topic(buttonElement,pstyle,act,bid,stype){
	var obj=document.getElementById("post_div");
	var buttonElement = document.getElementById("postbutton");
	if (pstyle!="1"){
		return this.location = postUrl(pstyle,act,bid,stype);
	}
	if (obj.style.display=="none")
		{
			obj.style.display="block";
			document.getElementById("post_iframe").style.height="760px";
			document.getElementById("post_iframe").src=postUrl(pstyle,act,bid,stype);
	}else {
			obj.style.display="none";
			document.getElementById("post_iframe").src="";
	}
};


function ActiveOnline(boardid)
{
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				updateonline(xmlhttp.responseText);		
			}else{}
		}
	}
	var param="state="+escape(document.title.toString())+"&boardid="+boardid;
	xmlhttp.open("post","activeonline.asp",true);	
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-Length",param.length); 
	xmlhttp.send(param);
}

function updateonline(XMLstr)
{
	eval(XMLstr);
	var AllOnlie=document.getElementById("allonline");
	var UserOnlie=document.getElementById("useronline");
	var GuestOnlie=document.getElementById("guestonline");
	if(AllOnlie) AllOnlie.innerHTML=allonline.toString();
	if(UserOnlie) UserOnlie.innerHTML=useronline.toString();
	if(GuestOnlie) GuestOnlie.innerHTML=guestonline.toString();

}

var cacheobj=function(){};
//浮动窗口效果
var ShadeDiv = {
	objid : null,
	Shade : document.createElement('div'),
	ShadeID : 'Shade',
	width : 400,
	height : 300,
	Position : function(){
		if (!ShadeDiv.objid){
			ShadeDiv.objid = null;
			return;
		}
		var de = document.documentElement;
		var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
		var ch = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
		if (self.pageYOffset) {
			var st = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			var st = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			var st = document.body.scrollTop;
		}
		if (window.innerHeight && window.scrollMaxY) {	
			var sh = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			var sh = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			var sh = document.body.offsetHeight;
		}
		ShadeDiv.Shade.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=40,finishOpacity=100,style=0)';
		ShadeDiv.Shade.style.height = (sh > ch ? sh : ch) + 'px';
		ShadeDiv.Shade.style.width = w + 'px';
		ShadeDiv.Shade.style.position = "absolute";
		ShadeDiv.Shade.style.left = 0;
		ShadeDiv.Shade.style.top = 0;
		ShadeDiv.Shade.style.zIndex = 2;
		ShadeDiv.Shade.style.backgroundColor = '#333333';
		var pos = [], pw;
		pw = ShadeDiv.width;
		pos[0] = (w-pw)/2;
		pos[1] = (ch-(ShadeDiv.height || 300))/2 + st;
		//window.status="ch:"+ch+"st:"+st+"post[1]:"+pos[1]+"ShadeDiv.clientHeight"+ShadeDiv.objid.clientHeight;
		if (navigator.product && navigator.product == 'Gecko'){
			pw -= 40;
		}
		ShadeDiv.objid.style.position='absolute';
		ShadeDiv.objid.style.width = ShadeDiv.width + 'px';
		ShadeDiv.objid.style.height = ShadeDiv.height + 'px';
		ShadeDiv.objid.style.left = pos[0] + 'px';
		ShadeDiv.objid.style.top = pos[1] + 'px';
		ShadeDiv.Shade.style.display = 'block';
		ShadeDiv.objid.style.display = 'block';
	},
	Show : function(id,w,h,src){
		ShadeDiv.height = parseInt(h);
		ShadeDiv.width = parseInt(w);
		ShadeDiv.Shade.id = ShadeDiv.ShadeID;
		ShadeDiv.objid = document.getElementById(id);
		document.body.insertBefore(ShadeDiv.Shade,null);
		ShadeDiv.Position();
		
		if (document.getElementById("iframeContent")) document.getElementById("iframeContent").src=src;}
	,
	//如：<a href="#" onclick="ShadeDiv.ShowFrame('链接文件地址&sh=300&sw=500',this);" title="txt">test</a>
	ShowFrame  : function(link,linkobj,linktitle){
		var gethref=link;
		if (!gethref){return;}
		if(gethref.indexOf("?")==-1){return;}
		var queryString = gethref.replace(/^[^\?]+\??/,'');
		var params = parseQuery( queryString );
		var sh,sw;
		sw = (params["sw"]*1) || 750;
		sh = (params["sh"]*1) || 550;
		var ShadeFrame = document.createElement('div');
		ShadeFrame.id = ShadeDiv.ShadeID + "_frame";
		ShadeFrame.name = ShadeDiv.ShadeID + "_frame"+Math.round(Math.random()*1000);
		ShadeFrame.style.width = sw+"px";
		ShadeFrame.style.height = sh+"px";
		ShadeFrame.style.zIndex = 100;
		document.body.appendChild(ShadeFrame);
		var divhtml = "<div class='titlebg' style='width:100%;OVERFLOW-X:hidden;'>  <img src='/img/close.gif' alt='关闭' class='imgonclick' style='float:right;margin-right:5px;margin-top:5px;' onclick='ShadeDiv.Close();' />&nbsp;&nbsp;&nbsp;&nbsp;"+linktitle+"</div>"
		divhtml += "<iframe frameborder='0' scrolling='no' hspace='0' src='' id='iframeContent' name='_iframeContent"+Math.round(Math.random()*1000)+"' style='width:"+sw+"px;height:"+(sh-30)+"px;'> </iframe>"
		ShadeFrame.innerHTML = divhtml;		
		ShadeDiv.Show(ShadeFrame.id,sw,sh,gethref);
		//if (linkobj!="")linkobj.target=null;
		//return false;
	},
	
	Close : function(){
		if (ShadeDiv.objid==null){
			return;
		}
		ShadeDiv.Confirmed();
	},

	Confirmed : function() {
		ShadeDiv.objid.style.display = 'none';
		ShadeDiv.Shade.style.display = 'none';
		document.body.removeChild(ShadeDiv.objid);
		document.body.removeChild(ShadeDiv.Shade);
		
	}

}

//页面完成后加载事件列表
function show_news(src,title){
if (src!=''){
	ShadeDiv.ShowFrame(src,this,title);
	}
}

function closewindow(){
   ShadeDiv.Close();
}
//url参数分割
function parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}
