/*
2 por linha com tempo, texto e imagem
*/

function makeNews(jsonTree)
{
	var newP = document.createElement('div');
		
	newP.setAttribute('id', jsonTree["data"]);				
	newP.setAttribute('class', "Objects News links");
	newP.setAttribute('onMouseOver', 'objBgOver(this)');
	newP.setAttribute('onMouseOut', 'objBgOut(this)');
	newP.setAttribute('onClick', 'article('+jsonTree["data"]+')');

	var bgNews = document.createElement('div');
	bgNews.setAttribute('class', "objBg");
	newP.appendChild(bgNews);

	if(jsonTree["img"]!= "" )
	{
		contImgP = document.createElement('div');
		contImgP.setAttribute('class', "StructL");
		
		imgP = document.createElement('img');
		imgP.setAttribute('src', jsonTree["img"]);
		imgP.setAttribute('class', "imgObj");
		imgP.setAttribute('alt', "logotipo - "+jsonTree["data"]);

		contImgP.appendChild(imgP);
		newP.appendChild(contImgP);
	}

	var headP = document.createElement('header');
	
	var titP = document.createElement('h2');
	titP.setAttribute('class', "subTit");

	contP = document.createElement('div');
	contP.setAttribute('class', "StructR");
	
	headP.appendChild(titP);
	contP.appendChild(headP);

	txtP = document.createElement('p');
	txtP.setAttribute('class', "textos resumo");


	switchNTxt(jsonTree, titP, txtP)
	
	
	contP.appendChild(txtP);
	newP.appendChild(contP);
	
	if(jsonTree["img"]!= "" )
	{
		imgP.setAttribute('alt', "logotipo - "+titP.innerHTML);
	}

	if(jsonTree["tempo"]!=null)
	{
		var temP = document.createElement('p');
		temP.setAttribute('class', "textos infDir");
	
		temP.innerHTML=jsonTree["tempo"];
		
		contP.appendChild(temP);
	}
	return newP;
}

function checkLangN(pathUrl, jsonTree)
{
	switch(lang)
	{
		case "pt":
			if(jsonTree["tituloPt"]==undefined)
			{
				jsonData.tituloPt="1";
				jsonData.excertoPt="1";
				getJson(pathUrl, jsonData);
				return false;
			}
		break;
		case "en":
			if(jsonTree["tituloEn"]==undefined)
			{
				jsonData.tituloEn="1";
				jsonData.excertoEn="1";
				getJson(pathUrl, jsonData);
				return false;
			}
		break;
		case "sp":
			if(jsonTree["tituloSp"]==undefined)
			{
				jsonData.tituloSp="1";
				jsonData.excertoSp="1";
				getJson(pathUrl, jsonData);
				return false;
			}
		break;
	}
	return true;
}

function switchNLang(jsonTree)
{
	for(i=0;i<jsonTree.length;i++)
	{
		switchNTxt(jsonTree[i], $("#"+jsonTree[i]["data"]+" .subTit"), $("#"+jsonTree[i]["data"]+" .resumo"));
	}
}

function switchNTxt(jsonTree, eleTit, eleTxt)
{

	switch(lang)
	{
		case "pt":
			$(eleTit).html(jsonTree["tituloPt"]);
			$(eleTxt).html(checkTxtL(jsonTree["excertoPt"], 250));

		break;
		case "sp":
			$(eleTit).html(jsonTree["tituloSp"]);
			$(eleTxt).html(checkTxtL(jsonTree["excertoSp"], 250));
		break;
		case "en":
			$(eleTit).html(jsonTree["tituloEn"]);
			$(eleTxt).html(checkTxtL(jsonTree["excertoEn"], 250));

		break;
	}
}
