/* Slide/hide ver. 3.2.1
 * 8 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 i,els = document.getElementsByTagName('*');
	for (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.morphData && e.morphData.running)) return;
	if (duration === undefined) duration = 750;
	var step, steps = Math.max(Math.ceil(duration/15),1);
	e.style.overflow = 'hidden';
	if (!e.morphData) e.morphData = { run: function(m){if (typeof m == 'function') m(); else if (typeof m == 'string') eval(m)}, f_more:f_more, f_less:f_less };
	if (e.style.height == '0px') {
		morph_height(e,0,e.morphData.naturalHeight,duration,steps,1);
	} else {
		e.morphData.naturalHeight = e.offsetHeight;
		e.morphData.styleHeight = 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 finished = (step == steps);
	var h = finished ? to : from + (to-from)*z;
	e.style.height = h+'px';
	if (finished && h!=0) {
		//e.style.height = e.morphData.styleHeight;
		e.morphData.run(e.morphData.f_less);
		e.morphData = undefined;
		return; }
	if (finished) {
		e.morphData.run(e.morphData.f_more);
		delete e.morphData.running;
		return; }
	var t = duration/steps;
	e.morphData.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='/includes/loading.css';
}
if (window['addEventListener']) addEventListener('load',init_slide_hide,false);
else if (window['attachEvent']) attachEvent('onload',init_slide_hide);

