var intStr = "0123456789 -/";

function changeURL(url){
	window.opener.location = url;
	window.close();
}

function checkAll(){
	var name = document.getElementById("name").value;
	var xNum = document.getElementById("xNum").value;
	var yNum = document.getElementById("yNum").value;
//	var speed = document.getElementById("speed").value;

	if(xNum == "" || xNum> 30 || xNum <7 || !isInt(xNum) || yNum == "" || yNum> 30 || yNum <7 || !isInt(yNum) || xNum*yNum > 420){
		alert("Il numero di righe e di colonne dev'essere compreso tra 7 e 30. Inoltre il prodotto righe per colonne dev'essere minore di 421. E' stato inserito il valore pił vicino.\n---------------------------------------\nRows and Cols number must be greater than 7 and smaller than 30. Besides, the product cols per rows should be smaller than 421. Highest value inserted.");
		document.getElementById("xNum").value	 = "20";
		document.getElementById("yNum").value	 = "21";	
		return false;
	}

	if(trim(name)==""){
		alert("Inserisci un nome valido!\n---------------------------------------\nInsert a valid name!");
		document.getElementById("name").value = "Player 1";
		return false;
	}

	document.getElementById("name").value = trim(name);
 window.open('http://www.lyra.net/fabio/giochi/expBall/sendTo.php', 'Popup','width=770,height=570,left=150,top=150,scrollbars=no,resizable=no');
document.getElementById('f1').target='Popup';
return true;

}

function isInt(myS){
	for (var i = 0; i < myS.length; i++) {
   		if (intStr.indexOf(myS.charAt(i)) < 0) {
         	return false;
        }
    }
	return true;
}


function trim(stringa){

	while (stringa.substring(0,1) == ' '){
		stringa = stringa.substring(1, stringa.length);
	}

	while (stringa.substring(stringa.length-1, stringa.length) == ' '){
		stringa = stringa.substring(0,stringa.length-1);
	}

	return stringa;
}
