//Javascript Document

/* 
 * $Author$
 * $Date$
 * $Revision$
 *
 * dyninterface
 * 
 * Developped in 2008, 2009 and 2010 by Pierre-Luc Blain
 * Concept by Pierre-Luc Blain
 *
 * mART productions 2010, All rights reserved
 */

var current_section='';
var stimer;
var target_section='';
var ws_height=0;//The height of the content area

var from_height=100;
var to_height=0;
var from_obj_body;
var to_obj_body;
var from_obj_content;
var to_obj_content;
var accel=0.3333;
var nav_app_name="";
var busy=false;

function SectionHead_OnClick(element)
{
	var section_id;
	
	if(busy==true) return;
	
	section_id=element.id;
	
	if(current_section=="")
	{
		current_section=section_id;
	}

	if(current_section!=section_id)
	{
		Section_OnChange(current_section, section_id)
	}
}

function Section_OnChange(from_section_id, to_section_id)
{
	var delay=50;
	var amount=33;

	clearInterval(stimer);
	target_section=to_section_id;
	
	nav_app_name=navigator.appName;
	
	if(nav_app_name=='Microsoft Internet Explorer')
	{
		delay=75;
		amount=5;
	}
	
	from_obj_content=GetObjById(current_section + "_Contents");
	to_obj_content=GetObjById(target_section + "_Contents");
	ws_height=from_obj_content.offsetHeight;
	
	from_obj_body=GetObjById(current_section + "_Body");
	to_obj_body=GetObjById(target_section + "_Body");	
		
	show(to_section_id + "_Body");
	
	busy=true;
	stimer=setInterval(TransferHeight, delay, amount);
	return;	
}

function TransferHeight(amount)
{
	if(amount==null)
	{
		amount=10;
	}
	
	from_height=(from_height-(to_height+amount)*accel);
	to_height=(to_height+(to_height+amount)*accel);
	
	if(to_height>=100)
	{
		clearInterval(stimer);
		if(nav_app_name=='Netscape')
		{
			from_obj_content.style.height="0px";
			to_obj_content.style.height=ws_height;
		}
		
		current_section=target_section;
		to_obj_body.style.height="100%";	
		from_obj_body.style.height="0px";
		from_obj_body.style.visibility='hidden';
		from_obj_body.style.overflow='hidden';
		from_height=100;
		to_height=0;
		busy=false;
	}
	else
	{
		if(nav_app_name=='Netscape')
		{
			from_obj_content.style.height=from_height/100*ws_height;
			to_obj_content.style.height=to_height/100*ws_height;
		}
		
		from_obj_body.style.height=(from_height) + "%";	
		to_obj_body.style.height=(to_height) + "%";
	}
	return;
}
