

var iedom = document.all || document.getElementById;
var spacePos = 200;

function Inicialize()
{
	if (iedom){
		
		// Texto completo
		var lblTheCity = getObject('lblTheCity');
		var lblHistory = getObject('lblHistory');
		var lblGeneralInfo = getObject('lblGeneralInfo');
		var lblHowToGetThere = getObject('lblHowToGetThere');
		var lblRestaurants = getObject('lblRestaurants');
		var lblNightLife = getObject('lblNightLife');

		// Texto introdutório
		var boxTheCity = getObject('boxTheCity');
		var boxHistory = getObject('boxHistory');
		var boxGeneralInfo = getObject('boxGeneralInfo');
		var boxHowToGetThere = getObject('boxHowToGetThere');
		var boxRestaurants = getObject('boxRestaurants');
		var boxNightLife = getObject('boxNightLife');
		
		// Pega as primeiras linhas;
		boxTheCity.innerHTML = TruncateWithEllipsis(lblTheCity.innerHTML , spacePos);
		boxHistory.innerHTML = TruncateWithEllipsis(lblHistory.innerHTML , spacePos);
		boxGeneralInfo.innerHTML = TruncateWithEllipsis(lblGeneralInfo.innerHTML , spacePos);
		boxHowToGetThere.innerHTML = TruncateWithEllipsis(lblHowToGetThere.innerHTML , spacePos);
		boxRestaurants.innerHTML = TruncateWithEllipsis(lblRestaurants.innerHTML , spacePos);
		boxNightLife.innerHTML = TruncateWithEllipsis(lblNightLife.innerHTML , spacePos);
		
		
	}
}

window.onload = Inicialize;

function TruncateWithEllipsis(text, length) 
{
	if (text.length > length)
	{
		var spacePos = text.indexOf(" ",length, (text.Length - length));
		
		if(spacePos > 0)
			text = text.substring(0,spacePos) + "...";
	}
	return text;
}

function TrucanteInnerText(panelObj){
	var panelObj2 = getObject(panelObj);
	panelObj2.innerHTML = TruncateWithEllipsis(panelObj2.innerHTML, 400);
}

function PanelBehavor(panelObj, sender){
	
	var introText = getObject('box' + panelObj);
	var fullText = getObject('lbl' + panelObj);
		
	if(introText.innerHTML.length > 0){
		introText.innerHTML = '';
		introText.style.display = 'none';
		fullText.style.display = 'block';
		sender.src = 'images/bt_less.gif'
	}
	else{
		introText.innerHTML = TruncateWithEllipsis(fullText.innerHTML, spacePos);
		introText.style.display = 'block';
		fullText.style.display = 'none';
		sender.src = 'images/bt_more.gif'
	}
}

function getObject(id){
	return document.getElementById ? document.getElementById(id) : eval('document.all.' + id);
}

//function ietruebody(){
//	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
//}
