
function popUp(URL,width,height)
{
	day = new Date();
	id = day.getTime();
	var winLeft = (screen.width - width) / 2;
	var winUp = (screen.height - height) / 2;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left='+winLeft+',top='+winUp);");
}

function contact_by_mail(user, domain, suffix, content) {
	if (!content) {
		document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
	} 
	else {
		document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + content + '</a>');
	}
	return true;
}

function openPopup() {
	loadCode();
	checkCode();
	Effect.Appear('popup_back', {duration: 0.3});
	Effect.BlindDown('popup_center');
}

function showPlayer() {
	document.getElementById('player').style.display = 'block';
}

var time = "";
function closePopup() {
	clearTimeout(time);
	Effect.Fade('popup_back');
	Effect.DropOut('popup_center');
}

/* ajax for popup */

function loadCode() {
	new Ajax.Updater('popup_container', '/special/ajax/generate_code.php', {
			asynchronous:true, method:'get'
		}
	);
}

function loadDownload() {
	document.getElementById('popup_container').style.backgroundImage = "url(/images/papa/back_popup_ok.gif)";
	new Ajax.Updater('popup_container', '/special/ajax/download.php', {
			asynchronous:true, method:'get', evalScripts:true
		}
	);
}

function checkCode() {
	var popupDisplay = document.getElementById('popup_center').style.display;
	
	var completHandler = function(t) {
		if(t.responseText.substring(0, 2) == "OK") {
			// meld bezoeker dat download is toegestaan
			loadDownload();
		}
		else {
			time = setTimeout("checkCode()", 5000);
			
			// download is niet toegestaan
			//alert('fout');
		}
	}
	
	new Ajax.Request('/special/ajax/check_code.php', {
			asynchronous:true, method:'get', 
			onComplete: completHandler
		}
	);
}


