var openSiteTimeout;
var openPageTimeout;

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
function music_DoFSCommand(command, args) {
	var musicObj = isInternetExplorer ? document.all.music : document.music;
	if (command=='openSite')
		openSite();
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub music_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call music_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}


function opacity(id, opacStart, opacEnd, millisec)
{
	//speed for each frame 
	var speed = Math.round(millisec / 100); 
	var timer = 0; 

	//determine the direction for the blending, if start and end are the same nothing happens 
	if(opacStart > opacEnd)
	{ 
		for(i = opacStart; i >= opacEnd; i--)
		{ 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		} 
	}
	else if(opacStart < opacEnd)
	{ 
		for(i = opacStart; i <= opacEnd; i++) 
		{ 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		} 
	} 
} 

// Change the opacity for different browsers 
function changeOpac(opacity, id)
{ 
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")"; 
}

// Write the navigation flash
function openSite()
{
	clearTimeout(openSiteTimeout);
	
	document.getElementById('main').innerHTML = '';
	
	document.getElementById('topLeft').className='topLeft';
	document.getElementById('headerArea').className='header';
	document.getElementById('adverts').className='header';
	document.getElementById('main').className='main';
	document.getElementById('navigationArea').className='navigation';
	document.getElementById('main').align='left';
	
	setTimeout('openPageWithId(\'php/navigation.php\',\'navigationArea\');',500);
	setTimeout('addHeaderArea();',3000);
	setTimeout('openPageWithId(\'php/adverts.php\',\'adverts\');',6000);
	openPageTimeout=setTimeout('openPage(\'php/home.php\');',6000);
}

// Add the header area
function addHeaderArea()
{
	html =	'<table cellspacing="0">'
		+		'<tr>'
		+			'<td>'
		+				'<img id="headerImg" src="images/logo.jpg" alt="Asian Resource Centre Logo" style="opacity: 0; filter: alpha(opacity=0);" />'
		+			'</td>'
		+			'<td>'
		+				'<a target="_blank" id="breakingNewsLink">'
		+					'<img class="slideshow" id="breakingNews" src="images/blank.jpg" alt=""/ style="border-style: none;">'
		+				'</a>'
		+			'</td>'
		+		'</tr>'
		+	'</table>';

	document.getElementById('headerArea').innerHTML = html;
	
	opacity("headerImg", 0, 100, 3000);
}