/* Slide/hide ver. 3.2
 * 1 November 2007
 * By Paul Hirsch and Michaeljohn Clement
 * http://www.iwdn.net/showthread.php?t=5954
 * Released into the public domain, use as you like.
 */
function init_slide_hide() {
	var els = document.getElementsByTagName('*');
	for (var i=0;i<els.length;i++) {
		if (els[i].className == 'hide_me') slide(els[i].id,0);
		if (els[i].className == 'slide_in') { slide(els[i].id,0); slide(els[i].id) }
	}
	var l = document.getElementById('loading_css');
	if (l) {l.href='';l.parentNode.removeChild(l)}
}
function slide(e,duration,f_more,f_less){
	if (typeof e == 'string') e = document.getElementById(e);
	if (!e || !e.style || (e.morph_data && e.morph_data.running)) return;
	if (duration === undefined) duration = 750;
	var step, steps = Math.max(Math.ceil(duration/10),1);
	e.style.overflow = 'hidden';
	if (!e.morph_data) e.morph_data = new Object();
	e.morph_data.f_more=f_more; e.morph_data.f_less=f_less;
	if (e.style.height == '0px') {
		morph_height(e,0,e.morph_data.naturalHeight,duration,steps,1);
	} else {
		e.morph_data.naturalHeight = e.offsetHeight;
		e.morph_data.style_height = e.style.height;
		morph_height(e,e.offsetHeight,0,duration,steps,1);
	}
}
function morph_height(e,from,to,duration,steps,step) {
	var x = step/steps;
	var y = Math.sin((x-0.5)*Math.PI);
	var z = (y+1)*0.5;
	var h = from + (to-from)*z;
	var finished = (step == steps);
	if (finished) h = to;
	e.style.height = h+'px';
	function run(m){if (typeof m == 'function') m(); else if (typeof m == 'string') eval(m)}
	if (finished && h!=0) {
		//e.style.height = e.morph_data.style_height;
		run(e.morph_data.f_less);
		e.morph_data = undefined;
		return;
	}
	if (finished) {
		run(e.morph_data.f_more);
		delete e.morph_data.running;
		return;
	}
	var t = duration/steps;
	e.morph_data.running = setTimeout(function(){morph_height(e,from,to,duration,steps,step+1)},t);
}
var noscript_css = document.getElementById('noscript_css');
if (noscript_css) {
	noscript_css.id='loading_css';
	noscript_css.href='loading.css';
}
if (window['addEventListener']) addEventListener('load',init_slide_hide,false);
else if (window['attachEvent']) attachEvent('onload',init_slide_hide);
