function init() {
	running1 = false;
	running2 = false;
	running3 = false;
	running4 = false;
	running5 = false;
	endHeight = 70;
	speed = 20; // speed is inverted: larger is slower
	acc = 40; // accelleration: larger is slower
	viewportHeight();
	document.getElementById('hook1').style.height = startHeight;
	document.getElementById('hook2').style.height = startHeight;
	document.getElementById('hook3').style.height = startHeight;
	document.getElementById('hook4').style.height = startHeight;
	document.getElementById('hook5').style.height = startHeight;
}

function toggle1() {
	if(running1 == false) {
		block = document.getElementById("hook1");
		if(block.offsetHeight < startHeight) {
			expand1();
		} else {
			contract1();
		}
	}
}
function toggle2() {
	if(running2 == false) {
		block = document.getElementById("hook2");
		if(block.offsetHeight < startHeight) {
			expand2();
		} else {
			contract2();
		}
	}
}
function toggle3() {
	if(running3 == false) {
		block = document.getElementById("hook3");
		if(block.offsetHeight < startHeight) {
			expand3();
		} else {
			contract3();
		}
	}
}
function toggle4() {
	if(running4 == false) {
		block = document.getElementById("hook4");
		if(block.offsetHeight < startHeight) {
			expand4();
		} else {
			contract4();
		}
	}
}
function toggle5() {
	if(running5 == false) {
		block = document.getElementById("hook5");
		if(block.offsetHeight < startHeight) {
			expand5();
		} else {
			contract5();
		}
	}
}

function expand1() {
	running1 = true;
	var block = document.getElementById("hook1");
	var ge1 = window.setTimeout("expand1()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight >= startHeight) {
		block.style.height = startHeight+"px";
		window.clearTimeout(ge1);
		running1 = false;
	}
	var newHeight=currHeight+Math.ceil((startHeight-currHeight)/acc);
	block.style.height = newHeight+"px";
}

function contract1() {
	running1 = true;
	var block = document.getElementById("hook1");
	var gc1 = window.setTimeout("contract1()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight <= endHeight) {
		block.style.height = endHeight+"px";
		window.clearTimeout(gc1);
		running1 = false;
	}
	var newHeight=currHeight-Math.ceil((currHeight-endHeight)/acc);
	block.style.height = newHeight+"px";
}

function expand2() {
	running2 = true;
	var block = document.getElementById("hook2");
	var ge2 = window.setTimeout("expand2()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight >= startHeight) {
		block.style.height = startHeight+"px";
		window.clearTimeout(ge2);
		running2 = false;
	}
	var newHeight=currHeight+Math.ceil((startHeight-currHeight)/acc);
	block.style.height = newHeight+"px";
}

function contract2() {
	running2 = true;
	var block = document.getElementById("hook2");
	var gc2 = window.setTimeout("contract2()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight <= endHeight) {
		block.style.height = endHeight+"px";
		window.clearTimeout(gc2);
		running2 = false;
	}
	var newHeight=currHeight-Math.ceil((currHeight-endHeight)/acc);
	block.style.height = newHeight+"px";
}

function expand3() {
	running3 = true;
	var block = document.getElementById("hook3");
	var ge3 = window.setTimeout("expand3()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight >= startHeight) {
		block.style.height = startHeight+"px";
		window.clearTimeout(ge3);
		running3 = false;
	}
	var newHeight=currHeight+Math.ceil((startHeight-currHeight)/acc);
	block.style.height = newHeight+"px";
}

function contract3() {
	running3 = true;
	var block = document.getElementById("hook3");
	var gc3 = window.setTimeout("contract3()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight <= endHeight) {
		block.style.height = endHeight+"px";
		window.clearTimeout(gc3);
		running3 = false;
	}
	var newHeight=currHeight-Math.ceil((currHeight-endHeight)/acc);
	block.style.height = newHeight+"px";
}

function expand4() {
	running4 = true;
	var block = document.getElementById("hook4");
	var ge4 = window.setTimeout("expand4()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight >= startHeight) {
		block.style.height = startHeight+"px";
		window.clearTimeout(ge4);
		running4 = false;
	}
	var newHeight=currHeight+Math.ceil((startHeight-currHeight)/acc);
	block.style.height = newHeight+"px";
}

function contract4() {
	running4 = true;
	var block = document.getElementById("hook4");
	var gc4 = window.setTimeout("contract4()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight <= endHeight) {
		block.style.height = endHeight+"px";
		window.clearTimeout(gc4);
		running4 = false;
	}
	var newHeight=currHeight-Math.ceil((currHeight-endHeight)/acc);
	block.style.height = newHeight+"px";
}

function expand5() {
	running5 = true;
	var block = document.getElementById("hook5");
	var ge5 = window.setTimeout("expand5()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight >= startHeight) {
		block.style.height = startHeight+"px";
		window.clearTimeout(ge5);
		running5 = false;
	}
	var newHeight=currHeight+Math.ceil((startHeight-currHeight)/acc);
	block.style.height = newHeight+"px";
}

function contract5() {
	running5 = true;
	var block = document.getElementById("hook5");
	var gc5 = window.setTimeout("contract5()",speed);
	var currHeight = block.offsetHeight;
	if (currHeight <= endHeight) {
		block.style.height = endHeight+"px";
		window.clearTimeout(gc5);
		running5 = false;
	}
	var newHeight=currHeight-Math.ceil((currHeight-endHeight)/acc);
	block.style.height = newHeight+"px";
}

function viewportHeight() {
	// Sets startHeight according to viewport; crossbrowser
	if (self.innerHeight) {
		startHeight = self.innerHeight;
		startWidth = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		startHeight = document.documentElement.clientHeight;
		startWidth = document.documentElement.clientWidth;
	}
	else if (document.body) {
		startHeight = document.body.clientHeight;
		startWidth = document.body.clientWidth;
	}
	
	// Fix disappearing scrollbar jump
	viewwidth = document.getElementById('viewport');
	portmargin = Math.floor(startWidth-960)/2;
	viewwidth.style.marginLeft = portmargin+"px";
}