/*

by afanmi
WWW_PHP888_COM

*/

document.write('<script text="text/javascript" src="images/cookie.js"></script>');var isIE=(document.all)?true:false;var isIE6=isIE&&([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1]==6);var $=function(id){return "string"==typeof id?document.getElementById(id):id;};var Class={create:function(){return function(){this.initialize.apply(this, arguments);}}};var Extend=function(destination,source){for(var property in source){destination[property]=source[property];}};var Bind=function(object,fun){return function(){return fun.apply(object, arguments);}};var Each=function(list,fun){for(var i=0,len=list.length;i<len;i++){fun(list[i],i);}};var Contains=function(a,b){return a.contains?a!=b&&a.contains(b):!!(a.compareDocumentPosition(b)&16);};var OverLay = Class.create();OverLay.prototype={initialize:function(options){this.SetOptions(options);this.Lay=$(this.options.Lay)||document.body.insertBefore(document.createElement("div"),document.body.childNodes[0]);this.Color = this.options.Color;this.Opacity=parseInt(this.options.Opacity);this.zIndex = parseInt(this.options.zIndex);with(this.Lay.style){display="none";zIndex=this.zIndex;left=top=0;position="fixed";width=height="100%";}if(isIE6){this.Lay.style.position = "absolute";this._resize=Bind(this,function(){this.Lay.style.width=Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)+"px";this.Lay.style.height=Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight)+"px";});this.Lay.innerHTML='<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>'}},SetOptions:function(options){this.options={Lay:null,Color:"#fff",Opacity:50,zIndex:1000};Extend(this.options,options||{});},Show:function(){if(isIE6){this._resize(); window.attachEvent("onresize",this._resize);}with(this.Lay.style){isIE?filter="alpha(opacity:"+this.Opacity+")":opacity=this.Opacity/100;backgroundColor=this.Color;display="block";}},Close:function(){this.Lay.style.display="none";if(isIE6){window.detachEvent("onresize",this._resize);}}};var LightBox=Class.create();LightBox.prototype={initialize:function(box,options){this.Box=$(box);this.OverLay=new OverLay(options);this.SetOptions(options);this.Fixed=!!this.options.Fixed;this.Over=!!this.options.Over;this.Center=!!this.options.Center;this.onShow=this.options.onShow;this.Box.style.zIndex=this.OverLay.zIndex+1;this.Box.style.display="none";if(isIE6){this._top=this._left=0;this._select=[];this._fixed=Bind(this,function(){this.Center?this.SetCenter():this.SetFixed();});}},SetOptions:function(options){this.options={Over:true,Fixed:false,Center:false,onShow:function(){}};Extend(this.options,options||{});},SetFixed:function(){this.Box.style.top=document.documentElement.scrollTop-this._top+this.Box.offsetTop+"px";this.Box.style.left=document.documentElement.scrollLeft-this._left+this.Box.offsetLeft+"px";this._top=document.documentElement.scrollTop;this._left=document.documentElement.scrollLeft;},SetCenter: function(){this.Box.style.marginTop=document.documentElement.scrollTop-this.Box.offsetHeight/2+"px";
this.Box.style.marginLeft=document.documentElement.scrollLeft-this.Box.offsetWidth/2+"px";},Show:function(options){this.Box.style.position=this.Fixed&&!isIE6?"fixed":"absolute";this.Over&&this.OverLay.Show();this.Box.style.display="block";if(this.Center){this.Box.style.top=this.Box.style.left="50%";if(this.Fixed){this.Box.style.marginTop=-this.Box.offsetHeight/2+"px"; 
this.Box.style.marginLeft=-this.Box.offsetWidth/2+"px";}else{this.SetCenter();}}if(isIE6){if(!this.Over){this._select.length=0;Each(document.getElementsByTagName("select"),Bind(this,function(o){if(!Contains(this.Box,o)){o.style.visibility="hidden";this._select.push(o);}}))}this.Center?this.SetCenter():this.Fixed&&this.SetFixed();this.Fixed&&window.attachEvent("onscroll",this._fixed);}/*this.onShow();*/},Close:function(){this.Box.style.display="none";this.OverLay.Close();if(isIE6){window.detachEvent("onscroll",this._fixed);Each(this._select,function(o){o.style.visibility="visible";});}}};

function externallinks(){if (!document.getElementsByTagName)return;var anchors=document.getElementsByTagName("a");for(var i=0;i<anchors.length;i++){var anchor=anchors[i];
if(anchor.getAttribute("href")&&anchor.getAttribute("rel")=="new")anchor.target="_blank";
}}window.onload=externallinks;

function delay(numberMillis){var now=new Date();var exitTime=now.getTime()+numberMillis;while(true){now=new Date();if(now.getTime()>exitTime)return;}}

function getXMLHTTPRequest(){var request=false;try{request=new XMLHttpRequest();}catch(trymicrosoft){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(othermicrosoft){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(failed){request=false;}}}return request;}function getPostParams(params){var buf=[],bp=params;for(var key in bp){if(typeof bp[key]!="function"){buf.push(encodeURIComponent(key),"=",encodeURIComponent(bp[key]),"&");}}buf.push("submit=","submit");return buf.join("");}function PostDataAjax(posturl,params,callbackfun){var request=getXMLHTTPRequest();if(!request){return;}request.open("POST",posturl,true);var qstr=getPostParams(params);var requestid=0;if(params['requestid']){requestid=params['requestid'];}request.setRequestHeader('Content-Length',qstr.length);request.setRequestHeader('CONTENT-TYPE','application/x-www-form-urlencoded');request.onreadystatechange=function(){if(request.readyState==0 && typeof callbackfun == 'function'){callbackfun('request.send______'+requestid);}if(request.readyState==1 && typeof callbackfun=='function'){callbackfun('request.read______'+requestid);}if(request.readyState==2 && typeof callbackfun=='function'){callbackfun('request.form______'+requestid);}if(request.readyState==3 && typeof callbackfun=='function'){callbackfun('request.load______'+requestid);}if(request.readyState==4 && request.status==200 && typeof callbackfun=='function'){callbackfun(request.responseText);}};request.send(qstr);}function GetDataAjax(pageurl,callbackfun){var request=getXMLHTTPRequest();if(!request){return;}try{request.open("GET",pageurl,true);request.onreadystatechange=function(){if(request.readyState==0 && typeof callbackfun=='function'){callbackfun('request.send');}if(request.readyState==1 && typeof callbackfun=='function'){callbackfun('request.read');}if(request.readyState==2 && typeof callbackfun=='function'){callbackfun('request.form');}if(request.readyState==3 && typeof callbackfun=='function'){callbackfun('request.load');}if(request.readyState==4 && request.status==200 && typeof callbackfun=='function'){callbackfun(request.responseText);}};request.send(null);}catch(e){}} 


function select_isvalueexit(s,v){var e=false;for(var i=0;i<s.options.length;i++){if(s.options[i].value==v){e=true;break;}}return e;}
function select_add(s,v,o){if(!select_isvalueexit(s,v)){s.options.add(new Option(o,v));}} 
function select_remove(s,v){if(select_isvalueexit(s,v)){for(var i=0;i<s.options.length;i++){if(s.options[i].value==v){s.options.remove(i);break;}}}}
function select_removeselected(s){var length=s.options.length-1;for(var i=length;i>=0;i--){if(s[i].selected==true){s.options[i]=null;}}}function select_select(s,v,o){if(select_isvalueexit(s,v)){for(var i=0;i<s.options.length;i++){if(s.options[i].value==v){s.options[i].text=o;break;}}}} 
function select_selectfirstoption(s,o){for(var i=0;i<s.options.length;i++){if(s.options[i].text==o){s.options[i].selected=true;break;}}}

//logout
function logout(){GetDataAjax("index.php?p=login&action=logout",function(a){if(a.substring(0,8)!='request.'){
	alert(a);
	self.location.href="?";
	return false;
}});}

function addbbs(m){
	var Paras=new Array();
	var p=$('postaddform');
	Paras['project']=p.project.value;
	Paras['qsta']=p.qsta.value;
	Paras['onlysayto']=p.onlysayto.value;
	Paras['sortid']=p.sortid.value;
	Paras['content']=p.content.value;
	Paras['tag']=p.tag.value;
	Paras['isaddtitle']=p.isaddtitle.checked?1:0;
	Paras['title']=p.title.value;
	Paras['isimgurl']=p.isimgurl.checked?1:0;
	Paras['isagree']=p.isagree.checked?1:0;
	if(m=='add'){
		PostDataAjax("index.php?p=bbs&action=ajaxaddaction",Paras,function(a){if(a.substring(0,8)!='request.'){
			alert(a.split('|')[0]);
			if(a.split('|')[1]){
				self.location.href=a.split('|')[1]; 
			}
			return false;
		}});
	}else if(m=='newwin'||m=='close'){
		for(var key in Paras){
			SetCookie('ADD_'+key,encodeURIComponent(Paras[key]),'h',1);
		}
		AjaxWinClose('AddbbsForm');
		if(m=='newwin')
		window.open("index.php?p=bbs&action=add&project="+GetCookie('ADD_project'));
	}
}

var box=new Array();

function AjaxWin(ajaxboxid,winclass,winfunction){
	if(!$(ajaxboxid)){
		$('WWW_PHP888_COM').innerHTML+='<div id="'+ajaxboxid+'"></div>';
	}
	$(ajaxboxid).className=winclass;
	box[ajaxboxid]=new LightBox(ajaxboxid);
	box[ajaxboxid].Over=false,//是否显示覆盖层
	box[ajaxboxid].Fixed=true,//是否固定定位
	box[ajaxboxid].Center=true,//是否居中
	box[ajaxboxid].Lay=null,//覆盖层对象
	box[ajaxboxid].OverLay.Color="#000",//背景色
	box[ajaxboxid].OverLay.Opacity=50,//透明度(0-100)
	box[ajaxboxid].OverLay.zIndex=1000//层叠顺序
	box[ajaxboxid].onShow=winfunction;
	box[ajaxboxid].Show();
}

function AjaxWinClose(ajaxboxid){
	box[ajaxboxid]=new LightBox(ajaxboxid);
	box[ajaxboxid].onShow=function(){};
//	box.Over=false,//是否显示覆盖层
	box[ajaxboxid].Close();
}


function woyaoshuohua(p){
	if(GetCookie('project'))
	p=GetCookie('project');
	if(p){
		if(box['SelectProject'])
		AjaxWinClose('SelectProject');
		AjaxWin('AddbbsForm','box_addform',PostDataAjax("index.php?p=bbs&action=addformaction&project="+p,new Array(),function(a){
			if(a.substring(0, 8)!='request.'){																						
				$("AddbbsForm").innerHTML=a;
			}else if($("AddbbsForm")){
				$("AddbbsForm").innerHTML='数据载入中';
			}
		}));
	}else{
		AjaxWin('SelectProject','box_selectproject',PostDataAjax("index.php?p=bbs&action=selectprojectaction",new Array,function(a){
			if(a.substring(0, 8)!='request.'){																						
				$("SelectProject").innerHTML=a+'<div style="text-align:right;"><a href="javascript:void(null);" onclick="AjaxWinClose(\'SelectProject\');">取消</a></div>';
			}else if($("SelectProject")){
				$("SelectProject").innerHTML='数据载入中';
			}
		}));
	}
}