tiTime=3500;
tiOn=1;
iBubble_half=new Image();
iBubble_half.src='assets/templates/main/img/bubble_half.gif';
iBubble_up=new Image();
iBubble_up.src='assets/templates/main/img/bubble_up.gif';
iBubble_down=new Image();
iBubble_down.src='assets/templates/main/img/bubble_down.gif';
iBubble_off=new Image();
iBubble_off.src='assets/templates/main/img/bubble_off.gif';
iBubble_0=new Image();
iBubble_0.src='assets/templates/main/img/0.gif';
aBubbles=new Array();
aNames=new Array();
oH=0;
sURL='';
var x1=0;
var y1=0;
var ti=0;
oldO=-1;
old2O=-1;
var hideAll=0;
aUnicalInilitialised=0;
initUnical=0;
window.onload=init;
window.onresize=init2;
/*-----------------------------------------------------------------------*/
function init()
{
	if (!document.getElementById) return;
	oBubble=document.getElementById ('iBubble');
	oH=document.getElementById ('hTitle');
	oHOldValue=oH.innerHTML;
	oD=document.getElementById ('dBodyMap');
	oDA=document.getElementById ('dA');
	x1=0;
	y1=0;
	oTmp=oD;
	while (oTmp.offsetParent)
	{
		oTmp=oTmp.offsetParent;
		x1+=oTmp.offsetLeft;
		y1+=oTmp.offsetTop;
	}
	aBubbles=new Array();
	aNames=new Array();
	aBubbles=getTags(oDA,'a');
	if (tiOn) tiStart();
	if (!aUnicalInilitialised && initUnical) initUnical(); /* Added  14.11.2008 for Unicale Operation*/
}
/*-----------------------------------------------------------------------*/
function init2 ()
{
	var i;
	var i2;
	tiStop();
	oldO=-1;
	oH.innerHTML=oHOldValue;
	if(!hideAll)
	{
		for (i=0; i<aBubbles.length; i++)
		{
			for (i2=0; i2<aBubbles[i].length; i2++)
			{
				aBubbles[i][i2].style.display='inline';
				aBubbles[i][i2].src=iBubble_off.src;
				aBubbles[i][i2].style.left=parseInt(aBubbles[i][i2].style.left)-x1+'px';
				aBubbles[i][i2].style.top=parseInt(aBubbles[i][i2].style.top)-y1+'px';
			}
		}
		init();
	}
}
/*-----------------------------------------------------------------------*/
function getTags(o, tag)
{
	var o2;
	o2=o.childNodes;
	var a;
	a=new Array();
	var l=o2.length;
	var sTmp=''; 
	var i;
	for (i=0; i<l;i++ )
	{ 
		sTmp=o2[i].tagName;
		if (sTmp)
		{
			if (sTmp.toLowerCase()==tag.toLowerCase())
			{
				aNames[aNames.length]=o2[i].title;
				a[aNames.length-1]=getBubbles(o2[i],'img');
			}
		}
	}
	return a;
}
/*-----------------------------------------------------------------------*/
function getBubbles(o, tag)
{
	var o2;
	o2=o.childNodes;
	var a=new Array();
	var l=o2.length;
	var sTmp=''; 
	for (var i=0; i<l;i++ )
	{ 
		var sTmp=o2[i].tagName;
		if (sTmp)
		{
			if (sTmp.toLowerCase()==tag.toLowerCase())
			{
				a[a.length]=o2[i];
				o2[i].style.left=parseInt(o2[i].style.left)+x1+'px';
				o2[i].style.top=parseInt(o2[i].style.top)+y1+'px';
				o2[i].src=iBubble_off.src;
			}
		}
	}
	return a;
}
/*-----------------------------------------------------------------------*/
function tiStart ()
/* Start timeout */
{
	ti=window.setInterval ('randomShow();',tiTime);
}
/*-----------------------------------------------------------------------*/
function tiStop ()
/* Stop timeout */
{
	window.clearInterval (ti);
	ti=0;
}
/*-----------------------------------------------------------------------*/
function randomShow ()
/* calculate random bubble and call function to show it */
{
	if (aBubbles.length<2) return; // Return if no bubbles or only one bubble 
	var i;
	i=Math.round (Math.random()*(aBubbles.length-1));	// calculate random number
	while (i==oldO) i=Math.round (Math.random()*(aBubbles.length-1)); //	if new bubble is current bubble then repeat until bubble is not current
	show (i,1);	// call function
}
/*-----------------------------------------------------------------------*/
function show (k, saveOld)
/* show selected object */
{
		var i;
		var found;
		found=0;
		if (typeof (k)=='string')
		{
			for (i in aNames)
			{
				if (aNames[i]==k)
				{
					found=1;
					k=i;
					break;
				}
			}
		}
		else if (typeof (k)=='number' && k>=0 && k<aBubbles.length) found=1;
		if (!found) return;
		if (old2O>-1) 
		{
			for (i=0; i<aBubbles[old2O].length; i++)
			{
				aBubbles[old2O][i].src=iBubble_off.src; // old old bubble(s) must be off!!!!
			}
		}
		if (saveOld)
		{
			if (oldO>-1) 
			{
				for (i=0; i<aBubbles[oldO].length; i++)
				{
					aBubbles[oldO][i].src=iBubble_down.src; // down current bubble(s)
				}
			}
		}
		old2O=oldO; // save old bubble(s) as old old
		oldO=k;	//	save selected(s) bubble as old
		for (i=0;i<aBubbles[k].length; i++)
		{
			aBubbles[k][i].src=iBubble_up.src; //	show current buble(s)
		}
		oH.innerHTML=aNames[k];	// change header to current bubble title
}
/*-----------------------------------------------------------------------*/
function hide ()
{
	if (old2O>-1)
	{
		for (i in aBubbles[old2O])
		{
			aBubbles[old2O][i].src=iBubble_off.src;
		}
	}
	for (i in aBubbles[oldO])
	{
		aBubbles[oldO][i].src=iBubble_down.src;
	}
//		old2O=oldO; // save old bubble(s) as old old
  oH.innerHTML=oHOldValue;
}
/*-----------------------------------------------------------------------*/
function showThis(o, saveOld)
/* Stop timeout and show this object */
{
	if (tiOn&&ti) tiStop();
	show (o,saveOld);
}
/*-----------------------------------------------------------------------*/
function hideAllBubbles()
{
	hideAll=1;
	for (i=0; i<aBubbles.length; i++)
	{
		for (i2=0; i2<aBubbles[i].length; i2++)
		{
			aBubbles[i][i2].style.display='none';
		}
	}
	tiStop();
}