// -----------------------------------------------------
// Copyright ©2004 deCube design and development
// Datum: 7 december 2004
// -----------------------------------------------------

var currentid = null;
var active = false;
var step = 5;
var browserName=navigator.appName; 

 if (browserName=="Microsoft Internet Explorer")
 {
	step = 10;
 }

// Browsercompatible CSS toegang
function css(layerID) 
{
	if(document.getElementById)
	{ return document.getElementById(layerID).style; }
	
	else if(document.all)
	{ return document.all[layerID].style; }
	
	else if(document.layers)
	{ return document.layers[layerID]; }
}

// Stuur de animatie aan(Welke ID, hoe hoog moet ie worden?)
function unfold(obj,howhigh)
{
if (active == false)
  {
	css(obj).display = "block";

	// als geklikte != de uitgeklapte, klap de huidig opengeklapte dicht
	if(obj != currentid && currentid != null)
	{
        destroy(currentid);
		
	// klap de geklikte open
        build(obj,howhigh);
		currentid = obj;
		return true;
	}
	// als geklikte == de uitgeklapte, klap dan dicht
	if (obj == currentid)
	{
        destroy(obj);
		currentid = null;
		return true;
	}
	// klap actieve open
	if(currentid == null)
	{
 		build(obj,howhigh);
		currentid = obj;
	}
  }
}

// Vergroot de geklikte
function build(obj,howhigh)
{
	var i = parseInt(css(obj).height);
	if (i<howhigh)
	{
		active = true;
		i=i+step;
		css(obj).height = i + "px";
 		setTimeout("build('"+obj+"',"+howhigh+");",10);
	}
	else
	{
		active = false;
	}
}

// Verklein object...
function destroy(obj)
{
	var j = parseInt(css(obj).height);
	if (j>0 && j != step)
	{
		active = true;
		j=j-step;
		css(obj).height = j + "px";
 		setTimeout("destroy('"+obj+"');",10);
	}
	else
	{
		css(obj).display = "none";
		active = false;
	}
}

function switchStyle(styleID)
{
	document.getElementById('selectedstyle').value = styleID;
	document.getElementById('styleForm').submit()
}
