window.onload = initImageResizer;
function initImageResizer(){
	var cons	= getElementsByClassName("PostContentInner");
	if(!cons) return;
	var img,imgs;
	for(var i=0;i<cons.length;i++){
		imgs	= cons[i].getElementsByTagName('img');
		if(!imgs) continue;
		for (var j=0;j<imgs.length;j++){		
			img	= imgs[j];
			if(img.width>screen.width-330){
				img.width = screen.width-400;
			}
		}
		
		as	= cons[i].getElementsByTagName('a');
		if(!as) continue;
		for (var j=0;j<as.length;j++){	
			if (as[j].href.indexOf("hmlan.com")==-1){
				as[j].href='#';
				as[j].target='';
			}
			
		}

		
	}
}
function getElementsByClassName(class_name){
	var all_obj,ret_obj=new Array(),j=0,teststr;
	
	if(document.all){
		all_obj=document.all;
	}else if(document.getElementsByTagName && !document.all){
		all_obj=document.getElementsByTagName("*");
	}
	
	for(i=0;i<all_obj.length;i++){
		if(all_obj[i].className.indexOf(class_name)!=-1){
			teststr=","+all_obj[i].className.split(" ").join(",")+",";
			if(teststr.indexOf(","+class_name+",")!=-1)	{
				ret_obj[j]=all_obj[i];
				j++;
			}
		}
	}
	return ret_obj;
}

function countDownRedirector(){
	var x	= document.getElementById("TimeCountNum");
	if(!x) return;
	var t	= x.innerHTML;
	if(t > 0 ){
		t--;
		x.innerHTML = t;
		window.setTimeout("countDownRedirector()",1000);
	}else{
		window.location	= x.title;
	}
}

function StrLenthByByte(str) 
{ 
	var len; 
	var i; 
	len = 0; 
	for (i=0;i<str.length;i++) 
	{ 
		if (str.charCodeAt(i)>255) len+=2; else len++; 
	} 
	return len; 
} 

function forum_onsubmit() 
{
	ContentLength=WBTB_Composition.document.body.innerHTML.length;
	if  (document.hmlanbbsform.BoaId.value=="")
		{
            alert("栏目不能为空");
            return false ;
        }
	else if  (document.hmlanbbsform.topic.value=="")
		{
            alert("标题不能为空");
            document.hmlanbbsform.topic.focus();
            return false ;
        }
		
	else if(StrLenthByByte(document.hmlanbbsform.topic.value)>50)
		{
            alert("标题不能多于50个字符!\n1个汉字等于2个字符");
            document.hmlanbbsform.topic.focus();
            return false ;
        }
		
	else if(ContentLength=="")
		{
			alert("内容不能为空！");
			return false;
		}
	else if(StrLenthByByte(WBTB_Composition.document.body.innerHTML)<4)
		{
			alert("为防止灌水，内容必须大于4个字符！\n1个汉字等于2个字符");
			return false;
		}
	
	else if(StrLenthByByte(WBTB_Composition.document.body.innerHTML)>80000000)
		{
			alert("内容不能超过80000000个字符！\n1个汉字等于2个字符");
			return false;
		}
	//document.hmlanbbsform.Reset.disabled = true;		
	document.hmlanbbsform.Submit.disabled = true;
	document.forms['hmlanbbsform'].elements['Submit'].value="正在提交数据，请稍候……";
	return true;
}

function forum_KeyDown()
{
	if(event.ctrlKey && window.event.keyCode == 13 && document.hmlanbbsform.Submit.disabled == false)
	{
		ContentLength=WBTB_Composition.document.body.innerHTML.length;
		if  (document.hmlanbbsform.BoaId.value=="")
		{
            alert("栏目不能为空");
            return false ;
        }
		else if  (document.hmlanbbsform.topic.value=="")
			{
            	alert("标题不能为空");
            	document.hmlanbbsform.topic.focus();
            	return false ;
        	}
		
		else if(StrLenthByByte(document.hmlanbbsform.topic.value)>50)
			{
            	alert("标题不能多于50个字符!\n1个汉字等于2个字符");
            	document.hmlanbbsform.topic.focus();
            	return false ;
       		 }
		
		else if(ContentLength=="")
			{
				alert("内容不能为空！");
				return false;
			}
		else if(StrLenthByByte(ContentLength)<4)
			{
				alert("为防止灌水，内容必须大于4个字符！\n1个汉字等于2个字符");
				return false;
			}
	
	
		else if(StrLenthByByte(ContentLength)>80000000)
			{
				alert("内容不能超过80000000个字符！\n1个汉字等于2个字符");
				return false;
			}
		document.hmlanbbsform.submit();
		//document.hmlanbbsform.Reset.disabled = true;
		document.hmlanbbsform.Submit.disabled = true;
		document.forms['hmlanbbsform'].elements['Submit'].value="正在提交数据，请稍候……";
		return true;
	}
}

//快速回复
function forum_quickonsubmit() 
{	
	if(document.hmlanbbsform.body.value=="")
		{
			alert("内容不能为空！");
			return false;
		}
	else if(StrLenthByByte(document.hmlanbbsform.body.value)<4)
		{
			alert("为防止灌水，内容必须大于4个字符！\n1个汉字等于2个字符");
			return false;
		}
	
	else if(StrLenthByByte(document.hmlanbbsform.body.value)>80000000)
		{
			alert("内容不能超过80000000个字符！\n1个汉字等于2个字符");
			return false;
		}
	//document.hmlanbbsform.Reset.disabled = true;		
	document.hmlanbbsform.Submit.disabled = true;
	document.forms['hmlanbbsform'].elements['Submit'].value="正在提交数据，请稍候……";
	return true;
}
function forum_quickKeyDown()
{
	if(event.ctrlKey && window.event.keyCode == 13 && document.hmlanbbsform.Submit.disabled == false)
	{
		if(document.hmlanbbsform.body.value=="")
			{
				alert("内容不能为空！");
				return false;
			}
		else if(StrLenthByByte(document.hmlanbbsform.body.value)<4)
			{
				alert("为防止灌水，内容必须大于4个字符！\n1个汉字等于2个字符");
				return false;
			}
	
		else if(StrLenthByByte(document.hmlanbbsform.body.value)>80000000)
			{
				alert("内容不能超过80000000个字符！\n1个汉字等于2个字符");
				return false;
			}
			document.hmlanbbsform.submit();
			//document.hmlanbbsform.Reset.disabled = true;
			document.hmlanbbsform.Submit.disabled = true;
			document.forms['hmlanbbsform'].elements['Submit'].value="正在提交数据，请稍候……";
			return true;
	}
}
function switchTopicOpenMode(box)
{
	var isPopNew   = box.checked;
	var anchorTags = document.getElementsByTagName('a');
	for (var i=0; i<anchorTags.length; i++)
	{
		if (anchorTags[i].getAttribute('name') != 'topiclink') continue;
		anchorTags[i].target = isPopNew ? '_blank' : '_self';
	}
}




function noimg(img)
{		//如果图片不存在，调用上级目录的xlogo.gif图片
    img.src ="/images/face/0.gif";
}
