function readCookie(name){
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		};
		return null;
	};
function createCookie(name,value,days){
		var expires = "";
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			expires = "; expires="+date.toGMTString();
		};
		document.cookie = name+"="+value+expires+"; path=/";
	};
function checkboxNums(tagsname,typename,exception){
	var o=document.all.tags(tagsname);
	Nums=0
	for(var i=0;i<o.length;i++){
		if(o[i].type==typename){
			if (o[i].name!=exception) {
				if (o[i].checked==true) Nums++;
			}
		}
	}
	return Nums;
}
function del(page){
	var Nums=0;
	var Nums=checkboxNums("INPUT","checkbox","checkboxall");
	if( Nums>0 ){
		if (confirm("确定要删除所选"+Nums+"的记录吗？删除后不可以再恢复哦！\n\n您真的要要删除？")){
			document.form1.do_action.value = 'del';
			document.form1.submit();
		}
	}
	else{
		alert("对不起，您没有作出任何选择。");
	}
}
function un(chkbox){
	var form = chkbox.form;
	for(var i=0;i<form.elements.length;i++){
		var o = form.elements[i];
		if( o === chkbox ) continue;
		if(o.type=="checkbox" && o.name!='today_star_audit_userid[]'&&!o.disabled){
			o.checked =chkbox.checked;
		}
	}
}

function del_all_log(page){
	if (confirm("确定要删除这所有论坛日志？删除后不可以再恢复哦！\n\n注意：两天内的论坛日志系统会自动保留！")){
		document.form1.do_action.value = 'all_del';
		document.form1.submit();
	}
}
function search(page){
	document.form1.do_action.value = 'search';
	document.form1.submit();
}
function admin_Size(num,objname)
{
	var obj=document.getElementById(objname)
	if (parseInt(obj.rows)+num>=3) {
		obj.rows = parseInt(obj.rows) + num;	
	}
	if (num>0)
	{
		obj.width="90%";
	}
}
function helpscript(n){
	txtRun=n;window.open('helpview.php','admin_help','toolbar=no,menubar=no,scrollbars=no, resizable=1, location=no, status=no,top=0,left=0,width=600,height=300')
}
function openset(v,s){
	if (v.value=='打开高级设置'){
		document.getElementById(s).style.display = "";
		v.value="关闭高级设置";
	}
	else{
		v.value="打开高级设置";
		document.getElementById(s).style.display = "none";
	}
}
function UType(n){
	var ToUserGroup = document.getElementById("ToUserGroup");
	if (n==1&&TheForm.UserName.disabled==true){
		TheForm.UserName.disabled = false;
		ToUserGroup.style.display = "none";
	}
	else{
		TheForm.UserName.disabled=true;
		if (n==2){
			ToUserGroup.style.display = "";
		}else{
			ToUserGroup.style.display = "none";
		}
	}
}
function Getcolor(img_val,input_val){
	var obj = document.getElementById("colourPalette");
	ColorImg = img_val;
	ColorValue = document.getElementById(input_val);
	if (obj){
		obj.style.left = getOffsetLeft(ColorImg) + "px";
		obj.style.top = (getOffsetTop(ColorImg) + ColorImg.offsetHeight) + "px";
		if (obj.style.visibility=="hidden"){
			obj.style.visibility="visible";
		}
		else {
			obj.style.visibility="hidden";
		}
	}
}
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
//Colour pallete left offset
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}
function setColor(color)
{
	if (ColorValue){ColorValue.value = color;}
	if (ColorImg){ColorImg.style.backgroundColor = color;}
	document.getElementById("colourPalette").style.visibility="hidden";
}
function CheckSel(Voption,Value)
{
	var obj = document.getElementById(Voption);
	if (!obj || !('length' in obj) || 'undefined' == typeof(obj.length)) {
		return;
	}
	for (i=0;i<obj.length;i++){
		if (obj.options[i].value==Value){
		obj.options[i].selected=true;
		break;
		}
	}
}

//单选表单选取
function chkradio(Obj,Val)
{
	if (Obj)
	{
		for (i=0;i<Obj.length;i++){
			if (Obj[i].value==Val){
			Obj[i].checked=true;
			break;
			}
		}
	}
}
var ColorImg;
var ColorValue;
function hideColourPallete() {
	document.getElementById("colourPalette").style.visibility="hidden";
}
function getGroup(Did)
{
	var SGroup = fetch_object(Did);
	if (SGroup){
		if (SGroup.style.display=='none'){
			SGroup.style.top = (document.body.scrollTop+((document.body.clientHeight-1200)/2))+"px";
			SGroup.style.left = (document.body.scrollLeft+((document.body.clientWidth-460)))+"px";
			SGroup.style.display = '';
			var groupid = fetch_object("groupid");
			var SelGroupid = fetch_object("selgroupid");
			var arrayGroupElement=groupid.value.split(",");
			for(i=0;i<arrayGroupElement.length;i++){
				for(j=0;j<SelGroupid.length;j++){
					if (arrayGroupElement[i]==SelGroupid.options[j].value){
						SelGroupid.options[j].selected=true;
					}
				}
			}		
		}
		else{
			var SelGroupid = fetch_object("selgroupid");
			var groupid = fetch_object("groupid");
			var Val="";
			SGroup.style.display='none';
			if (SelGroupid){
				for (var i=0;i<SelGroupid.length;i++){
					if (SelGroupid.options[i].selected){
						Val += SelGroupid.options[i].value;
						Val += ",";
					}
				}
				groupid.value = Val.substr(0,Val.lastIndexOf(","));
			}
		}
	}
}
function get_radio_value(oForm,sAction){
	var aradios = document.getElementsByTagName("input");
	var radiaCheckFlag=0;
	for(i=0;i<aradios.length;i++){	
		if (aradios[i].type=="radio" && aradios[i].checked){
			oForm.action=sAction + aradios[i].value;
			radiaCheckFlag = 1;
			return true;
		}
	}
	if (radiaCheckFlag==0){
		alert("对不起，请作出选择！");
		return false;
	}
	return false;
}
function today_star_setaudit(chkbox)
{
	var form = chkbox.form;
	form.today_star_audit_count.value = parseInt(form.today_star_audit_count.value);
	if (form.today_star_audit_count.value < 0)	{
		form.today_star_audit_count.value = 0;
	}
	if (chkbox.checked)	{
		form.today_star_audit_count.value++;
	} else {
		form.today_star_audit_count.value--;
	}
	if (form.today_star_audit_count.value > 2) {
		alert('当前系统只允许两位今日之星！');
		if (chkbox.checked) {
			chkbox.checked = false;
			form.today_star_audit_count.value--;
		}
		return false;
	}
	return true;
}
//gather;

function CheckAll(form)  {
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name != 'chkall'&&e.type=="checkbox")
		{
			e.checked = form.chkall.checked;
		}
	}
}

//--------------------------------------2007-8-28 IvanSky DownLoad start----------------------------------------------------

function allun(chkbox){
	var form = chkbox.form;
	for(var i=0;i<form.elements.length;i++){
		var o = form.elements[i];
		if( o === chkbox ) continue;
		if(o.type=="checkbox" && o.name!='today_star_audit_userid[]'){
				if (o.checked==true){
					o.checked=false;
				}else{
					o.checked=true;
					
				}
		}
	}
}

function f_edit(page){
	Nums=0;
	Nums=checkboxNums("INPUT","checkbox","checkboxall");
	if (Nums==0){
		alert("您没有作出任何选择，不能进行编辑操作。");
	}else if (Nums>1){
		alert("对不起，你选择了（"+Nums+"）条记录，而我们只能对一条记录进行编辑。\n\n请重新选择！");
	}else{
		if (confirm("您确定要对这条记录进行编辑吗？")){
			document.f_name.action=page;
			document.f_name.submit();
		}
	}
}
function f_del(page){
	Nums=0;
	Nums=checkboxNums("INPUT","checkbox","checkboxall");
	if(Nums>0){
		if (confirm("确定要删除这（"+Nums+"）条记录吗？删除后不可以再恢复哦！\n\n您真的要删除？")){
			document.f_name.action=page;
			document.f_name.submit();
		}
	}else{
		alert("您没有作出任何选择，不能进行删除操作。");
	}
}

//--------------------------------------2007-8-28 IvanSky DownLoad end----------------------------------------------------

var servercmd=function(execurl,callbackfunc,async){
	var raiseError=function(msg){
		if(msg)alert(msg);
	}
	
	if(execurl){
		var _execurl=execurl;
	}else{
		return false;
	}
	
	if(typeof(callbackfunc)!=="function"){
		return false;
	}else{
		_callbackfunc=callbackfunc;
	}
	
	if(async!==false){
		_async=true;
	}else{
		_async=false;
	}

	var getajax=function(){
		try{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			try{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					ajax = new XMLHttpRequest();
				}catch(e){
					ajax = null;
				}
			}
		}
		return ajax;
	}
     
	evalString=function(s){
		if(s==="") return s;
		re=/\{(.+?)\}/gm;
	    try{
		   return s.replace(re,function($1){if($1){return eval($1)}else{return ""}});
		}catch(e){
		   return s
		}
    }
	
	this.execute=function(){
		var ajax=getajax();
		if(!ajax)return false;
		url=evalString(_execurl);
		if(_async){
			try{
		       ajax.onreadystatechange = function(){
				   if(ajax.readyState == 4){
					   if(ajax.status==200){
						   _callbackfunc(true,ajax.responseText);
					   }else{
						   _callbackfunc(false,[1,"",url]);
					   }
				   }
			   };
	        }catch(e){
		      return false;
	       }
		}
		ajax.open("GET", url, _async);
	    ajax.setRequestHeader("If-Modified-Since","0");
	    ajax.send(null);
		if(!_async){
			 _callbackfunc(true,ajax.responseText);
		}
	
	}
	return this;
}


function parseServerResult(s){
	arrRet=s.split("@@@");
	arr2=Array(5);
	if(arrRet.length!==5)return false;
	arr2["errno"]=parseInt(arrRet[1]);
	arr2["msg"]=arrRet[2];
	arr2["js"]=arrRet[3];
	return arr2;
}


var premenuon=false;
function switchmenuon(sender){
	if(premenuon)premenuon.className="";
	sender.className="on";
    sender.blur();
	premenuon=sender;
}
