/***************************************************************************
*                  Project : BaoMienphi  |  Powered by VSSC.VN
*                            -------------------
*   Cap nhat           	: 	10/02/2007
*   Nguoi tao 		   	: 	TuanNA
*   Nguoi sua cuoi     	: 	TuanNA
*   Email              	: 	tuan@vssc.vn
*   File 				: 	loadhome.js
*	Chuc nang			:	Load du lieu Trang chu tin tuc
****************************************************************************/// JavaScript Document
function get_data_new(data){
	return data["Homeitems"]["Homeitem"];
}

function output_new(){
	var i;
	var xmlfile = 'data/xml/news/home.xml?'+Math.random()*1000;
	var datanews = get_dataXML(xmlfile);
		
	blockhot = get_block("hotnew");	
	blockhot = set_var('hot.title',datanews.Homeitems.hotnews.title,blockhot);		
	blockhot = set_var('hot.img',datanews.Homeitems.hotnews.image,blockhot);		
	blockhot = set_var('hot.url',datanews.Homeitems.hotnews.url,blockhot);		
	blockhot = set_var('hot.url2',datanews.Homeitems.hotnews.url,blockhot);		
	blockhot = set_var('hot.brief',datanews.Homeitems.hotnews.brief,blockhot);		
	set_block('hotnew',blockhot);			
	
	var n = datanews.Homeitems.Homeitem.length;
	datacat = '';
	for(i=0;i<n;i++){
		itemdata = get_data_new(datanews);
		blockcat = get_block("block_category");	
		blockcat = set_var('category_name',itemdata[i]["category"]["title"],blockcat);		
		blockcat = set_var('browse_category_link',itemdata[i]["category"]["url"],blockcat);		
		blockcat = set_var('news_image',itemdata[i]["category"]["newimage"],blockcat);		
		blockcat = set_var('news_style',itemdata[i]["category"]["newstyle"],blockcat);		
		blockcat = set_var('news_link',itemdata[i]["category"]["newlink"],blockcat);		
		blockcat = set_var('news_link2',itemdata[i]["category"]["newlink"],blockcat);
		blockcat = set_var('news_title',itemdata[i]["category"]["newtitle"],blockcat);		
		blockcat = set_var('news_brief',itemdata[i]["category"]["newbrief"],blockcat);						
		blockothers = '';
		if(	itemdata[i]["category"]["items"]){	
			var k =itemdata[i]["category"]["items"]["item"].length;
			
			
			if(k>1){
			for(j=0;j<k;j++){
				blockother = get_block("block_other_news");	
				blockother = set_var('other_news_title',itemdata[i]["category"]["items"]["item"][j]["title"],blockother);		
				blockother = set_var('other_news_link',itemdata[i]["category"]["items"]["item"][j]["link"],blockother);	
				blockothers = blockothers + blockother;
				
				}
			}
			else{
				blockother = get_block("block_other_news");	
				blockother = set_var('other_news_title',itemdata[i]["category"]["items"]["item"]["title"],blockother);		
				blockother = set_var('other_news_link',itemdata[i]["category"]["items"]["item"]["link"],blockother);	
				blockothers = blockothers + blockother;
				
			}
			
			}
		blockcat = set_var('other_news',blockothers,blockcat);

		if(itemdata[i]["category"]["newtitle"])	{
			datacat = datacat + blockcat;
			}
	}

	set_block('block_other_news','');
	set_block('block_category',datacat);
	
	body = get_block("block_home");	

set_block('home',body);

}

