var news = null;

function News(){
}
	
	News.prototype = {
	view : function()
	{
		$("#title").html(newsTitle);
		$("#publisher").html(publisher);
		if(window.opener.document.getElementById("content")!=null)
		$("#content").html(window.opener.document.getElementById("content").value);
		var tmp_date = new Date();
		var arr_str = tmp_date.getFullYear()+"-"+(Number(tmp_date.getMonth())+1)+"-"+tmp_date.getDate()+ " "+tmp_date.getHours()+":"+tmp_date.getMinutes();
		$("#createDate").html(arr_str);
	},
	initData : function(){
		if(view=="view")
		{
			window.onbeforeunload = function()
			{
				
				$.post($.getUrl("bs_newsAct/deleteById.jsonp?p0="+nid));
			}
			
		}
		var json = $.getJSON($.getUrl("bs_newsAct/findById.jsonp?p0=")+nid,callBack);
	
	function callBack(data)
	{
	
		
		if(data.content.substring(0,5)=="<p><a"&&data.content.substring(data.content.length-8,data.content.length)=="</a></p>")
		{
			var temp =data.content.split("href");
			var temp2 =temp[1].split("\"");
			window.location=temp2[1];
		}
		var tmp_date = new Date(data.createDate);
		var arr_str = tmp_date.getFullYear()+"-"+(Number(tmp_date.getMonth())+1)+"-"+tmp_date.getDate()+ " "+tmp_date.getHours()+":"+tmp_date.getMinutes();
		$("#title").html(data.title);
		$("#createDate").html(arr_str);
		$("#publisher").html(data.publisher);
		$("#clickCount").html(data.clickCount);
		$("#content").html(data.content);
		
	}
}
};


$(document).ready(function (){
	
	news = new News();
	if(nid!=0)
	{
		news.initData();
	}
	else
	{
		news.view();
		
	}
});