// doContentFix: omdat het niet mogelijk bleek om content-main1 wijs te maken dat hij de hoogte had van de hoogste td
// (die met content), deze fix om alsnog de achtergrond afbeelding onderaan te krijgen.
function doContentFix() {
	var contentMain1 = document.getElementById("content-main1");
	var new_height = contentMain1.offsetHeight;
	
	var contentFix = document.getElementById("content-fix");	

	// de content-left afbeelding pas tonen als het element zijn nieuwe hoogte heeft gekregen
	var contentLeft = document.getElementById("content-left");	
	contentLeft.getElementsByTagName("table")[0].style.height = (new_height.toInt() + 114) + 'px';
	contentLeft.getElementsByTagName("table")[0].style.backgroundImage = 'url(images/content_left_bg.gif)';
	
	// de arrow bij de funny wordt pas zichtbaar (afbeelding vervangen) als het element zijn nieuwe hoogte heeft gekregen
	var contentRightArrow = document.getElementById("content-right-arrow");			
	contentRightArrow.getElementsByTagName("img")[0].src = "images/block_arrow.gif";
	
	// de funny staat eerst buiten beeld: nu in de juiste positie plaatsen, zodat hij niet van de oude naar de nieuwe positie lijkt te springen
	var funny = $('funny');
	funny.setStyle('height', (new_height.toInt() + 96) + 'px');
	funny.style.backgroundPosition = "left bottom";
}

function mouseoverPortfolio(id) {
	var divPortfolio = document.getElementById("divPortfolio" + id);
	divPortfolio.style.width = '89px';
	divPortfolio.style.height = '57px';
	divPortfolio.style.border = '0';
}

function mouseoutPortfolio(id) {
	var divPortfolio = document.getElementById("divPortfolio" + id);
	divPortfolio.style.width = '79px';
	divPortfolio.style.height = '47px';
	divPortfolio.style.border = '5px solid #FFDE00';
}

function doSubmit(form) {
	var frmContactForm = document.getElementById(form);
	var txtContactNaam = document.getElementById("txtContactNaam");
	var txtContactEmail = document.getElementById("txtContactEmail");
	var txtContactBericht = document.getElementById("txtContactBericht");

	if (!jsValidateField("txtContactNaam","text")) {
		alert('U heeft geen naam ingevuld. Probeer het a.u.b. nogmaals.');	
		txtContactNaam.focus();
	} else if (!jsValidateField("txtContactEmail","email")) {
		alert('U heeft geen e-mail adres ingevuld. Probeer het a.u.b. nogmaals.');
		txtContactEmail.focus();
	} else if (!jsValidateField("txtContactBericht","text")) {
		alert('U heeft geen vraag of opmerking ingevuld. Probeer het a.u.b. nogmaals.');
		txtContactBericht.focus();
	} else { 
		frmContactForm.submit();	
	}	
}

function swapPortfolioPage(change) {
	var myRequest = new Request.JSON ({
		url: 'include/moo.inc.php',
		data: {			
			request: 'swapPortfolio',
			pp: ($('pp').value.toInt() + change.toInt())
		},
		onRequest: function() {
			$('pp').set('value', ($('pp').value.toInt() + change.toInt()));
		},
		onSuccess: function(response) {
			var portfolioList = $('portfolio-list');
			portfolioList.set('html', response.new_html);
			
			var pp = $('pp');
			var portfolioLNav1 = $('portfolio-lnav1');
			var portfolioLNav2 = $('portfolio-lnav2');			
			if (pp.get('value').toInt() == 1) {
				portfolioLNav1.set('html', '<img src="images/t.gif" width="7" height="7" alt="">');
				portfolioLNav2.set('html', '<img src="images/t.gif" width="100" height="7" alt="">');
			} else {
				portfolioLNav1.set('html', '<a href="#" onclick="swapPortfolioPage(\'-1\');return false;"><img src="images/portfolionav_arrow_left.gif" width="7" height="7" alt=""></a>');
				portfolioLNav2.set('html', '<a href="#" onclick="swapPortfolioPage(\'-1\');return false;">vorige</a>');
			}
			
			var portfolioRNav1 = $('portfolio-rnav1');
			var portfolioRNav2 = $('portfolio-rnav2');
			if (response.more.toInt() > 0) {
				portfolioRNav1.set('html', '<a href="#" onclick="swapPortfolioPage(\'1\');return false;">volgende</a>');
				portfolioRNav2.set('html', '<a href="#" onclick="swapPortfolioPage(\'1\');return false;"><img src="images/portfolionav_arrow_right.gif" width="7" height="7" alt=""></a>');
			} else {
				portfolioRNav1.set('html', '<img src="images/t.gif" width="100" height="7" alt="">');
				portfolioRNav2.set('html', '<img src="images/t.gif" width="7" height="7" alt="">');			
			}
			
			doContentFix();
		}
	});
	myRequest.send();	
}

function showPopup(id) {
	var allPopup = document.getElementsByClassName("popup-container");
	for (var i=0; i<allPopup.length; i++) {
		allPopup[i].style.display = "none";	
	}
	
	var divPopup = document.getElementById("divPopup"+id);		
	divPopup.style.display = "block";			
}

function hidePopup(id) {
	var divPopup = document.getElementById("divPopup"+id);
	divPopup.style.display = "none";
}