//限制文本框输入字数
function OnFeedbackChange(field, maxLength, counter)
{ 
	try
	{
		var counterSpan = document.getElementById(counter);
		var textBox = document.getElementById(field);
		var length;

		if(typeof(textBox) != "undefined") length = textBox.value.length;

		if(typeof(length) != "undefined")
		{
			var charsRemaining = maxLength - length;
			var scrolltop = textBox.scrollTop;
			var scrollleft = textBox.scrollLeft;
			if(charsRemaining < 0) 
			{ 
				textBox.value = textBox.value.substring(0, maxLength);
				charsRemaining = 0 
				textBox.scrollTop = scrolltop;
				textBox.scrollLeft = scrollleft;
			}
			counterSpan.innerHTML = charsRemaining;
		}
	}
	catch(e){}
}

//图片按比例缩放
function DrawImage(obj,maxwidth,maxheight){
	var objimg = new Image(); 
	objimg.src = obj.src;
	
	var owidth = objimg.width;
	var oheight = objimg.height;
	
	var dblWidthMultiple = owidth / maxwidth;
	var dblHeighMultiple= oheight / maxheight;
	
	if((owidth > maxwidth) || (oheight > maxheight))
	{
		if(dblWidthMultiple >= dblHeighMultiple)
		{
			w = maxwidth;
			h = parseInt(oheight / dblWidthMultiple);
		}
		else
		{
			w = parseInt(owidth / dblHeighMultiple);
			h = maxheight;
		}
	}
	else
	{
		w = owidth;
		h = oheight;
	}

	obj.width = w;
	obj.height = h;
}

//按回车提交表单
function FormSubmit(objButton){
	if(event.keyCode==13){
		event.keyCode=9;
		event.returnValue = false;
		document.getElementById(objButton).click(); 
	}
}

//用户信息打开新窗口
function openwindow(owin,url,winname,winWidth,winHeight)
{
	var winLeft = screen.availWidth-winWidth-10;

	owin = window.open(url,winname,'left='+winLeft+',top=0,height='+winHeight+',width='+winWidth+',menubar=no,status=yes,toolbar=no,location=no,resizable=no,scrollbars=no');
	owin.focus();
}

function openwindow1(owin,url,winname)
{
	var winHeight = 517;
	var winWidth = 400;

	var winLeft = screen.availWidth-winWidth-10;

	owin = window.open(url,winname,'left='+winLeft+',top=0,height='+winHeight+',width='+winWidth+',menubar=no,status=yes,toolbar=no,location=no,resizable=no,scrollbars=no');
	owin.focus();
}

function iframeResize(FrameName,target){
	var dyniframe   = null;
	var indexwin    = null;

	if(document.getElementById){
		dyniframe = eval(target).document.getElementById(FrameName);
		indexwin  = window;
		parentwin = parent;

		if(dyniframe){
			if (dyniframe.contentDocument){
				dyniframe.height = dyniframe.contentDocument.body.scrollHeight + 10;
			}
			else if(dyniframe.document && dyniframe.document.body.scrollHeight){
				dyniframe.height=0;
				iframeheight = dyniframe.document.body.scrollHeight-84;
				windowheight = indexwin.document.body.scrollHeight;
				parentheight = parentwin.document.body.scrollHeight;
				dyniframe.height = (iframeheight < parentheight) ? windowheight : iframeheight;
			}
		}
	}
}

function insert_face(facecode){
	document.getElementById("comment").value += "[:s" + facecode + "]";
}