
//
function keyword_bold()
{
	try{
		$$(".description").each(function(e){
			var text = e.innerHTML
			re = new RegExp("()","ig");//i 执小写
			var retext = "<b>$1</b>";
			e.innerHTML = text.replace(re,retext);
		});
	}
	catch(e){}
}
// 图片
function pimage_resize()
{
	var d_h = 80;
	var d_w = 80;
	$$('img[ptype=photo]').each(function(e){
		var o_h = e.height;
		var o_w = e.width;
		if (o_h > d_h || o_w > d_w )
		{
			var percent = get_percent(o_h,o_w,d_h,d_w);
			e.height = o_h * percent;
			e.width = o_w * percent;
		}
	});
}
// 图片
function get_percent(o_h,o_w,d_h,d_w)
{
	var percent = 1;
	if (o_h / o_w >= d_h / d_w)
	{
		percent = d_h / o_h;
	}
	else
	{
		percent = d_w / o_w;
	}
	return percent;
}
// suggestion
function update(object, value)
{
	var index1 = value.indexOf('@');
	if ( index1 == -1 )
	{
		object.text.value = value;
		$('code').value="";
	}
	else
	{
		var v = value.substring(index1+1) ;
		var var_arr=v.split('@');
		$('code').value = var_arr[0] ;
		object.text.value =value.substring(0,index1);
	}
	var index = value.toLowerCase().indexOf(object.value.toLowerCase());
	if (index > -1) {
		setSelectionRange(object.text, index + object.value.length, value.length);
	}

}

function setImgSize(theURL,sImage,stand,ctand)
{
	var imgObj;
	var sizeStand=stand;
	var CStand=ctand;
	if(arguments.length>=3)
	{
		sizeStand=arguments[2];
	}
	imgObj=new Image();
	imgObj.src=theURL;
	if(ctand==0)
	{
		if((imgObj.width!=0)&&(imgObj.height!=0))
		{
			if(imgObj.width>sizeStand||imgObj.height>sizeStand)
			{
				if(imgObj.width>imgObj.height)
				{
					var iHeight=imgObj.height*sizeStand/imgObj.width;
					sImage.height=iHeight;sImage.width=sizeStand;
				}
				else
				{
					var iWidth=imgObj.width*sizeStand/imgObj.height;sImage.width=iWidth;sImage.height=sizeStand;
				}
			}
			else
			{
				sImage.width=imgObj.width;sImage.height=imgObj.height;
			}
		}
		else
		{
			sImage.width=sizeStand;sImage.height=sizeStand;
		}
	}
	else
	{
		if((imgObj.width!=0)&&(imgObj.height!=0))
		{
			if(imgObj.width>sizeStand||imgObj.height>CStand)
			{
				var wi=imgObj.width/sizeStand;
				var hi=imgObj.height/CStand;
				if(wi>hi)
				{
					var iHeight=imgObj.height*sizeStand/imgObj.width;
					sImage.height=iHeight;sImage.width=sizeStand;
				}
				else
				{
					var iWidth=imgObj.width*CStand/imgObj.height;
					sImage.width=iWidth;sImage.height=CStand;
				}

			}
			else
			{
				sImage.width=imgObj.width;sImage.height=imgObj.height;
			}
		}
		else
		{
			sImage.width=sizeStand;sImage.height=CStand;
		}
	}
}
function show_reply(myitem)
{
  document.getElementById(myitem).style.display="block";
}
function hidden_reply(myitem)
{
  document.getElementById(myitem).style.display="none";
}