
function ScoreToInt(score) {
if (typeof score == 'null') {
	score = 0;
	}
if (typeof score == "string") {
	if (score.length == 0) {
		score = 0;
		}
	else {
		score = parseInt(score);
		if (isNaN(score)) {
			score = -1;
			}
		}
	}
if (typeof score != "number") {
	score = -1;
	}
if (Math.floor(score) != score) {
	score = -1;
	}
return score;
}

function ScoreUpdate(id,index,score,finish) {
if (id != 3) {
	score = ScoreToInt(score);
	if (score > 180  || score < 0) {
		// can probably also exclude score == 179, 178, 176, 175, 173, 172, 169, 166, 163
		alert('Score is outside range or invalid');
		if (id==1){
			document.form2.our_throw[index].value = '';
			document.form2.our_throw[index].focus();
			}
		if (id==2){
			document.form2.opp_throw[index].value = '';
			document.form2.opp_throw[index].focus();
			}
		}
	
	//calculate and assign darts used
	for (i = document.form2.darts_grid.value - 1; i >= 0 ; i--) {
		if (document.form2.opp_throw[i].value == '0' || document.form2.opp_throw[i].value > 0 || document.form2.our_throw[i].value == '0' || document.form2.our_throw[i].value > 0) {
			document.form2.darts_used.value = (i + 1) * 3;
			break;
			}
		}
	// Calculate total score
	var total = 0;
	for (i = 0; i < document.form2.darts_grid.value ; i++) {
		if (id == 1) {
			total += ScoreToInt(document.form2.our_throw[i].value);
			}
		else {
			total += ScoreToInt(document.form2.opp_throw[i].value);
			}
		}
	if (id == 1) {
		document.form2.our_score.value = total;
		document.form2.player_score.value = document.form2.our_score.value;
		if (total != finish) {
			document.form2.our_out_dart.value = '';
			}
		}
	else {
		document.form2.opponent_score.value = total;
		document.form2.their_score.value = document.form2.opponent_score.value;
		if (total == finish) {
			document.form2.our_out_dart.value = '';
			}
		}
	}
// Set our darts count - if our first throw, we've thrown even if left blank - darts-used is based on either column !
var last_row;
last_row = document.form2.darts_used.value / 3 - 1;
if (document.form2.first_dart.value == 0) {
	document.form2.our_darts_count.value = document.form2.darts_used.value;
	document.form2.odc.value = document.form2.darts_used.value;
	}
else if (document.form2.first_dart.value == 1 && (document.form2.our_throw[last_row].value == '0' || document.form2.our_throw[last_row].value > 0)) { 
	// if their first throw and our score set - we've thrown
	document.form2.our_darts_count.value = document.form2.darts_used.value;
	document.form2.odc.value = document.form2.darts_used.value;
	}
else {
	// their first throw and our score not set - we've thrown 3 less
	document.form2.our_darts_count.value = document.form2.darts_used.value - 3;
	document.form2.odc.value = document.form2.our_darts_count.value;
	}
// Re-do the count down for this player
var score_left;
score_left = finish;
for (i = 0; i <= last_row; i++) {
	if (id == 1) {
		// our score
		score_left -= document.form2.our_throw[i].value;
		document.form2.our_rem[i].value = score_left;
		}
	else {
		// their score
		score_left -= document.form2.opp_throw[i].value;
		document.form2.their_rem[i].value = score_left;
		}
	}
for (i = last_row+1; i < document.form2.darts_grid.value; i++) {
	if (id == 1) {
		// our score
		document.form2.our_rem[i].value = '';
		}
	else {
		// their score
		document.form2.their_rem[i].value = '';
		}
	}

}

function LgScoreUpdate(id,index,score,finish) {
if (id != 3) {
	score = ScoreToInt(score);
	if (score > 180  || score < 0) {
		// can probably also exclude score == 179, 178, 176, 175, 173, 172, 169, 166, 163
		alert('Score is outside range or invalid');
		if (id==1){
			document.form2.our_throw[index].value = '';
			document.form2.our_throw[index].focus();
			}
		if (id==2){
			document.form2.opp_throw[index].value = '';
			document.form2.opp_throw[index].focus();
			}
		}
	
	//calculate and assign darts used
	for (i = document.form2.darts_grid.value - 1; i >= 0 ; i--) {
		if (document.form2.opp_throw[i].value == '0' || document.form2.opp_throw[i].value > 0 || document.form2.our_throw[i].value == '0' || document.form2.our_throw[i].value > 0) {
			document.form2.darts_used.value = (i + 1) * 3;
			break;
			}
		}
	// Calculate total score
	var total = 0;
	for (i = 0; i < document.form2.darts_grid.value ; i++) {
		if (id == 1) {
			total += ScoreToInt(document.form2.our_throw[i].value);
			}
		else {
			total += ScoreToInt(document.form2.opp_throw[i].value);
			}
		}
	if (id == 1) {
		document.form2.our_score.value = total;
		document.form2.player_score.value = document.form2.our_score.value;
		if (total != finish) {
			document.form2.home_out_dart.value = '';
			}
		}
	else {
		document.form2.opponent_score.value = total;
		document.form2.their_score.value = document.form2.opponent_score.value;
		if (total != finish) {
			document.form2.away_out_dart.value = '';
			}
		}
	}
// Set darts counts - if our first throw, we've thrown even if left blank - darts-used is based on either column !
var last_row;
last_row = document.form2.darts_used.value / 3 - 1;
if (last_row <= index) {
	if (document.form2.first_dart.value == 0 && id == 1) {
		// Our first throw and our result - set our column
		document.form2.home_darts_count.value = document.form2.darts_used.value;
		document.form2.odc.value = document.form2.darts_used.value;
		}
	else if (document.form2.first_dart.value == 0) {
		// Our first throw and their result - set both columns
		if (document.form2.home_out_dart.value == 0) {
			// Only adjust if not already won
			document.form2.home_darts_count.value = document.form2.darts_used.value;
			document.form2.odc.value = document.form2.darts_used.value;
			}
		if (document.form2.opp_throw[index].value == '0' || document.form2.opp_throw[index].value > 0) {
			// It's a non-blank score
			document.form2.away_darts_count.value = document.form2.darts_used.value;
			document.form2.adc.value = document.form2.darts_used.value;
			}
		else {
			// It's a blank score
			document.form2.away_darts_count.value = document.form2.darts_used.value - 3;
			document.form2.adc.value = document.form2.darts_used.value - 3;
			}
		}
	else if (id == 1) {
		// Their first throw - our result
		if (document.form2.our_throw[index].value == '0' || document.form2.our_throw[index].value > 0) {
			// It's a non blank score
			document.form2.home_darts_count.value = document.form2.darts_used.value;
			document.form2.odc.value = document.form2.darts_used.value;
			}
		else {
			// It's a blank score
			document.form2.home_darts_count.value = document.form2.darts_used.value - 3;
			document.form2.odc.value = document.form2.darts_used.value - 3;
			}
		if (document.form2.away_out_dart.value == 0) {
			// Only set if not already won leg.
			document.form2.away_darts_count.value = document.form2.darts_used.value;
			document.form2.adc.value = document.form2.darts_used.value;
			}
		}
	else {
		// Their first throw and theirr result - set their column
		document.form2.away_darts_count.value = document.form2.darts_used.value;
		document.form2.adc.value = document.form2.darts_used.value;
		}
	}
// Re-do the count down for this player
var score_left;
score_left = finish;
for (i = 0; i <= last_row; i++) {
	if (id == 1) {
		// our score
		score_left -= document.form2.our_throw[i].value;
		document.form2.our_rem[i].value = score_left;
		}
	else {
		// their score
		score_left -= document.form2.opp_throw[i].value;
		document.form2.their_rem[i].value = score_left;
		}
	}
for (i = last_row+1; i < document.form2.darts_grid.value; i++) {
	if (id == 1) {
		// our score
		document.form2.our_rem[i].value = '';
		}
	else {
		// their score
		document.form2.their_rem[i].value = '';
		}
	}

}

function updateTotalDarts(dart_p, finish) {
// Updates our total darts 					
var dart_i, last_row;
dart_i= ScoreToInt(dart_p);
if (document.form2.our_score.value == finish && (dart_i < 1 || dart_i > 3)) {
	alert('Out dart input not valid. Please enter 1, 2, or 3.');
	document.form2.our_out_dart.value = '';
	}
else if (document.form2.our_score.value != finish && (dart_p != null && dart_p.length != 0)) {
	alert('Out dart input not valid as our player has not won.');
	document.form2.our_out_dart.value = '';
	}
else {
	document.form2.our_darts_count.value = ScoreToInt(document.form2.darts_used.value) + dart_i - 3;
	document.form2.odc.value = document.form2.our_darts_count.value;
	}
}

function updateLeagueDarts(dart_p, finish, person) {
// Updates our total darts 					
var dart_i, last_row;
dart_i= ScoreToInt(dart_p);
if (person == 1) { // Player(s) A
	if (document.form2.our_score.value == finish && (dart_i < 1 || dart_i > 3)) {
		alert('Out dart input not valid. Please enter 1, 2, or 3.');
		document.form2.home_out_dart.value = '';
		}
	else if (document.form2.our_score.value != finish && (dart_p != null && dart_p.length != 0)) {
		alert('Out dart input not valid as Player(s) A has not won.');
		document.form2.home_out_dart.value = '';
		}
	else {
		document.form2.home_darts_count.value = ScoreToInt(document.form2.darts_used.value) + dart_i - 3;
		document.form2.odc.value = document.form2.home_darts_count.value;
		}
	}
else {
	if (document.form2.opponent_score.value == finish && (dart_i < 1 || dart_i > 3)) {
		alert('Out dart input not valid. Please enter 1, 2, or 3.');
		document.form2.away_out_dart.value = '';
		}
	else if (document.form2.opponent_score.value != finish && (dart_p != null && dart_p.length != 0)) {
		alert('Out dart input not valid as Player(s) B has not won.');
		document.form2.away_out_dart.value = '';
		}
	else {
		document.form2.away_darts_count.value = ScoreToInt(document.form2.darts_used.value) + dart_i - 3;
		document.form2.adc.value = document.form2.away_darts_count.value;
		}
	}
}


function updateDartFinish(value) {
	// Not used??
	document.form2.dart_finish.value = value;
	}

					   
					   function updateLines(callid,id,darts){
			
						   if(callid==0){
						   window.open("scorecard-update.php?ID="+id+"&darts="+darts, "_self");
						   } else {
							   window.open("scorecard-update.php?ID1="+id+"&darts="+darts, "_self"); 
						   }
					   }
					   
					   
					   function changeSeason(id,url,id1){

						   if(id1 > 0){
						   window.open(url+'?ID2='+id+'&ID1='+id1+'&ID='+id1, "_self");
					   } else {
					    window.open(url+'?ID2='+id, "_self");
					   }
					   }
					   
					   function changeFDate(d1,url,id1,id,d2){

						window.open(url+'?ID2='+id+'&S='+d1+'&E='+d2+'&ID='+id1, "_self");
					   }
					   
					   function changeTopx(c,url,id1,id){

						window.open(url+'?ID2='+id+'&ID='+id1+'&T='+c, "_self");
					   }
					   
					     function changeSeason2(id,id1,id2,url){

						   if(id1 > 0){
						   window.open(url+'?ID='+id+'&ID1='+id1+'&ID2='+id2, "_self");
						   }
					   }
					   
					   
					      function changeDivision(id,id2,id3,url){

						   window.open(url+'?ID='+id+'&ID2='+id2+'&ID3='+id3, "_self");
					
					   }
					   
					   function setLeague(id,id1){
						if(id==0){
							 
							   document.form1.competition_name.disabled = false;
							   document.form1.competition_name.value = "";
							      document.form1.ID.value = 0;
								   document.form1.ID1.value = 0;
							   document.form1.county_id.disabled = false;
							   document.form1.county_id.value = "";
							   document.form1.competition_postcode.disabled = false;
							   document.form1.competition_postcode.value = "";
							    document.form1.division_name.disabled = false;
							   document.form1.form1.division_name.value = "";
						   } else {
						window.open('team-signup-3.php?ID='+id+'&ID1='+id1, '_self');
						    //alert('set league');
					   }
					   }
					   

function setLeague2(id,url){
if (id==0){
	window.open(url, '_self');
	}
else {
	window.open(url+'?ID='+id, '_self');
	}
}
					   
function setLeague3(id,url){
if (id>0){
	window.open(url+'?submitted=1&ID='+id, '_self');
	}
}
				

function toggleLeague(id,name){
if (id==1){
	document.form1.comp_name.value = name;
	document.form1.comp_name.readOnly = true;
	} 
else {
	document.form1.comp_name.value = "";
	document.form1.comp_name.readOnly = false;
	document.form1.comp_name.focus();
	}
}
	

function rulesnewlines(newrows){
	if (arguments.length == 2) {
	url = 'league-rules-update.php?moregrid='+newrows;
	}
	else {
	url = 'rules-update.php?moregrid='+newrows;
	}
	document.form1.action=url;
	document.form1.submit();
}


function submitgameleg(darts){
	if (arguments.length == 2) {
	url = 'set-leg-update.php?darts='+darts;
	}
	else {
	url = 'game-leg-update.php?darts='+darts;
	}
	document.form2.action=url;
	document.form2.submit();
}

function submitlegleg(darts){
	url = 'leg-update.php?darts='+darts;
	document.form2.action=url;
	document.form2.submit();
}

function submitleagueleg(darts){
	url = 'league-leg-update.php?darts='+darts;
	document.form2.action=url;
	document.form2.submit();
}

function validateForm(final_score){
	if (typeof final_score != "number"){
		final_score = 501;
		}
	if (final_score > -101) {
		// leg-update has no name objects so skip these checks
		if (document.form2.opponent_names.value =='') {
			alert ('Please enter an opponent');
			return false;
			}
		if (document.form2.our_names.value == '' && document.form2.player_id.value == 0) {
			alert ('Please enter our player(s)');
			return false;
			}
		}
	if (final_score == -2) {
		return true;
		}
	if (final_score == -1 && document.form2.winner.value == 0) {
		alert ('In multi-leg games, please say which player won.');
		return false;
		}
	if (final_score == -1) {
		return true;
		}
	if (document.form2.our_score.value == 0 && document.form2.opponent_score.value == 0 && final_score < 0) {
		// multi-leg game passed as negative
		alert ('No scores entered. Please say which player won.');
		return false;
		}
	else if (document.form2.our_score.value == 0 && document.form2.opponent_score.value == 0 && document.form2.winner.value == 0) {
		alert ('You must either enter scores, or if a one-leg game, say which player(s) won.');
		return false;
		}
	if (final_score == 0) {
		// format is other
		return true;
		}
	if (final_score > 0 && document.form2.our_score.value == 0 && document.form2.opponent_score.value == 0 && document.form2.winner.value != 0) {
		// from game-leg-update and winner set and no scores entered - it's valid.
		// If from leg-update final_score is still negative
		return true;
		}
	if (final_score < 0) {
		// its a leg of a multi-leg game - passed as negative
		final_score = 0 - final_score;
		}
	if (document.form2.our_score.value > final_score || document.form2.opponent_score.value > final_score) {
		alert ('Final score not valid - it is higher than the finish.');
		return false;
		}
	if (document.form2.our_score.value == final_score && document.form2.opponent_score.value == final_score) {
		alert ('Final score not valid - both players have reached the finish.');
		return false;
		}
	if ((document.form2.our_score.value > 0 || document.form2.opponent_score.value > 0) && document.form2.our_score.value < final_score && document.form2.opponent_score.value < final_score) {
		alert (final_score + ' not reached. Please complete scoresheet.');
		return false;
		}
	if (document.form2.our_score.value == final_score && document.form2.our_out_dart.value < 1) {
		alert ('You must enter a finish dart.');
		return false;
		}
	var last_row, ourscore, theirscore;
	last_row = document.form2.darts_used.value / 3 - 1;
	ourscore = ScoreToInt(document.form2.our_score.value)
	theirscore = ScoreToInt(document.form2.opponent_score.value)
	if (ourscore > theirscore && document.form2.our_throw[last_row].value == 0) {
		alert ('The opponent has thrown after our player has finished.');
		return false;
		}
	if (ourscore < theirscore && document.form2.opp_throw[last_row].value == 0) {
		alert ('Our player has thrown after the opponent has finished.');
		return false;
		}
	if (ourscore < theirscore) {
		// Player B won - check last dart for Player A has been entered
		if (document.form2.first_dart.value == 0 && document.form2.our_throw[last_row].value == '') {
			// Winner threw second - Current row should have a value in
			alert ('No last throw has been entered for our player.');
			return false;
			}
		if (document.form2.first_dart.value == 1 && document.form2.our_throw[last_row - 1].value == '') {
			// Winner threw first - Previous row should have a value in
			alert ('No last throw has been entered for our player.');
			return false;
			}
		}
	else {
		// Player A won - check last dart for Player B has been entered
		if (document.form2.first_dart.value == 0 && document.form2.opp_throw[last_row - 1].value == '') {
			// Winner threw first - Previous row should have a value in
			alert ('No last throw has been entered for the opposing player(s).');
			return false;
			}
		if (document.form2.first_dart.value == 1 && document.form2.opp_throw[last_row].value == '') {
			// Winner threw second - Current row should have a value in
			alert ('No last throw has been entered for the opposing player(s).');
			return false;
			}
		}
	if (document.form2.first_dart.value == 0 && document.form2.opp_throw[last_row].value != '' && ourscore > theirscore) {
		alert ('Last throw should not have been entered for the opponent.');
		return false;
		}
	if (document.form2.first_dart.value == 1 && document.form2.our_throw[last_row].value != '' && ourscore < theirscore) {
		alert ('Last throw should not have been entered for our player.');
		return false;
		}
	dart_i= ScoreToInt(document.form2.our_out_dart.value);
	if (document.form2.our_score.value == final_score && (dart_i < 1 || dart_i > 3)) {	
		// Need to check these here as otherwise you can save the form by clicking Submit with an illegal value in these fields
		alert('Out dart input not valid. Please enter 1, 2, or 3.');
		return false;
		}
	else if (document.form2.our_score.value != final_score && document.form2.our_out_dart.value != 0) {
		alert('Out dart input not valid as our player has not won.');
		return false;
		}

//  validation on box should make this unnecessady
//	if (document.form2.player_nodart.value > 0 && document.form2.player_nodart.value > 3) {
//		alert ('The finish dart must be 1, 2, or 3');
//		return false;
//	}
}

function validateLgForm(final_score){
	if (typeof final_score != "number"){
		final_score = 501;
		}
	if (final_score == -2) {
		return true;
		}
	if (final_score == -1 && document.form2.winner.value == 0) {
		alert ('In multi-leg games, please say which player won.');
		return false;
		}
	if (final_score == -1) {
		return true;
		}
	if (document.form2.our_score.value == 0 && document.form2.opponent_score.value == 0 && final_score < 0) {
		// multi-leg game passed as negative
		alert ('No scores entered. Please say which player won.');
		return false;
		}
	else if (document.form2.our_score.value == 0 && document.form2.opponent_score.value == 0 && document.form2.winner.value == 0) {
		alert ('You must either enter scores, or if a one-leg game, say which player(s) won.');
		return false;
		}
	if (final_score == 0) {
		// format is other
		return true;
		}
	if (final_score < 0) {
		// its a leg of a multi-leg game - passed as negative
		final_score = 0 - final_score;
		}
	if (document.form2.our_score.value > final_score || document.form2.opponent_score.value > final_score) {
		alert ('Final score not valid - it is higher than the finish.');
		return false;
		}
	if (document.form2.our_score.value == final_score && document.form2.opponent_score.value == final_score) {
		alert ('Final score not valid - both players have reached the finish.');
		return false;
		}
	if ((document.form2.our_score.value > 0 || document.form2.opponent_score.value > 0) && document.form2.our_score.value < final_score && document.form2.opponent_score.value < final_score) {
		alert (final_score + ' not reached. Please complete scoresheet.');
		return false;
		}
	if (document.form2.our_score.value == final_score && document.form2.home_out_dart.value < 1) {
		alert ('You must enter a finish dart for Player(s) A.');
		return false;
		}
	if (document.form2.opponent_score.value == final_score && document.form2.away_out_dart.value < 1) {
		alert ('You must enter a finish dart for Player(s) B.');
		return false;
		}
	if (document.form2.home_out_dart.value > 0 && document.form2.away_out_dart.value > 0) {
		alert ('You have entered a finish dart for both players.');
		return false;
		}
	var last_row, ourscore, theirscore;
	last_row = document.form2.darts_used.value / 3 - 1;
	ourscore = ScoreToInt(document.form2.our_score.value)
	theirscore = ScoreToInt(document.form2.opponent_score.value)
	if (ourscore > theirscore && document.form2.our_throw[last_row].value == 0) {
		alert ('Player(s) B has thrown after Player(s) A has finished.');
		return false;
		}
	if (ourscore < theirscore && document.form2.opp_throw[last_row].value == 0) {
		alert ('Player(s) A has thrown after Player(s) B has finished.');
		return false;
		}
	if (ourscore < theirscore) {
		// Player B won - check last dart for Player A has been entered
		if (document.form2.first_dart.value == 0 && document.form2.our_throw[last_row].value == '') {
			// Winner threw second - Current row should have a value in
			alert ('No last throw has been entered for Player(s) A.');
			return false;
			}
		if (document.form2.first_dart.value == 1 && document.form2.our_throw[last_row - 1].value == '') {
			// Winner threw first - Previous row should have a value in
			alert ('No last throw has been entered for Player(s) A.');
			return false;
			}
		}
	else {
		// Player A won - check last dart for Player B has been entered
		if (document.form2.first_dart.value == 0 && document.form2.opp_throw[last_row - 1].value == '') {
			// Winner threw first - Previous row should have a value in
			alert ('No last throw has been entered for Player(s) A.');
			return false;
			}
		if (document.form2.first_dart.value == 1 && document.form2.opp_throw[last_row].value == '') {
			// Winner threw second - Current row should have a value in
			alert ('No last throw has been entered for Player(s) B.');
			return false;
			}
		}
	if (document.form2.first_dart.value == 0 && document.form2.opp_throw[last_row].value != '' && ourscore > theirscore) {
		alert ('Last throw should not have been entered for Player(s) B.');
		return false;
		}
	if (document.form2.first_dart.value == 1 && document.form2.our_throw[last_row].value != '' && ourscore < theirscore) {
		alert ('Last throw should not have been entered for Player(s) A.');
		return false;
		}
	dart_i= ScoreToInt(document.form2.home_out_dart.value);
	if (document.form2.our_score.value == final_score && (dart_i < 1 || dart_i > 3)) {	
		// Need to check these here as otherwise you can save the form by clicking Submit with an illegal value in these fields
		alert('Player(s) A out dart input not valid. Please enter 1, 2, or 3.');
		return false;
		}
	else if (document.form2.our_score.value != final_score && document.form2.home_out_dart.value != 0) {
		alert('Out dart input not valid as Player(s) A has not won.');
		return false;
		}
	dart_i= ScoreToInt(document.form2.away_out_dart.value);
	if (document.form2.opponent_score.value == final_score && (dart_i < 1 || dart_i > 3)) {	
		// Need to check these here as otherwise you can save the form by clicking Submit with an illegal value in these fields
		alert('Player(s) B out dart input not valid. Please enter 1, 2, or 3.');
		return false;
		}
	else if (document.form2.opponent_score.value != final_score && document.form2.away_out_dart.value != 0) {
		alert('Out dart input not valid as Player(s) B has not won.');
		return false;
		}

//  validation on box should make this unnecessady
//	if (document.form2.player_nodart.value > 0 && document.form2.player_nodart.value > 3) {
//		alert ('The finish dart must be 1, 2, or 3');
//		return false;
//	}
}

function DelConfirm(id, typeid){
	if (id==0) return;
	url = 'confirm-delete.php?ID='+id+'&T='+typeid;
	document.form1.action=url;
	document.form1.submit();
}

function GameRuleChange(rulesid){
	url = 'fixture-update.php?submitted=1&rulesid='+rulesid;
	document.form1.action=url;
	document.form1.submit();
}

function updateGames(id,rulesid){
	//alert(rulesid);
	window.open('fixture-update.php?ID='+id+'&rulesid='+rulesid,'_self');
	}

function SetArrTick(id, arrlen) {
// IMPORTANT - If there is only one tick-box, we are not really dealing with an array
// Strangely, this doesn't seem to matter with the other elements, only the tick-box
if (arrlen == 1) {
	if (document.form1.xpicked.checked) { 
		document.form1.picked.value = 1; 
		}
	else {
		document.form1.picked.value = 0;
	}
	}
else {
	if (document.form1.xpicked[id].checked) { 
		document.form1.picked[id].value = 1; 
		}
	else {
		document.form1.picked[id].value = 0;
		}
	}
}

function lgprofilecountry(id) {
	url = 'league-profile.php?country='+id;
	document.team.action=url;
	document.team.submit();
}

function tmprofilecountry(id) {
	url = 'club-update.php?country='+id;
	document.team.action=url;
	document.team.submit();
}

function PopupResults(url, id) {
	if (id > 0) {
		window.open(url+'?ID='+id,'','scrollbars=yes,width=600,height=500');
		}
}