/* --------------- "baloons" -----------------  */

var people = new Array();

people[0] = new Object();

people[0].nm = 'Sandis Sauka';

people[0].msg = new Array();	
people[0].msg[0] = 'I\'m very satisfied with work of the team :)';

people[0].baloonOffsetX = 5;
people[0].baloonOffsetY = 45;
people[0].baloonArr = 0;   // 1 = left, 0 = right

people[1] = new Object();
people[1].nm = 'Sergey Lensky';

people[1].msg = new Array();
people[1].msg[0] = 'New project - new technologies!';
people[1].msg[1] = 'Case study rocks!';
people[1].msg[2] = 'Just like my job.';

people[1].baloonOffsetX = -50;
people[1].baloonOffsetY = 25;
people[1].baloonArr = 0;   // 1 = left, 0 = right


people[2] = new Object();

people[2].nm = 'Andrey Bogutsky';

people[2].msg = new Array();
people[2].msg[0] = 'Complicated from inside, simple and elegant from outside.';
people[2].msg[1] = 'A Sampo Bank client will be surprised how simple and functional the website is. Isn\'t it the most important?';
people[2].msg[2] = 'A great communications and understanding the customer\'s requirements allowed us to create simple and unique design.';

people[2].baloonOffsetX = 15;
people[2].baloonOffsetY = 25;
people[2].baloonArr = 1;   // 1 = left, 0 = right


var fromBaloon = 0;

var baloon = document.createElement('div');
document.body.appendChild(baloon);
baloon.className = 'Baloon';

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var t = obj;
	if (t.offsetParent)
	{
		while (t.offsetParent)
		{
			curtop += t.offsetTop;
			t = t.offsetParent;
		}
	}
	else if (t.y)
		curtop += t.y;
	return curtop;
}

function showBaloon(n)
{	
	
	var manPosX = findPosX(document.getElementById('m' + n));
	var manPosY = findPosY(document.getElementById('m' + n));
	
	var arrClass = (people[n].baloonArr ? "ArrowImageL" : "ArrowImageR");
	
	baloon.style.left = manPosX + people[n].baloonOffsetX + 'px';
	baloon.style.top  = manPosY + people[n].baloonOffsetY + 'px';
	baloon.style.visibility = 'visible';		
	
	if (!fromBaloon)
	{
		fromBaloon = 0;
		baloon.innerHTML = '<table class="BaloonTable" onmouseover="fromBaloon = 1"><tr><td colspan="3" class="Arrow"><center><div class="' + arrClass + '">.</div></center></td></tr><tr><td class="UL"></td><td></td><td class="UR"></td></tr><tr><td></td><td class="Msg"><b style="padding-bottom: 2px; display: block;">' + people[n].nm + '</b>' + people[n].msg[Math.round(Math.random() * (people[n].msg.length - 1))] + '</td><td></td></tr><tr><td class="BL"></td><td></td><td class="BR"></td></tr></table>';
	}
}

function hideBaloon()
{
	baloon.style.visibility = 'hidden';		
	fromBaloon = 0;
}

/* -------------- "baloons" end -------------- */