// 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 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 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 (strFormName.iptTitle.value.length < 1 || strFormName.iptTitle.value.length > 100 )
	{ 
		 alertCUI(':-)  对不起!请您填入帖子主题(1-20字)'); 
		 strFormName.iptTitle.focus();	 
		 return false;
	}

	/*if (strFormName.txtContent.value.length < 5 || strFormName.txtContent.value.length > 10000 )
	{ 
		 alertCUI(':-)  对不起!请您填入帖子内容(5－30000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}*/

	//submitonce(strFormName);

	return true;
}

function CheckFormAddReply(strFormName)
{
	if (strFormName.iptReTitle.value.length < 1 || strFormName.iptReTitle.value.length > 100 )
	{ 
		 alertCUI(':-)  对不起!请您填入回复主题(1-20字)'); 
		 strFormName.iptReTitle.focus();	 
		 return false;
	}

	/*if (strFormName.txtContent.value.length < 5 || strFormName.txtContent.value.length > 10000 )
	{ 
		 alertCUI(':-)  对不起!请您填入回复内容(5－10000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}*/
	//submitonce(strFormName);
	return true;
}

