var $LMARQUEE,$HTMLMARQUEE="";
NEWSHOME = function(){}
NEWSHOME.prototype.getNews=function(type){
	var fncSuc = XHR.Delegate(this,this.listSuc);
	var param = {act:"listNewsType",page:1,n:5,type:type};
	new XHR("post",fncSuc).send($PN+"/Proc",param);
	this.type = type;
}
NEWSHOME.prototype.listSuc=function(r){
	if(this.type==0){
		this.listNewsSuc(r);
	}else{
		this.listEventSuc(r);
	}
}
NEWSHOME.prototype.listNewsSuc=function(r){
	var xml = new XML(r);
	var id = "";
	if(xml.value){
		var news = xml.get("news");
		var htmlbig="",htmlsmall="";
		for(var i=0; i < news.length; i++){
			id = news[i].getAttribute("id");
			if(i==0){
				var file = (news[i].getAttribute("filepic")=="") ? "../../images/noimg.gif" : $LIB_PATH+getThumbPath(news[i].getAttribute("filepic"));
				var pic = 	"<a  href=\"?act=newsdetail&id="+id+"&lang="+$LANG+"\"><img align=\"left\" style=\"margin-right:8px\" class=\"commonborder\" src=\""+file+"\" width=\"100px\"/></a>";
				htmlbig = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" style=\"margin-bottom:5px\">"+
				             "<tr>"+
				                "<td width=\"100%\" valign=\"top\">"+pic+
				                "<a style=\"text-decoration:none\" class=\"t_newshome\" href=\"?act=newsdetail&id="+id+"&lang="+$LANG+"\">"+news[i].getAttribute("title")+"</a></div>"+
				                "<div class=\"d_newshome\">"+procTime(news[i].getAttribute("date"))+
				                "</td>"+
				              "</tr>"+
				           "</table>";
			}else{
				htmlsmall +="<li style=\"margin-left:10px\"><a class=\"newshome_list\" href=\"?act=newsdetail&id="+id+"&lang="+$LANG+"\">"+news[i].getAttribute("title")+"</a></li>";
			}
		}
		if((htmlbig+htmlsmall)!=""){
			htmlsmall = "<ul style=\"padding:10px;margin:0px\">"+htmlsmall+"</ul>";
			var text = "Xem thêm &raquo;";
			if($LANG!=undefined && $LANG=="en"){
				text = "View more &raquo;";
			}
			htmlsmall += "<div align=\"right\" style=\"margin-top:10px;font-size:11px\"><a class=\"viewmore_news\" href=\"?act=newslist&page=1&n=10&lang="+$LANG+"&id=-1\">"+text+"</a></div>";
			$("newslisthome").innerHTML = htmlbig+htmlsmall;
			$("newslisthomediv").style.display="block";
		}
		
	}
}
NEWSHOME.prototype.listEventSuc=function(r){
	var xml = new XML(r);
	var id = "";
	if(xml.value){
		if($HTMLMARQUEE!="") return;
		var news = xml.get("news");
		var html="";
		var lengthspace=0;
		var title = "";
		for(var i=0; i < news.length; i++){
			id = news[i].getAttribute("id");
			title +=news[i].getAttribute("title");
			html += "<a class=\"marqueediv\" href=\"#\" style=\"margin-right:30px;text-decoration:none\" onClick=\"showEvent('"+id+"')\">"+
					"<img border=\"0\" src=\"../../images/dotwhite.gif\"/> "+	
					news[i].getAttribute("title")+"</a>";
			lengthspace=lengthspace+30*(i+1);
		}
		if(html!=""){
			var l = title.length*7+lengthspace;
			$LMARQUEE = l;
			$HTMLMARQUEE= html;
			showMarquee();
		}else{
			$("eventdiv").style.display="none";
		}
	}
}
function showMarquee(){
	$("marquee").innerHTML = '<marquee direction="left" onmouseover="this.stop();" onmouseout="this.start();" id="eventMarquee" scrollamount="2" scrolldelay="4" class="marqueewidth">'+
			  					'<div id="event2" style="white-space:nowrap;width:'+$LMARQUEE+'px">' +
			  					$HTMLMARQUEE+
			  					'</div>'+
			  				 '</marquee>';
	$("eventdiv").style.visibility="visible";
	$("eventMarquee").start();
}

