$(function()
{
	$('input[@id=attachFile]').click(function(e)
	{
		
		var title = $(this).attr('title');
		ajaxDialog(lang.title.attachFile,
		{success:function(json,boxy)
		{
			
			var nofile = parseInt(json.length) > 0 ? undefined:true;
			var vars =
			{
				title:title,
				files:json,
				nofile:nofile
			}
			
			var result = $('#attachFileTpl').royTemplate(vars);
			var div  = $('<div></div>');
			div.append(result);
			
			boxy.setContent(div);
			
			pos = boxy.getCenter();
			boxy.moveTo(pos.x,pos.y);
		}},
		{url:sysurl('news','news.list_attach.ajax','id='+$(this).attr('rel'))});
	});
	
	if(window['KEY'] != '')
	{
		var keyword= window['KEY'];
		
		keyword = keyword.toUpperCase();//高亮關鍵字必須為大寫
		var hlObjs =$('.newsTable');
		
		for(i=0;i<hlObjs.length;i++)
		{
			$(hlObjs[i]).find('tr td').each(function()
			{
				
				$(this).removeHighlight();//移除前次高亮結果
				$.highlight(this, keyword);//高亮關鍵字
				
			});
		}
	}
});
