// the flag of web finished
var EndFlag = 1;

// 问候语提示
function ShowHello() {
	var welcomestring;
	var d = new Date();	
	h = d.getHours();
	if(h<6)
		welcomestring="凌晨好";
	else if (h<9)
		welcomestring="早上好";
	else if (h<12)
		welcomestring="上午好";
	else if (h<14)
		welcomestring="中午好";
	else if (h<17)
		welcomestring="下午好";
	else if (h<19)
		welcomestring="傍晚好";
	else if (h<22)
		welcomestring="晚上好";
	else
		welcomestring="夜里好";
	document.write(welcomestring);
}

function CheckFormLogin() 
{
	if (document.frmLogin.iptUserName.value == "" )
		{ 
		 alertCUI(':-)  对不起!请您填入用户名。'); 
		 document.frmLogin.iptUserName.focus()
		 return false;
		}
	if (document.frmLogin.iptPassword.value == "" )
		{ 
		 alertCUI(':-)  对不起!请您填入用户密码。'); 
		 document.frmLogin.iptPassword.focus()
		 return false;
		}
	if (GetStrLength(document.frmLogin.iptPassword.value) < 5 )
		{ 
		 alertCUI(':-)  对不起!，您输的密码小于6位。密码应为6-20位'); 
		 document.frmLogin.iptPassword.focus()
		 return false;
		}
	return true;
}


// 自适应显示图片
function DrawImage(ImgD,intLargeImgWidth,intLargeImgHeight,intAltFlag)
{
	var image = new Image();
	image.src = ImgD.src;

	if (image.width > 0 && image.height > 0)
	{
		flag = true;
		if (image.width/image.height >= intLargeImgWidth/intLargeImgHeight)
		{
			if (image.width > intLargeImgWidth)
			{  
				ImgD.width = intLargeImgWidth;
				ImgD.height = (image.height * intLargeImgWidth)/image.width;
			} 
			else
			{
				ImgD.width = image.width;  
				ImgD.height = image.height;
			}

			if (intAlfFlag = 0 )
			{
				ImgD.alt = "实际大小：" + image.width + "×" + image.height + ",点击查看原始图";
			}
		}
		else
		{
			if (image.height > intLargeImgHeight)
			{  
				ImgD.height = intLargeImgHeight;
				ImgD.width = (image.width * intLargeImgHeight)/image.height;     
			}
			else
			{
				ImgD.width = image.width;  
				ImgD.height = image.height;
			}
			
			if (intAltFlag = 0 )
			{
				ImgD.alt = "实际大小：" + image.width + "×" + image.height+ ",点击查看原始图";
			}
		}
	}
   /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
} 

// 自适应显示图片
function DrawImage2(ImgD,intLargeImgWidth)
{
	var image = new Image();
	image.src = ImgD.src;

	if (image.width > intLargeImgWidth)
	{  
			ImgD.width = intLargeImgWidth;
	}

	ImgD.alt = "实际大小：" + image.width + "×" + image.height + ",点击查看原始图";

}


function CheckFormLogin() 
{
	if (GetStrLength(document.frmLogin.iptUserName.value) < 2 || GetStrLength(document.frmLogin.iptUserName.value) > 10 )
	{ 
		 alertCUI(':-)  对不起!请您填入用户名(2-10字)'); 
		 document.frmLogin.iptUserName.focus();	 
		 return false;
	}

	if (GetStrLength(document.frmLogin.iptPassword.value) < 6 || GetStrLength(document.frmLogin.iptPassword.value) > 20 )
	{ 
		 alertCUI(':-)  对不起!请您填入用户密码(6-20字)'); 
		 document.frmLogin.iptPassword.focus();	 
		 return false;
	}
	return true;
}

function CheckGoForm()
{
	if (!IsNumeric(document.frmGo.intPageNow.value))
	{
		 alertCUI(':-)  对不起!请您填入正确的页码'); 
		 document.frmGo.intPageNow.focus();	 
		 return false;
	}

	return true;
}
function IsNumeric(p) 
{ 
	if (p == "") 
		return false;
	
	var l = p.length; 
	var count = 0; 
	for (var i = 0; i < l; i++) 
	{ 
		var digit = p.charAt(i); 
		if (digit == "." ) 
		{ 
			++count; 
			if (count > 1) return false; 
		} 
		else if (digit < "0" || digit > "9") 
		return false; 
	}
	
	return true;
	
} 

// 表单提交后submit按钮变为不可用
function submitonce(theform)
{
	if (document.all||document.getElementById)
	{
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
		}
	}
}

// 改变背景颜色
function BgChange(field,strClassName)
{
	field.className = strClassName;
}

// 回复背景颜色
function BgReset(field,strClassName)
{
	field.className = strClassName;
}

function CheckFormAddTopics(strFormName) 
{
	if (GetStrLength(strFormName.iptTitle.value) < 1 || GetStrLength(strFormName.iptTitle.value) > 100 )
	{ 
		 alertCUI(':-)  对不起!请您填入帖子主题(1-20字)'); 
		 strFormName.iptTitle.focus();	 
		 return false;
	}

	/*if (GetStrLength(strFormName.txtContent.value) < 5 || GetStrLength(strFormName.txtContent.value) > 10000 )
	{ 
		 alertCUI(':-)  对不起!请您填入帖子内容(5－30000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}*/

	//submitonce(strFormName);

	return true;
}

function CheckFormAddReply(strFormName)
{
	if (GetStrLength(strFormName.iptReTitle.value) < 1 || GetStrLength(strFormName.iptReTitle.value) > 100 )
	{ 
		 alertCUI(':-)  对不起!请您填入回复主题(1-20字)'); 
		 strFormName.iptReTitle.focus();	 
		 return false;
	}

	/*if (GetStrLength(strFormName.txtContent.value) < 5 || GetStrLength(strFormName.txtContent.value) > 10000 )
	{ 
		 alertCUI(':-)  对不起!请您填入回复内容(5－10000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}*/
	//submitonce(strFormName);
	return true;
}