////////////////////////////////////////////////////////////////////////////////////////
// 
// 
// 公共ＪＳ调用页
//
//
///////////////////////////////////////////////////////////////////////////////////////


// 站内信息弹出框
function MessagePostWindow(Url)
{
	window.open(Url,'','width=430,height=420,status=no,resizable=yes,scrollbars=yes');
}


////////////////////////////////////////////////////////
//
// 将高度和宽度超过的图片强行缩小
//
////////////////////////////////////////////////////////
function imgload(e)
{
	imgloadChange();

	var oImg = document.images;
	var oClientSreen=0;
	for(var i=0;i<oImg.length;i++) 
	{
		if ( oImg[i].id.indexOf("PicSignture") != -1 )
		{
			// 基本上是限制签名档中图片的大小
			oClientSreen=600;
			if(oImg[i].height>250 && oImg[i].width<oClientSreen) {oImg[i].style.height=250;}
			if(oImg[i].width>oClientSreen) {oImg[i].style.width=oClientSreen-10;}
		}
		if ( oImg[i].id.indexOf("PicPost") != -1 )
		{
			// 基本上是限制贴中图片的大小
			oClientSreen=700;
			if(oImg[i].height>600 && oImg[i].width<oClientSreen) {oImg[i].style.height=600;}
			if(oImg[i].width>oClientSreen) {oImg[i].style.width=oClientSreen-10;}
		}
		if (oImg[i].id.indexOf("imgFace") != -1) 
		{
			if ( oImg[i].width == 28 && oImg[i].height == 30  )
			{
				oImg[i].src = "../Lib/Images/DefaultPhoto.gif";
			}
			else
			{
				if(oImg[i].height>200 ) {oImg[i].style.height=200;}
				if(oImg[i].width>150) {oImg[i].style.width=150;}
			}
		}
	}
}

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 Redirect()
{

	if(document.all('BbsTopic_BbsLimitPage_txtPageNum')!=null)
	{
		PageNum = document.all('BbsTopic_BbsLimitPage_txtPageNum').value;
	}
	else if( document.all('BbsLimitPage_txtPageNum')!=null)
	{	
		PageNum = document.all('BbsLimitPage_txtPageNum').value;
	}
	else
	{
		return;
	}
	

	if( PageNum=="" )
	{
		alert("请输入要跳转的页面!");
		return;
	}
	var arrParameter
	var str = "url=";
	var tmp = "";
	var i;
	var Url = document.location.href;
	var num = Url.indexOf(str);
	if( num>0 )
	{
		tmp = Url.substring(num + str.length);
		arrParameter = tmp.split(",");
		if( arrParameter.length==6 )
		{
			arrParameter[4] = PageNum;
		}
		Url = Url.substring(0,num+str.length);
		for( i=0;i<6;i++ )
		{
			Url = Url + arrParameter[i];
			if( i!=5 ) Url = Url + ",";
		}
	}
	else
	{
		str = "page=";
		num = Url.indexOf(str);
		if( num>0 )
		{
			tmp = Url.substring(0,num + str.length);
		}
		else
		{
			if( Url.indexOf("?")>0 )
			{
				tmp = Url + "&page=";
			}
			else
			{
				tmp = Url + "?page=";
			}
			
		}
		Url = tmp + PageNum;
	}
	document.location.href = Url;
}

////////////////////////////////////////////////////////
//
// 论坛页面互转函数
//
////////////////////////////////////////////////////////
function Change_Page(curvalue)
{
	//var arrParameter
	//var str = "url=";
	//var tmp = "";
	//var i;
	//var Url = document.location.href;
	//var num = Url.indexOf(str);
	//tmp = Url.substring(num + str.length);
	//arrParameter = tmp.split(",");
	//if( arrParameter.length==6 )
	//{
	//	arrParameter[1] = curvalue;
	//	Url = Url.substring(0,num+str.length);
	//	for( i=0;i<6;i++ )
	//	{
	//		Url = Url + arrParameter[i];
	//		if( i!=5 ) Url = Url + ",";
	//	}
	//}
	//else
	//{
	//	Url = "listtopic.aspx?url=0," + curvalue + ",0,0,1,0";
	//}
	// 上述出现问题的原因是当前页面是viewtopic.aspx的时候会出现问题

	var Url = "";
	Url = "listtopic.aspx?url=0," + curvalue + ",0,0,1,0";
	document.location.href = Url;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//	移植于91com项目中的script/public.js
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
//
// 注册成为９１ＣＯＭ用户表单验证函数 
//
////////////////////////////////////////////////////////

function Check_UserName(theform)		//----用户名有效性验证时判断是否有输入用户名
{
	if (!checkvalue(theform.txtUserName,4,20,32,"用户名"))	return false;
	if (!CheckIfEnglish(theform.txtUserName.value))
	{
		alert("用户名只能由字母和数字组成!");
		theform.txtUserName.focus();
		theform.txtUserName.select();
		return false;
	}
}

function Check_Reg91Com(theform)		//----注册信息提交时验证相关信息是否有填写正确
{
	//客户端验证
	/*
	用 户 名:txtUserName
	用户昵称:txtNickName
	真实姓名:txtTrueName
	登录密码:txtPassword1
	确认密码:txtPassword2
	电子信箱:txtEmail
	问　　题:txtQuestion
	答　　案:txtAnswer
	认 证 号:RndNumber
	*/

	if (!checkvalue(theform.txtUserName,4,20,32,"用户名"))	return false;
	if (!CheckIfEnglish(theform.txtUserName.value))
	{
		alert("用户名只能由字母和数字组成!");
		//theform.txtUserName.focus();
		//theform.txtUserName.select();
		return false;
	}


	if (document.all("txtUserName").disabled!=true )
	{
		if( theform.txtNickName.value.indexOf("@")>=0 )
		{
			alert("用户昵称中不能含有@");
			//theform.txtNickName.focus();
			//theform.txtNickName.select();
			return false;
		}
		if (!checkvalue(theform.txtNickName,0,0,1,"用户昵称"))	return false;
		if (checkIsNull(theform.txtNickName.value))
		{
			alert("用户昵称中不能含有空格!");
			//theform.txtNickName.focus();
			//theform.txtNickName.select();
			return false;
		}
	}
	
	//if (!checkvalue(theform.txtTrueName,1,8,32,"真实姓名"))	return false;
	if (!checkvalue(theform.txtPassword,6,32,32,"密码"))	return false;
	if (!CheckIfEnglish(theform.txtPassword.value))
	{
		alert("密码只能由字符和数字组成!");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
	if (!checkvalue(theform.txtConfirmPassword,6,32,32,"确认密码"))	return false;
	if (!CheckIfEnglish(theform.txtConfirmPassword.value))
	{
		alert("确认密码只能由字符和数字组成!");
		theform.txtConfirmPassword.focus();
		theform.txtConfirmPassword.select();
		return false;
	}	
	if(theform.txtPassword.value!=theform.txtConfirmPassword.value)
	{
		alert("两次输入密码不正确！");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
	
	/*
	if(!checkvalue(theform.txtEmail,0,0,1,"电子邮箱"))	return false;
	if(!checkemail(theform.txtEmail.value))
	{
		alert("您输入的电子邮箱格式不正确!");
		theform.txtEmail.focus();
		theform.txtEmail.select();
		return false;
	}
	if(!checkvalue(theform.txtQuestion,6,32,32,"密码找回问题"))	return false;
	if(checkIsNull(theform.txtQuestion.value))
	{
		alert("密码找回问题不能含有空格!");
		theform.txtQuestion.focus();
		theform.txtQuestion.select();
		return false;
	}
	if(!checkvalue(theform.txtAnswer,6,32,32,"密码找回答案"))	return false;
	if(checkIsNull(theform.txtAnswer.value))
	{
		alert("密码找回答案不能含有空格!");
		theform.txtAnswer.focus();
		theform.txtAnswer.select();
		return false;
	}
	*/
	
	////////////////////////////////////////////////////////
	//
	// 扩展：９１ＣＯＭ用户信息编辑表单验证函数 
	//
	// 验证交友信息
	//
	////////////////////////////////////////////////////////
	if(document.all("Panel_FriendInfo")!=null)
	{
	
		if(!checkvalue(theform.txtAge,0,0,1,"年龄"))	return false;
		if(!checkvalue(theform.txtAge,0,0,2,"年龄"))		return false;
		if(theform.txtAge.value>100)
		{
			alert("请输入您的实际年龄!");
			theform.txtAge.focus();
			theform.txtAge.select();
			return false;
		}
	
		if(theform.txtMobile.value!="")
		{
			if(!checkvalue(theform.txtMobile,0,0,8,"手机"))		return false;
			if(theform.txtMobile.value.length<11 || theform.txtMobile.length>12)
			{
				alert("手机号码位数不正确!");
				theform.txtMobile.focus();
				return false;
			}
		}
		
		if(!checkvalue(theform.txtIntroduce,0,0,1,"个人介绍"))		return false;
		
		if(theform.dlGameClass.value=="0")
		{
			alert("请选择游戏类别!");
			theform.dlGameClass.focus();
			return false;
		}
		
		if(theform.txtLikeGame.value=="")
		{
			alert("请填写您最喜欢的游戏!");
			theform.txtLikeGame.focus();
			return false;
		}
		
		if(theform.txtGameServer.value=="")
		{
			alert("请填写您所在的游戏服务器!");
			theform.txtGameServer.focus();
			return false;
		}
		
		if(theform.txtGameRole.value=="")
		{
			alert("请填写您在游戏中的角色!");
			theform.txtGameRole.focus();
			return false;
		}
		
		if(theform.dlAstro.value==0)
		{
			alert("请选择您的星座!");
			theform.dlAstro.focus();
			return false;
		}
		
		if(theform.dlStature.value==0)
		{
			alert("请选择您的身高!");
			theform.dlStature.focus();
			return false;
		}
		
	}
	
}

// 站内头部社区公告
function announcement() {
	$('announcement').innerHTML = '<marquee style="filter:progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=10, finishY=100,style=1,opacity=0,finishOpacity=100); margin: 0px 8px" direction="left" scrollamount="2" scrolldelay="1" height="30" onMouseOver="this.stop();" onMouseOut="this.start();">' +
		$('announcement').innerHTML + '</marquee>';
	$('announcement').style.display = 'block';
}
function $(id) {
	return document.getElementById(id);
}