function addTeam(team) {
	if(team == 2) {
		$("#teambox2").show();
		$("#team2ContainerBOX").show();
		$("#teambox3option").show();
		changeTeam2($().val());
	} else if (team == 3) {
		$("#teambox3").show();
		$("#team3ContainerBOX").show();
	}
	changePrice();
}


function changePrice() {
	var price;
	var price = parseInt($("#TeamPrice1").val())+parseInt($("#TeamPrice2").val())+parseInt($("#TeamPrice3").val());
	$("#priceContainer2").text(parseInt($("#prepaid").val()*425));
	$("#priceContainer").text(price);
	$("#amount").attr("value", price+parseInt($("#prepaid").val()*425));
	//console.log("teamprice1: " +$("#TeamPrice1").val()+ ", teamprice2: " +$("#TeamPrice2").val()+ ", teamprice3: " +$("#TeamPrice3").val() + "prepaid: " +$("#prepaid").val() + "totalamount: "+$("#amount").val()+ ", actual amount: "+price+parseInt($("#prepaid").val()*425)); 

}


function horsePrice() {
	var price;
	var price = parseInt($("#TeamPrice2").val())+parseInt($("#TeamPrice3").val());
	$("#priceContainer2").text("0");
	$("#priceContainer").text(price+parseInt($("#prepaid").val()*425));
	$("#amount").attr("value", price+parseInt($("#prepaid").val()*425));
	//console.log("teamprice2: " +$("#TeamPrice2").val()+ ", teamprice3: " +$("#TeamPrice3").val() + "prepaid: " +$("#prepaid").val() + "totalamount: "+$("#amount").val()+ ", actual amount: "+price+parseInt($("#prepaid").val()*425)); 

}




function changeTeam1(team) {
//used by the pay player fee form. moved to file to make it easier to manage
var playerFee = new Array();
var playerPrice = new Array();
//playerFee[sport][html][defaultprice];

playerFee['badminton'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['badminton'] += "<option selected='selected' value='300'>Monday</option>";
playerFee['badminton'] += "<option value='500'>Friday</option>";
playerFee['badminton'] += "<option value='700'>Monday and friday</option>";
playerFee['badminton'] += "</select>";
playerPrice['badminton'] = 300;

playerFee['basket'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['basket'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['basket'] += "<option value='400'>2. team men</option>";
playerFee['basket'] += "<option value='400'>3. team men</option>";
playerFee['basket'] += "<option value='250'>Practice only - no matches</option>";
playerFee['basket'] += "<option value='400'>1. team women</option>";
playerFee['basket'] += "<option value='400'>2. team women</option>";
playerFee['basket'] += "</select>";
playerPrice['basket'] = 400;

playerFee['cricket'] = "<input type='hidden' name='teamdate1' id='teamdate1' value='400' />-";
playerPrice['cricket'] = 400;

playerFee['passive'] = "<input type='hidden' name='teamdate1' id='teamdate1' value='50' />-";
playerPrice['passive'] = 50;

playerFee['floorball'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['floorball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['floorball'] += "<option value='250'>1. team women</option>";
playerFee['floorball'] += "</select>";
playerPrice['floorball'] = 500;

playerFee['football'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['football'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['football'] += "<option value='400'>2. team men</option>";
playerFee['football'] += "<option value='250'>Practice only - no matches</option>";
playerFee['football'] += "<option value='400'>1. team women</option>";
playerFee['football'] += "</select>";
playerPrice['football'] = 400;

playerFee['handball'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['handball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['handball'] += "<option value='500'>2. team men</option>";
playerFee['handball'] += "<option value='450'>1. team women</option>";
playerFee['handball'] += "<option value='450'>2. team women</option>";
playerFee['handball'] += "</select>";
playerPrice['handball'] = 500;

playerFee['riding'] = "<input type='hidden' name='teamdate1' id='teamdate1' value='550' />-";
playerPrice['riding'] = 550;

playerFee['rugby'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['rugby'] += "<option selected='selected' value='250'>1. team men</option>";
playerFee['rugby'] += "<option value='250'>1. team women</option>";
playerFee['rugby'] += "</select>";
playerPrice['rugby'] = 250;

playerFee['volleyball'] = "<input type='hidden' name='teamdate1' id='teamdate1' value='250' />-";
playerPrice['volleyball'] = 250;

playerFee['tennis'] = "<select class='formselect' id='teamdate1' name='teamdate1' onchange='$(\"#TeamPrice1\").val(this.options[this.selectedIndex].value); $(\"#TeamDay1\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['tennis'] += "<option selected='selected' value='900'>Single</option>";
playerFee['tennis'] += "<option value='490'>Double</option>";
playerFee['tennis'] += "</select>";
playerPrice['tennis'] = 900;

playerFee['none'] = "<input type='hidden' name='teamdate1' id='teamdate1' value='0' />-";
playerPrice['none'] = 0;

	$('#TeamPrice1').val(playerPrice[team]);
	$('#TeamDay1').val($('#teamdate1 :selected').text());
	$('#TeamName1').val(team);
	$('#teamContainer').html(playerFee[team]);	

	if (team == 'riding') {
		if($("#horse_fee").is(":checked")) {
			document.getElementById("priceContainerPlus").style.display = 'inline';
			changePrice();
		} else {
			document.getElementById("priceContainerPlus").style.display = 'none';
			horsePrice();
		}
		$(".specialMonths").show();
		$("#months").show();
		
	} else {
		document.getElementById("priceContainerPlus").style.display = 'none';
		$(".specialMonths").hide();
		$("#months").hide();
		$("#prepaid").val("0");
		changePrice();
	}
}

function changeTeam2(team) {
//used by the pay player fee form. moved to file to make it easier to manage
var playerFee = new Array();
var playerPrice = new Array();
//playerFee[sport][html][defaultprice];

playerFee['badminton'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['badminton'] += "<option selected='selected' value='300'>Monday</option>";
playerFee['badminton'] += "<option value='500'>Friday</option>";
playerFee['badminton'] += "<option value='700'>Monday and friday</option>";
playerFee['badminton'] += "</select>";
playerPrice['badminton'] = 300;

playerFee['basket'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['basket'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['basket'] += "<option value='400'>2. team men</option>";
playerFee['basket'] += "<option value='400'>3. team men</option>";
playerFee['basket'] += "<option value='250'>Practice only - no matches</option>";
playerFee['basket'] += "<option value='400'>1. team women</option>";
playerFee['basket'] += "<option value='400'>2. team women</option>";
playerFee['basket'] += "</select>";
playerPrice['basket'] = 400;

playerFee['cricket'] = "<input type='hidden' name='teamdate2' id='teamdate2' value='400' />-";
playerPrice['cricket'] = 400;

playerFee['floorball'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['floorball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['floorball'] += "<option value='250'>1. team women</option>";
playerFee['floorball'] += "</select>";
playerPrice['floorball'] = 500;

playerFee['football'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['football'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['football'] += "<option value='400'>2. team men</option>";
playerFee['football'] += "<option value='250'>Practice only - no matches</option>";
playerFee['football'] += "<option value='400'>1. team women</option>";
playerFee['football'] += "</select>";
playerPrice['football'] = 400;

playerFee['handball'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['handball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['handball'] += "<option value='500'>2. team men</option>";
playerFee['handball'] += "<option value='450'>1. team women</option>";
playerFee['handball'] += "<option value='450'>2. team women</option>";
playerFee['handball'] += "</select>";
playerPrice['handball'] = 500;

playerFee['rugby'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['rugby'] += "<option selected='selected' value='250'>1. team men</option>";
playerFee['rugby'] += "<option value='250'>1. team women</option>";
playerFee['rugby'] += "</select>";
playerPrice['rugby'] = 250;

playerFee['volleyball'] = "<input type='hidden' name='teamdate2' id='teamdate2' value='250' />-";
playerPrice['volleyball'] = 250;

playerFee['tennis'] = "<select class='formselect' id='teamdate2' name='teamdate2' onchange='$(\"#TeamPrice2\").val(this.options[this.selectedIndex].value); $(\"#TeamDay2\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['tennis'] += "<option selected='selected' value='900'>Single</option>";
playerFee['tennis'] += "<option value='490'>Double</option>";
playerFee['tennis'] += "</select>";
playerPrice['tennis'] = 900;

playerFee['none'] = "<input type='hidden' name='teamdate2' id='teamdate2' value='0' />-";
playerPrice['none'] = 0;

	$('#teamContainer2').html(playerFee[team]);
	$('#TeamPrice2').val(playerPrice[team]);
	$('#TeamPrice2').val($('#teamdate2').val());
	$('#TeamDay2').val($('#teamdate2 :selected').text());
	$('#TeamName2').val(team);
	changePrice();
}

function changeTeam3(team) {
//used by the pay player fee form. moved to file to make it easier to manage
var playerFee = new Array();
var playerPrice = new Array();
//playerFee[sport][html][defaultprice];

playerFee['badminton'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['badminton'] += "<option selected='selected' value='300'>Monday</option>";
playerFee['badminton'] += "<option value='500'>Friday</option>";
playerFee['badminton'] += "<option value='700'>Monday and friday</option>";
playerFee['badminton'] += "</select>";
playerPrice['badminton'] = 300;

playerFee['basket'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['basket'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['basket'] += "<option value='400'>2. team men</option>";
playerFee['basket'] += "<option value='400'>3. team men</option>";
playerFee['basket'] += "<option value='250'>Practice only - no matches</option>";
playerFee['basket'] += "<option value='400'>1. team women</option>";
playerFee['basket'] += "<option value='400'>2. team women</option>";
playerFee['basket'] += "</select>";
playerPrice['basket'] = 400;

playerFee['cricket'] = "<input type='hidden' name='teamdate3' id='teamdate3' value='400' />-";
playerPrice['cricket'] = 400;

playerFee['floorball'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['floorball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['floorball'] += "<option value='250'>1. team women</option>";
playerFee['floorball'] += "</select>";
playerPrice['floorball'] = 500;

playerFee['football'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['football'] += "<option selected='selected' value='400'>1. team men</option>";
playerFee['football'] += "<option value='400'>2. team men</option>";
playerFee['football'] += "<option value='250'>Practice only - no matches</option>";
playerFee['football'] += "<option value='400'>1. team women</option>";
playerFee['football'] += "</select>";
playerPrice['football'] = 400;

playerFee['handball'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['handball'] += "<option selected='selected' value='500'>1. team men</option>";
playerFee['handball'] += "<option value='500'>2. team men</option>";
playerFee['handball'] += "<option value='450'>1. team women</option>";
playerFee['handball'] += "<option value='450'>2. team women</option>";
playerFee['handball'] += "</select>";
playerPrice['handball'] = 500;

playerFee['rugby'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['rugby'] += "<option selected='selected' value='250'>1. team men</option>";
playerFee['rugby'] += "<option value='250'>1. team women</option>";
playerFee['rugby'] += "</select>";
playerPrice['rugby'] = 250;

playerFee['volleyball'] = "<input type='hidden' name='teamdate3' id='teamdate3' value='250' />-";
playerPrice['volleyball'] = 250;

playerFee['tennis'] = "<select class='formselect' id='teamdate3' name='teamdate3' onchange='$(\"#TeamPrice3\").val(this.options[this.selectedIndex].value); $(\"#TeamDay3\").val(this.options[this.selectedIndex].text);changePrice();'>";
playerFee['tennis'] += "<option selected='selected' value='900'>Single</option>";
playerFee['tennis'] += "<option value='490'>Double</option>";
playerFee['tennis'] += "</select>";
playerPrice['tennis'] = 900;

playerFee['none'] = "<input type='hidden' name='teamdate3' id='teamdate3' value='0' />-";
playerPrice['none'] = 0;

	$('#teamContainer3').html(playerFee[team]);
	$('#TeamPrice3').val(playerPrice[team]);
	$('#TeamPrice3').val($('#teamdate3').val());
	$('#TeamDay3').val($('#teamdate3 :selected').text());
	$('#TeamName3').val(team);
	changePrice();
}