function popup(width, height)
{
	window.open("/media/flash/game_paragraphen/popup.php", "Game", "left=0, top=0, width="+width+", height="+height);
}

function popup_datendieter(width, height)
{
	window.open("/media/flash/game_datendieter/popup.php", "Game", "left=0, top=0, width="+width+", height="+height);
}

function openSchalk(source){
	if(source == "undefined" || source == ""){
		source = GAME_HJR;
	}
	window.open("http://www.schalk-and-friends.de/?RON="+source, "Schalk&Friends", "left=0, top=0, width=800, height=600, menubar=yes, titlebar=yes, toolbar=yes, location=yes, resizable=yes");
}

function tellafriend(modus) {
	//var taflayer = document.getElementById("taflayer");
	loadForm(modus)
	//taflayer.style.display = "";
}

function tafclose() {
	var taflayer = document.getElementById("taflayer");
	taflayer.style.display = "none";
} 

function loadForm(modus) {
new Request({
			url: "tellafriend_form.php",
			method: "post",
			//data: dta,
			onComplete: function(responseHTML) {
				var html = JSON.decode(responseHTML);
				$("formContainer").innerHTML = html.data;
				$("taflayer").style.display = "";
			}
		}).post("tellafriend_form.php");
	var taflayer = document.getElementById("taflayer");
	if(modus == "intro"){
		taflayer.style.left = "77px";
		taflayer.style.top = "90px";
	}else{
		taflayer.style.left = "182px";
		taflayer.style.top = "88px";
	}
	//$("formContainer").load("tellafriend_form.php");
	//$("taflayer").style.display = "";
}

function checkForm() {
	var el = document.tafform.elements;
	var errors = 0;

	for(i = 0; i < el.length; i++) {
		if(el[i].type == "text") {
			if( el[i].id == "myName" && el[i].value.length == 0 )
				errors++;
			
			if( el[i].id == "myVorname" && el[i].value.length == 0 )
				errors++;
			
			if( el[i].id == "myEmail" && el[i].value.length == 0 || el[i].id == "myEmail" && el[i].value.indexOf("@") < 0 )
				errors++;
			
			if( el[i].id == "friend1" && el[i].value.length == 0 || el[i].id == "friend1" && el[i].value.indexOf("@") < 0 )
				errors++;
		}
	}
	
	if( errors > 0 ) {
		alert("Es sind nicht alle Felder ausgefüllt");
		return;
	}
	else {
		var taflayer = document.getElementById("taflayer");
		$("formContainer").innerHTML = '<div align="center"><h4>Einen Moment bitte...</h4><p>Deine Daten werden &uuml;bermittelt</p><p><img src="images/wait.gif" alt="" title="" /></p></div>';
		
		dta = { "myName": el['myName'].value, "myVorname": el['myVorname'].value, "myEmail": el['myEmail'].value, "friend1": el['friend1'].value, "friend2": el['friend2'].value, "friend3": el['friend3'].value }
		
		new Request({
			url: "taf.php",
			method: "post",
			data: dta,
			onComplete: function(responseHTML) {
				var html = JSON.decode(responseHTML);
				$("formContainer").innerHTML = html.innerHTML;
			}
		}).post("taf.php");
	}
}