HA_current=0;
HA_fade_interval=0;
current_HA = '';

function load_hosted_app(HA,force)
{
	if((ready || force) && HA != current_HA)
	{
		//HA_fade_interval = setInterval('HA_fade(\''+HA+'\')',30);
		eval(HA+'_content_section.load_section()');
		
		update_location('hosted_apps-'+HA);
		
		if(current_HA != '')
		{
			eval(current_HA+'_content_section.unload_section()');
		}
			
		current_HA = HA;
	}
}

function HA_fade(HA)
{

	for(i=0; i<groups['hosted_apps'].length; i++)
	{
		if(groups['hosted_apps'][i] != 'hosted_apps_header')
		{
			if(HA!=groups['hosted_apps'][i])
			{
				outgoing = groups['hosted_apps'][i];
			
				ID(outgoing).style.opacity = 100-HA_current;
				ID(outgoing).style.MozOpacity = (100-HA_current)/100;
				ID(outgoing).style.KhtmlOpacity = (100-HA_current)/100;
				ID(outgoing).style.filter = "alpha(opacity=" + 100-HA_current + ")";
			}
			else
			{
				ID(HA).style.opacity = HA_current;
				ID(HA).style.MozOpacity = HA_current/100;
				ID(HA).style.KhtmlOpacity = HA_current/100;
				ID(HA).style.filter = "alpha(opacity=" +HA_current + ")"
			}
		}
	}
	
	if(HA_current<25)
	{
		/*ID(incoming).style.opacity = HA_current;
		ID(incoming).style.MozOpacity = HA_current/100;
		ID(incoming).style.KhtmlOpacity = HA_current/100;
		ID(incoming).style.filter = "alpha(opacity=" +HA_current + ")";*/
		HA_current+=5;
	}
	else
	{
		/*ID(outgoing).style.opacity = 10;
		ID(outgoing).style.MozOpacity = 10;
		ID(outgoing).style.KhtmlOpacity = 10;
		ID(outgoing).style.filter = "alpha(opacity=" + ID(outgoing).style.opacity + ")";
		ID(outgoing).style.display='none';*/
		
		ID(HA).style.opacity = 100;
		ID(HA).style.MozOpacity = 1;
		ID(HA).style.KhtmlOpacity = 1;
		ID(HA).style.filter = "alpha(opacity=" + ID(HA).style.opacity + ")";
		HA_current=0;
		clearInterval(HA_fade_interval);
	}
}

function HA_reset()
{
	for(i=0; i<groups['hosted_apps'].length; i++)
	{
		if(groups['hosted_apps'][i] != 'hosted_apps_header')
		{
			outgoing = groups['hosted_apps'][i];
			
			ID(outgoing).style.opacity = 100;
			ID(outgoing).style.MozOpacity = 1;
			ID(outgoing).style.KhtmlOpacity = 1;
			ID(outgoing).style.filter = "alpha(opacity=" + ID(outgoing).style.opacity + ")";
		}
	}
	
	current_HA = '';
}

function quick_load_hosted_app(HA)
{
	load_hosted_app(HA,true)
}

function load_info(title)
{
	eval(title+'_section.load_section()');
}

function unload_info(title)
{
	eval(title+'_section.unload_section()');
}

function load_hosted_apps()
{
	load_all_sections('hosted_apps');		
		
	if(window.location.href.toString().indexOf('#') != -1 && window.location.href.toString().indexOf('-') != -1 && window.location.href.toString().split('#')[1].split('-')[0] == 'hosted_apps')
	{
		default_hosted_app = window.location.href.toString().split('#')[1].split('-')[1];
	}
	else
	{
		default_hosted_app = undefined;
	}
	
	if(default_hosted_app != undefined)
	{
		quick_load_hosted_app(default_hosted_app);
	}
	else
	{	
		unload_all_sections('hosted_apps_content');
		update_location('hosted_apps');
	}
}

function unload_hosted_apps()
{
	unload_all_sections('hosted_apps');
	unload_all_sections('hosted_apps_content');
	current_HA = '';
}


