//////////////////////////////////////////////////////////////////////////////
//                      Show/Hide With a Slide Script                       //
//////////////////////////////////////////////////////////////////////////////
//
// CONTRIBUTORS:
//
// Original Creator:
//     Paul Hirsch
//     www.paulhirsch.com
//
// Tested by:
//     International Web Developers Network (IWDN)
//     www.iwdn.net - home page
//     www.iwdn.net/index.php - forums/community where testing took place
//
// Other Contributors:
//     Michaeljohn Clement - clued me in on offsetHeight - very handy!
//     Richard Brattlund - added plus and minus signs automatically changing onClick :)
//
//
// LICENSE:
//
// This script is protected under General Public License (GPL).  Feel free to
// redistribute this script, so long as you do not alter any of the contents
// specifying authorship.  If you add to or modify this script, you may add
// your name to the "Other Contributors" list at the top of this script.  As
// a courtesy, please email me and let me know how you've improved my script!
// You may not profit from the direct sale of this script.  You may use this
// script in commercial endeavors however (i.e. as part of a commercial site).
//
// Email me here: http://www.paulhirsch.com/contact_me.php
//
// Copyright 2006, Paul Hirsch. All rights specified herein and within GPL
// documentation: http://www.gnu.org/licenses/gpl.txt
//
//////////////////////////////////////////////////////////////////////////////
// DO NOT TOUCH ANYTHING BELOW THIS LINE                                    //
// unless you know what the heck you're doing!                              //
//////////////////////////////////////////////////////////////////////////////

var Hide = "";
var varHt = 0;
var Ht = "";
var x = 0;
var y = 10;
var z = 4;
var foo = new Array();
var Speed = "";

function setup() {
	foo = document.getElementsByTagName("div");
	for (i=0;i<foo.length;i++) {
		if (foo[i].className == "hidden") {
			Hide = foo[i].id;
		}
	}
	Ht = document.getElementById(Hide).offsetHeight;
	Speed = Hide.substring(Hide.lastIndexOf('-')+1);
	document.getElementById(Hide).style.height = '0px';
	document.getElementById('toggle').style.display = 'inline';

	if (Speed == 1) { y = 100; z = 1; }
	if (Speed == 2) { y = 70; z = 1; }
	if (Speed == 3) { y = 40; z = 1; }
	if (Speed == 4) { y = 20; z = 1; }
	if (Speed == 5) { y = 10; z = 1; }
	if (Speed == 6) { y = 10; z = 2; }
	if (Speed == 7) { y = 10; z = 4; }
	if (Speed == 8) { y = 10; z = 7; }
	if (Speed == 9) { y = 10; z = 10; }
}

function toggle() {
	if (x === 0) {
		document.getElementById('expandBtn').src='http://richardbrattlund.se/service/wp-content/themes/service/images/btn_minus.gif';
		document.getElementById(Hide).style.height = varHt+'px';
		if (((Ht-varHt) < z) && (varHt !== Ht)) {
			varHt = Ht;
		} else {
			varHt = varHt+z;
		}
		if (varHt <= Ht) {
			setTimeout('toggle()',y);
		}
		if (varHt > Ht) {
			varHt = Ht;
			x = 1;
		}
	} else {
		document.getElementById('expandBtn').src='http://richardbrattlund.se/service/wp-content/themes/service/images/btn_plus.gif';
		document.getElementById(Hide).style.height = varHt+'px';
		varHt = varHt-z;
		if ((Ht-varHt) <= Ht) {
			setTimeout('toggle()',y);
		}
		if ((Ht-varHt) > Ht) {
			varHt = 0;
			document.getElementById(Hide).style.height = varHt+'px';
			x = 0;
		}
	}
}