//CONTACT

var cpopTimer = "";



function showcontactPopup(e) {

	var popcontact = document.getElementById('cpop');

	var btncontact = document.getElementById('contact');



	if (moveanim.timer != null) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}



	// Determine where we should pop up in relation to the projecten button



	position = findElementPos(btncontact);

	popcontact.style.top = (position[1] - (popcontact.offsetHeight - 25)) +"px";

	popcontact.style.left = "515" + "px";



	// If already trigger a rollover, cancel it because we're back in



	if (cpopTimer != "")

	{

		clearTimeout(cpopTimer);

		cpopTimer = "";

	} else {

		setOpacity(0, 'cpop');

		popcontact.style.visibility = 'visible';

		moveStart(popcontact, parseInt(popcontact.style.left), parseInt(popcontact.style.left), parseInt(popcontact.style.top) + 10, parseInt(popcontact.style.top), 15);

		fadeElementSetup('cpop', 0, 100, 13);

	}

}



function hidecontactPopup() {

	// Start timer to hide the pop-up and the overlay

	cpopTimer = setTimeout("actuallyHide()", 500);

}



function actuallyHide() {

	var popcontact = document.getElementById('cpop');

	if (cpopTimer != "")

	{

		cpopTimer = "";

		moveStart(popcontact, parseInt(popcontact.style.left), parseInt(popcontact.style.left), parseInt(popcontact.style.top), parseInt(popcontact.style.top) - 10, 15);		

		fadeElementSetup('cpop', 100, 0, 13, 1);

	}

}



//

// MOVE: Animate the move of an element.

//

// Move is also synchronous. One at a time, please.

//



var moveanim = {time:0, beginX:0, changeX:0.0, beginY:0, changeY:0, duration:0.0, element:null, timer:null};



function moveStart(elem, startX, endX, startY, endY, duration)

{

	if (moveanim.timer != null) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}

	moveanim.time = 0;

	moveanim.beginX = startX;

	moveanim.changeX = endX - startX;

	moveanim.beginY = startY;

	moveanim.changeY = endY - startY;

	moveanim.duration = duration;

	moveanim.element = elem;



	moveanim.timer = setInterval("moveAnimDo();", 15);

}



function moveAnimDo()

{

	if (moveanim.time > moveanim.duration) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}

	else {

		moveX = cubicOut(moveanim.time, moveanim.beginX, moveanim.changeX, moveanim.duration);

		moveY = cubicOut(moveanim.time, moveanim.beginY, moveanim.changeY, moveanim.duration);

		moveanim.element.style.left = moveX + "px";

		moveanim.element.style.top = moveY + "px";

		moveanim.time++;

	}

}

//PROJECTEN

var ppopTimer = "";



function showprojectenPopup(e) {

	var popprojecten = document.getElementById('ppop');

	var btnprojecten = document.getElementById('projecten');



	if (moveanim.timer != null) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}



	// Determine where we should pop up in relation to the projecten button



	position = findElementPos(btnprojecten);

	popprojecten.style.top = (position[1] - (popprojecten.offsetHeight - 25)) +"px";

	popprojecten.style.left = "167" + "px";



	// If already trigger a rollover, cancel it because we're back in



	if (ppopTimer != "")

	{

		clearTimeout(ppopTimer);

		ppopTimer = "";

	} else {

		setOpacity(0, 'ppop');

		popprojecten.style.visibility = 'visible';

		moveStart(popprojecten, parseInt(popprojecten.style.left), parseInt(popprojecten.style.left), parseInt(popprojecten.style.top) + 10, parseInt(popprojecten.style.top), 15);

		fadeElementSetup('ppop', 0, 100, 13);

	}

}



function hideprojectenPopup() {

	// Start timer to hide the pop-up and the overlay

	ppopTimer = setTimeout("actuallyHide2()", 500);

}



function actuallyHide2() {

	var popprojecten = document.getElementById('ppop');

	if (ppopTimer != "")

	{

		ppopTimer = "";

		moveStart(popprojecten, parseInt(popprojecten.style.left), parseInt(popprojecten.style.left), parseInt(popprojecten.style.top), parseInt(popprojecten.style.top) - 10, 15);		

		fadeElementSetup('ppop', 100, 0, 13, 1);

	}

}



//

// MOVE: Animate the move of an element.

//

// Move is also synchronous. One at a time, please.

//



var moveanim = {time:0, beginX:0, changeX:0.0, beginY:0, changeY:0, duration:0.0, element:null, timer:null};



function moveStart(elem, startX, endX, startY, endY, duration)

{

	if (moveanim.timer != null) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}

	moveanim.time = 0;

	moveanim.beginX = startX;

	moveanim.changeX = endX - startX;

	moveanim.beginY = startY;

	moveanim.changeY = endY - startY;

	moveanim.duration = duration;

	moveanim.element = elem;



	moveanim.timer = setInterval("moveAnimDo();", 15);

}



function moveAnimDo()

{

	if (moveanim.time > moveanim.duration) {

		clearInterval(moveanim.timer);

		moveanim.timer = null;

	}

	else {

		moveX = cubicOut(moveanim.time, moveanim.beginX, moveanim.changeX, moveanim.duration);

		moveY = cubicOut(moveanim.time, moveanim.beginY, moveanim.changeY, moveanim.duration);

		moveanim.element.style.left = moveX + "px";

		moveanim.element.style.top = moveY + "px";

		moveanim.time++;

	}

}