// JavaScript Document

///////////////////////////////////////////////////

	var browser = 'unknown';
	//alert(navigator.userAgent);
	if (navigator && navigator.userAgent.toLowerCase().indexOf("opera") != -1) browser = 'opera';
	else if (navigator && navigator.userAgent.toLowerCase().indexOf("msie") != -1) browser = 'msie';
	else if (navigator && navigator.userAgent.toLowerCase().indexOf("gecko") != -1) browser = 'gecko';	
	
	function $(elm) {
		return typeof elm == 'string' ? document.getElementById(elm) : elm;
	}
	var max_Width=0;
	function showSection(page, not1st) {
		var section = $('section_'+page);
		
		if (!not1st) {
			section.style.overflow = 'hidden';
			section.style.display = '';
		}
		if(max_Width == 0 ) max_Width =244;
		section.style.width =section.offsetWidth + Math.ceil((max_Width -section.offsetWidth)/8) + 'px';
		//alert(section.offsetWidth +'-'+ max_Width )
		if (section.offsetWidth < max_Width ) {
			if (section.hideTimer) {clearTimeout(section.hideTimer);section.hideTimer=0;}
			section.showTimer = setTimeout('showSection("'+page+'", true);', 20);
		} else {
			section.showTimer = 0;
			section.style.overflow = '';
			section.style.Width = '';
			
		}
	}
	function hideSection(page, not1st ,fix_width) {
		fix_width = fix_width || 0;
		var section = $('section_'+page);
		if (section.style.display == 'none') {return;}
		var tmph = section.offsetWidth;
		if (!not1st) {
			section.style.overflow = 'hidden';
		}
		
		section.style.width = section.offsetWidth - Math.ceil(section.offsetWidth/8) + 'px';
	
		if (browser=='gecko' && document.documentElement.scrollWidth-(document.documentElement.scrollTop+document.documentElement.clientWidth) < section.offsetWidth)
		{
	
		document.documentElement.scrollTop -= (tmph-section.offsetWidth);
	
		}
		//alert(fix_width)
		if (section.offsetWidth > fix_width) {
			if (section.showTimer) {clearTimeout(section.showTimer);section.showTimer=0;}
			section.hideTimer = setTimeout('hideSection("'+page+'", true, '+fix_width+');', 20);
		} else {
			section.hideTimer = 0;
			//section.style.display = 'none';
			section.style.width = fix_width+'px';
			//section.style.overflow = 'hidden';
		}
	}
	
	var currentPage = new Array();
	
	function changePage(page, group, fix_width) {
		set_extras(page);
		if (currentPage[group] && currentPage[group] == page) {
			if (parseInt($('section_'+page).style.width) != (fix_width||0)){
		
				hideSection(page, false, fix_width);
				document.getElementById('td_width').style.width=231 + 'px';
				tbl_Elem='tbl_' + page;
				document.getElementById(tbl_Elem).style.visibility= 'hidden';
			}else
				showSection(page);
		} else {
			
			showSection(page); 
			if (currentPage[group]) {hideSection(currentPage[group], false, fix_width);}
			currentPage[group] = page;
		}
	}
	
	function set_extras(order)
	{
		items=new Array('society','school','home','letter');
		for(key in items)
		{
			Elem='tbl_' + items[key];
			document.getElementById( Elem ).style.visibility='hidden';
		}
		tbl_Elem='tbl_' + order;
		document.getElementById(tbl_Elem).style.visibility= 'visible';
		var a; 
		if (order != 'society')
			document.getElementById('section_society').style.width=0+'px';
		
		switch (order)
		{
			case 'society': 
					a=114 ;
					max_Width=230;
					break
			case 'school':	
					a=114;
					max_Width=0;
					break
			case 'home': 
					a=114;
					max_Width=0;
					break
			case 'letter': 	
					a=114;
					max_Width=0;
					break
		}
		document.getElementById('td_width').style.width= a + 'px';
	}