//<script>
runnerTotal=fieldsize;

//********** Dave Chan 25/06/2007
//Function to disable the bet options "box, flexi, RB".  It depends on the value selected on the Bet Type DDL.
//This function will run every 0.2 second
function checkDisableCbs()
{
	//alert("checkDisable");
	//Get the value from Bet Type DDL
	var betType = document.getElementById('betType');
	
	var selectedValue = betType.options[betType.selectedIndex].value;
    
	var chkFlexi = document.getElementById('chkFlexi');
	var chkBox = document.getElementById('chkBox');
	var chkRovingBanker = document.getElementById('chkRovingBanker');
	var spanFlexiText = document.getElementById('spanflexiText');
	var flexiText = document.getElementById('flexiText');
	var flexiMessage = document.getElementById('flexiMessage');
	//var divflexitext = document.getElementById('divflexiText');
	var Flexidiv = document.getElementById('Flexidiv');
	var Boxdiv = document.getElementById('Boxdiv');
	var RovingBankerdiv = document.getElementById('RovingBankerdiv');
	
	//alert(spanFlexiText);
	if ( (selectedValue == "win") || (selectedValue == "pla") || (selectedValue == "e-w") ) // WIN, PLA, E-W
	{
		if(chkFlexi) chkFlexi.disabled = true;
		if(Flexidiv) Flexidiv.style.display = "none";
		
		if(chkBox) chkBox.disabled = true;
		if(Boxdiv) Boxdiv.style.display = "none";
		
		if(chkRovingBanker) chkRovingBanker.disabled = true;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
		
		//if(flexiText) flexiText.style.display='none';
		//if(spanFlexiText) spanFlexiText.style.display = 'none';
		
	}
	else if (selectedValue == "qin" || selectedValue == "qinB" || selectedValue == "qinR" || selectedValue == "qinS")
	{
		if(selectedValue == "qinS")
		{
			if(chkFlexi) chkFlexi.disabled = true;
			if(Flexidiv) Flexidiv.style.display = "none";
			
			if(chkBox) chkBox.disabled = true;
			if(Boxdiv) Boxdiv.style.display = "none";
			
			if(chkRovingBanker) chkRovingBanker.disabled = true;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
		}
		else
		{
			if(chkFlexi) chkFlexi.disabled = true;
			if(Flexidiv) Flexidiv.style.display = "none";
			
			if(chkBox) chkBox.disabled = true;
			if(Boxdiv) Boxdiv.style.display = "none";
			
			if(chkRovingBanker) chkRovingBanker.disabled = false;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "";
		}	
	}
	else if (selectedValue == "exa" || selectedValue == "exaB" || selectedValue == "exaR" || selectedValue == "exaS" )
	{
		if (selectedValue == "exaS")
		{
			if(chkFlexi) chkFlexi.disabled = true;
			if(Flexidiv) Flexidiv.style.display = "none";
			
			if(chkBox) chkBox.disabled = true;
			if(Boxdiv) Boxdiv.style.display = "none";
			
			if(chkRovingBanker) chkRovingBanker.disabled = true;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
	//		if(spanFlexiText) spanFlexiText.style.display = 'none';
		}
		else
		{
			if(chkFlexi) chkFlexi.disabled = true;
			if(Flexidiv) Flexidiv.style.display = "none";
			
			if(chkBox) chkBox.disabled = false;
			if(Boxdiv) Boxdiv.style.display = "";
			
			if(chkRovingBanker) chkRovingBanker.disabled = false;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "";
	//		if(spanFlexiText) spanFlexiText.style.display = 'none';
		}
	}
	else if (selectedValue == "tri" || selectedValue == "triB" || selectedValue == "triR" || selectedValue == "triS" || selectedValue == "triF")
	{
		if (selectedValue == "triS")
		{
			if(chkFlexi) chkFlexi.disabled = false;
			if(Flexidiv) Flexidiv.style.display = "";
			
			if(chkBox) chkBox.disabled = true;
			if(Boxdiv) Boxdiv.style.display = "none";
			
			if(chkRovingBanker) chkRovingBanker.disabled = true;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
	//		if(spanFlexiText) spanFlexiText.style.display = 'none';
		}
		else
		{
			if(chkFlexi) chkFlexi.disabled = false;
			if(Flexidiv) Flexidiv.style.display = "";
			
			if(chkBox) chkBox.disabled = false;
			if(Boxdiv) Boxdiv.style.display = "";
			
			if(chkRovingBanker) chkRovingBanker.disabled = false;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "";
	//		if(spanFlexiText) spanFlexiText.style.display = 'none';
		}
	}
	else if (selectedValue == "due" || selectedValue == "dueR")
	{
		if(chkFlexi) chkFlexi.disabled = true;
		if(Flexidiv) Flexidiv.style.display = "none";
		
		if(chkBox) chkBox.disabled = true;
		if(Boxdiv) Boxdiv.style.display = "none";
		
		if(chkRovingBanker) chkRovingBanker.disabled = false;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "";
	//	if(spanFlexiText) spanFlexiText.style.display = 'none';
		
	}
	else if (selectedValue == "d-d" || selectedValue == "r-d")
	{
		if(chkFlexi) chkFlexi.disabled = true;
		if(Flexidiv) Flexidiv.style.display = "none";
		
		if(chkBox) chkBox.disabled = true;
		if(Boxdiv) Boxdiv.style.display = "none";
		
		if(chkRovingBanker) chkRovingBanker.disabled = true;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
	//	if(spanFlexiText) spanFlexiText.style.display = 'none';

		var legTitle1 = document.getElementById('legTitle1');
		var legTitle2 = document.getElementById('legTitle2');
		var legTitle3 = document.getElementById('legTitle3');
		var legTitle4 = document.getElementById('legTitle4');
		if(legTitle1) legTitle1.style.display = '';
		if(legTitle2) legTitle2.style.display = '';
		if(legTitle3) legTitle3.style.display = '';
		if(legTitle4) legTitle4.style.display = '';
		
		var cb3 = document.getElementById('checkboxes3');
		var cb4 = document.getElementById('checkboxes4');
		if(cb3) cb3.style.display = 'none';
		if(cb4) cb4.style.display = 'none';
	}
	else if (selectedValue == "qad" || selectedValue == "qadF")
	{
		if(chkFlexi) chkFlexi.disabled = false;
		if(Flexidiv) Flexidiv.style.display = "";
		
		if(chkBox) chkBox.disabled = true;
		if(Boxdiv) Boxdiv.style.display = "none";
		
		if(chkRovingBanker) chkRovingBanker.disabled = true;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
	//	if(spanFlexiText) spanFlexiText.style.display = 'none';

		var legTitle1 = document.getElementById('legTitle1');
		var legTitle2 = document.getElementById('legTitle2');
		var legTitle3 = document.getElementById('legTitle3');
		var legTitle4 = document.getElementById('legTitle4');
		if(legTitle1) legTitle1.style.display = '';
		if(legTitle2) legTitle2.style.display = '';
		if(legTitle3) legTitle3.style.display = '';
		if(legTitle4) legTitle4.style.display = '';
	}
	else if (selectedValue == "BIG6")
	{
		if(chkFlexi) chkFlexi.disabled = false;
		if(Flexidiv) Flexidiv.style.display = "";
		
		if(chkBox) chkBox.disabled = true;
		if(Boxdiv) Boxdiv.style.display = "none";
		
		if(chkRovingBanker) chkRovingBanker.disabled = true;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
	//	if(spanFlexiText) spanFlexiText.style.display = 'none';

		var legTitle1 = document.getElementById('legTitle1');
		var legTitle2 = document.getElementById('legTitle2');
		var legTitle3 = document.getElementById('legTitle3');
		var legTitle4 = document.getElementById('legTitle4');
		var legTitle5 = document.getElementById('legTitle5');
		var legTitle6 = document.getElementById('legTitle6');
		if(legTitle1) legTitle1.style.display = '';
		if(legTitle2) legTitle2.style.display = 'none';
		if(legTitle3) legTitle3.style.display = 'none';
		if(legTitle4) legTitle4.style.display = 'none';
		if(legTitle5) legTitle5.style.display = 'none';
		if(legTitle6) legTitle6.style.display = 'none';
	}
	//added by ADI
	else if(selectedValue=="fst4F" || selectedValue=="fst4" || selectedValue=="fst4B" || selectedValue=="fst4S"){
		if(selectedValue=="fst4S")
		{
			if(chkFlexi) chkFlexi.disabled = false;
			if(Flexidiv) Flexidiv.style.display = "";
			
			if(chkBox) chkBox.disabled = true;
			if(Boxdiv) Boxdiv.style.display = "none";
			
			if(chkRovingBanker) chkRovingBanker.disabled = true;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "none";
			
			var checkboxes = document.getElementById('checkboxes3');
				if(checkboxes) checkboxes.disabled = true;
		}
		else
		{
			if(chkFlexi) chkFlexi.disabled = false;
			if(Flexidiv) Flexidiv.style.display = "";
			
			if(chkBox) chkBox.disabled = false;
			if(Boxdiv) Boxdiv.style.display = "";
			
			if(chkRovingBanker) chkRovingBanker.disabled = false;
			if(RovingBankerdiv) RovingBankerdiv.style.display = "";
		}
	}
	else
	{
		if(chkFlexi) chkFlexi.disabled = false;
		if(Flexidiv) Flexidiv.style.display = "";
		
		if(chkBox) chkBox.disabled = false;
		if(Boxdiv) Boxdiv.style.display = "";
		
		if(chkRovingBanker) chkRovingBanker.disabled = false;
		if(RovingBankerdiv) RovingBankerdiv.style.display = "";
	//	if(spanFlexiText) spanFlexiText.style.display = '';
	}

	//Refresh the page every 0.2 second
	//setTimeout("checkDisableCbs();",200);
	//alert("Comb2 is");alert(combinations2);
	//update the Bet Cost everytime
	//popBetVals();
}




function drawHeader() {
	for (i=1; i!=runnerTotal+1; i++) {
		document.write("<tr><td class=grid2 height=20><b><center>" + i + "</td></tr>");
	}
	document.write("<tr><td class=grid2  height=20><b><center>Field</td></tr>");
}

//************ Dave Chan 25/06/2007
//Added one more parameter to determain whether the checkbox generated should be disable.
function drawRunners(z, enable) {

	for (i=1; i!=runnerTotal+1; i++) {
		if (enable == 0)
		{
			document.write("<tr><td class=grid2><input type=checkbox disabled=true name=" + z + " value=" + i + " onClick='return 			clicked(this.name,this.value,this)'></td></tr>");
		}
		else
		{
			document.write("<tr><td class=grid2><input type=checkbox name=" + z + " value=" + i + " onClick='return 			clicked(this.name,this.value,this)'></td></tr>");
		}
		}
	

	
	//Render a "Field" check box at the end
	if(enable==0)
	{
		document.write("<tr><td class=grid2><input type=checkbox disabled=true name=" + z + " value=F onClick='return 				clicked(this.name,this.value,this)'></td></tr>");
	}
	else
	{
		document.write("<tr><td class=grid2><input type=checkbox name=" + z + " value=F onClick='return 				clicked(this.name,this.value,this)'></td></tr>");
	}
	
	//Disable the whole checkbox column
	/*if (enable == 0)
	{
		var checkboxes = document.getElementById('checkboxes' + z);
		if(checkboxes) checkboxes.disabled = true;
	}*/
	
}




function getFirst() {
	startElem=0;
	for (i=0; i!=document.bc.elements.length; i++) {
		if (document.bc.elements[i].type == "checkbox") { startElem=i; break }
	}
}

ml=0;
standout=0;
roving=0;

//*************** Dave Chan 25/06/2007
//Onclick function for bet option "Box".  It must work with the Bet Type
function chkBox_Click(objThis)
{
	var chkFlexi = document.getElementById('chkFlexi');
	bFlexiChecked = chkFlexi.checked;
	bChecked = objThis.checked;
	tmp = document.bc.betType.selectedIndex; 
	document.bc.reset(); 
	document.bc.betType.selectedIndex = tmp;
	objThis.checked = bChecked;
	chkFlexi.checked = bFlexiChecked;
	
	var selectedValue = document.bc.betType.options[document.bc.betType.selectedIndex].value;

	
	var chkBox = document.getElementById('chkBox');
	var chkRovingBanker = document.getElementById('chkRovingBanker');
	//var spanFlexiText = document.getElementById('flexiText');
	
	//Empty the other 2 options
	//if(chkFlexi) chkFlexi.checked = false;
	if(chkRovingBanker) chkRovingBanker.checked = false;
	
	//alert(selectedValue);
	
	if (selectedValue == "tri" || selectedValue == "triB" || selectedValue == "triR") // trifecta
	{
		//if it is checked then change the Bet Type value to "triB".  it will make sure that it uses the
		//trifecta "Box" calculation.
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "triB";
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			//if(checkboxes3) checkboxes3.disabled = true;
			disableCheckBoxes(2);
			disableCheckBoxes(3);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to trifecta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "tri";
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			//if(checkboxes3) checkboxes3.disabled = false;
			enableCheckBoxes(2);
			enableCheckBoxes(3);
			betClear()
		}
	}
	else if (selectedValue == "exa" || selectedValue == "exaB" || selectedValue == "exaR") // Exacta
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "exaB";
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			disableCheckBoxes(2);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "exa";
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			enableCheckBoxes(2);
			
			betClear()
		}
	}
	else if (selectedValue == "due" || selectedValue == "dueR") // Duet
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "due";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			disableCheckBoxes(2);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "due";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			enableCheckBoxes(2);
			
			betClear()
		}
	}
	else if (selectedValue == "qin" || selectedValue == "qinR") // Duet
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qin";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			disableCheckBoxes(2);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qin";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			disableCheckBoxes(2);
			
			betClear()
		}
	}
	else if(selectedValue=="fst4" || selectedValue=="fst4B" || selectedValue=="fst4F" || selectedValue=="fst4R")//added by ADI
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4B";
			
			disableCheckBoxes(2);
			disableCheckBoxes(3);
			disableCheckBoxes(4);
			betClear()
		}		
		else
		//if it is unchecked, make the bet type back to first4
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4";
			
			enableCheckBoxes(2);
			enableCheckBoxes(3);
			enableCheckBoxes(4);
			betClear()
		}	
	}
}

//*************** Dave Chan 25/06/2007
//Onclick function for bet option "Roving Banker".  It must work with the Bet Type
function chkRovingBanker_Click(objThis)
{
	var chkFlexi = document.getElementById('chkFlexi');
	bFlexiChecked = chkFlexi.checked;
	
	bChecked = objThis.checked;
	tmp = document.bc.betType.selectedIndex; 
	document.bc.reset(); 
	document.bc.betType.selectedIndex = tmp;
	objThis.checked = bChecked;
	
	chkFlexi.checked=bFlexiChecked;
	
	var selectedValue = document.bc.betType.options[document.bc.betType.selectedIndex].value;

	//var chkFlexi = document.getElementById('chkFlexi');
	var chkBox = document.getElementById('chkBox');
	var chkRovingBanker = document.getElementById('chkRovingBanker');
	//var spanFlexiText = document.getElementById('flexiText');
	
	//if(chkFlexi) chkFlexi.checked = false;
	if(chkBox) chkBox.checked = false;
	
	
	if (selectedValue == "tri" || selectedValue == "triR" || selectedValue == "triB") // trifecta
	{
		//if it is checked then change the Bet Type value to "triR".  it will make sure that it uses the
		//trifecta "Roving Banker" calculation.		
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "triR";
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			//if(checkboxes3) checkboxes3.disabled = true;
			enableCheckBoxes(2);
			disableCheckBoxes(3);
			
			betClear()
		}
		else
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "tri";
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes3) checkboxes3.disabled = false;
			enableCheckBoxes(3);
			
			betClear()
		}
	}
	else if (selectedValue == "qin" || selectedValue == "qinB" || selectedValue == "qinR") // Quinella
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qinR";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			//if(checkboxes3) checkboxes3.disabled = true;

			enableCheckBoxes(2);
			//disableCheckBoxes(3);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to quinella
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qin";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			//if(checkboxes3) checkboxes3.disabled = true;
			disableCheckBoxes(2);
			//disableCheckBoxes(3);
			
			betClear()
		}
	}
	else if (selectedValue == "tri" || selectedValue == "triR" || selectedValue == "triB") // trifecta
	{
		//if it is checked then change the Bet Type value to "triR".  it will make sure that it uses the
		//trifecta "Roving Banker" calculation.		
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "triR";
			//var checkboxes2 = document.getElementById('checkboxes2');
			//var checkboxes3 = document.getElementById('checkboxes3');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			//if(checkboxes3) checkboxes3.disabled = true;
			enableCheckBoxes(2);
			disableCheckBoxes(3);
			
			betClear()
		}
		else
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "tri";
			var checkboxes3 = document.getElementById('checkboxes3');
			
			if(checkboxes3) checkboxes3.disabled = false;
			enableCheckBoxes(3);
			
			betClear()
		}
	}
	else if (selectedValue == "due" || selectedValue == "dueR") // Duet
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "dueR";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = false;
			enableCheckBoxes(2);
			
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "due";
			
			//var checkboxes2 = document.getElementById('checkboxes2');
			
			//if(checkboxes2) checkboxes2.disabled = true;
			disableCheckBoxes(2);
			
			betClear()
		}
	}
	else if (selectedValue == "exa" || selectedValue == "exaB" || selectedValue == "exaR") // Exacta
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "exaR";
			enableCheckBoxes(2);
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "exa";
			
			betClear()
		}
	}
	else if(selectedValue=="fst4" || selectedValue=="fst4R" || selectedValue=="fst4F" || selectedValue=="fst4B" )
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4R";
			disableCheckBoxes(3);
			disableCheckBoxes(4);
			enableCheckBoxes(2);
			betClear()
		}
		else
		//if it is unchecked, make the bet type back to exacta
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4";
			enableCheckBoxes(3);
			enableCheckBoxes(4);
			enableCheckBoxes(2);
			betClear()
		}	
	}

	
}


//*************** Dave Chan 25/06/2007
//Onclick function for bet option "Flexi".  It must work with the Bet Type
function chkFlexi_Click(objThis)
{
	var selectedValue = document.bc.betType.options[document.bc.betType.selectedIndex].value;
	var chkFlexi = document.getElementById('chkFlexi');
	var divflexiText = document.getElementById('divflexiText');
	
	if(objThis.checked)
	{
		divflexiText.style.display = '';	
	}
	else
	{
		divflexiText.style.display = 'none';	
	}
	
	if (selectedValue == "tri" || selectedValue == "triB" || selectedValue == "triR" || selectedValue == "triF") // trifecta
	{
		
	}
	else if (selectedValue == "qad" || selectedValue == "qadF" || selectedValue == "BIG6") // Quaddie && BIG6
	{
		/*if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qadF";
			//betClear()
		}
		else
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "qad";
			//betClear()
		}*/
	}
	else if(selectedValue=="fst4" || selectedValue=="fst4F")
	{
		if (objThis.checked)
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4F";
			//divflexiText.style.display='';
			//betClear()
		}
		else
		{
			document.bc.betType.options[document.bc.betType.selectedIndex].value = "fst4";
			//divflexiText.style.display="none";
			//betClear()
		}
	}
	popBetVals();
}
/*
function writeBetOptionBoxes() {

bt = document.bc.betType.options[document.bc.betType.selectedIndex].value;	

alert("aaaaaaaaaaa    " + bt);

if ( (bt == "win") || (bt == "pla") || (bt == "e-w") ) { // WIN, PLA, E-W
document.write("<tr><td><input type=checkbox disabled name=chkFlexi value=1>Flexi</td></tr>");
document.write("<tr><td><input type=checkbox disabled name=chkBox value=1>Box</td></tr>");
document.write("<tr><td><input type=checkbox disabled name=chkRovingBanker value=1>Roving Banker</td></tr>");
document.bc.flexiText.style.display = "none";
}
else
{
alert("good");
document.write("<tr><td><input type=checkbox name=chkFlexi value=1>Flexi</td></tr>");
document.write("<tr><td><input type=checkbox name=chkBox value=1>Box</td></tr>");
document.write("<tr><td><input type=checkbox name=chkRovingBanker value=1>Roving Banker</td></tr>");

}

}
*/
//********* Dave Chan 25/06/2007
//onclick function for every check box on the left panel (horse number).
function clicked(na,va,ob) {
	t=0;
	combinations2=0;
	bt = document.bc.betType.options[document.bc.betType.selectedIndex].value;
	oneExacta=0; // used to allow only 1 exaS or exaR pos 1 selection
	twoTrifecta=0; // used to allow only 1 exaS or exaR pos 1 selection
	oneQuinella=0; // used to allow only 1 qinR pos 1 selection
	oneDuet=0; // used to allow only 1 dueR pos 1 selection
	
	oneFirst4=0;//added by ADI
	
	//Dave Chan 28/06/2007 - added qinR and dueR
	//if1
	//added fst4S by Adi 16/07/2007
	if ( (bt == "exaR") || (bt == "exaS") || (bt == "triR") || (bt == "triS") || (bt == "qinR") || (bt == "dueR") ||(bt == "fst4S") ||(bt == "fst4R")) {
		if(na == 1 && va == "F") // disable first runner field box
		//if(na == 1 && va == "F" && bt!="fst4S") // disable first runner field box except for FIRST4 STANDOUT added by ADI 18/07/2007
		{
			//if(bt=="fst4S")//added by ADI 18/07/2007 --> this condition is special for FIRST4S bcoz we dont want to change the original coding
		    // {
			//    for (i=0; i!=document.bc.elements.length; i++) 
			//	{
			//		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked == true) ) 
			//		{
			//			document.bc.elements[i].checked = false;//will untick the value that equal to LEGS1
			//		}
			//	}
		    //}
			ob.checked=false;
			return false;
		}
		
		
		for (i=0; i!=document.bc.elements.length; i++) {
			if ( (bt == "exaR") || (bt == "exaS")) { // allow only two 2 selections for exaR and exaS
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					oneExacta++;
					if (oneExacta == 2) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}

			if (bt == "triR") { // allow only 2 selections in LEGS1 for trifecta roving banker added on 19/07/2007
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					twoTrifecta++;
					if (twoTrifecta == 3) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
			
			if (bt == "triS") { // allow only 1 selections in LEGS1 for trifecta standout added on 19/07/2007
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					twoTrifecta++;
					if (twoTrifecta == 2) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
			
			if ( (bt == "fst4S") ) { // allow 1 selection only
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					oneFirst4++;
					if (oneFirst4 == 2) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
		
			if ( (bt == "fst4R") ) { // allow only 3 selections for first 4 roving banker
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					oneFirst4++;
					if (oneFirst4 == 4) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
			
			if ( (bt == "qinR") ) { // allow only 1 selections for qinR
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					oneQuinella++;
					if (oneQuinella == 2) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
			
			if ( (bt == "dueR") ) { // allow only 1 selections for  dueR
				if ( (document.bc.elements[i].name == 1) && (document.bc.elements[i].checked) ) {
					oneDuet++;
					if (oneDuet == 2) {
						ob.checked=false;
						return 1;
						break;
					}
				}
			}
		
			 // disallow same selections across positions for tri and exa (roving / standout)
			if ( (document.bc.elements[i].name != na) && (document.bc.elements[i].value == va) && (document.bc.elements[i].checked) ) {
				ob.checked=false;
				return 1; 
				break; 
			}
		}
	}

	
	//if2
	if ( (bt != "qin") && (bt != "due") && (fields[na]) && (va != "F") ) {
		//ob.checked = false;
		// also uncheck field checkbox
		for (i=0; i!=document.bc.elements.length; i++) {
			if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].value.indexOf("F") == 0) ) {
				document.bc.elements[i].checked = false;
			}
		}
	}//endif2


	//if3
	if ( (bt == "win") || (bt == "pla") || (bt == "e-w") ) { // WIN, PLA, E-W
		legs=1;
		if (na > legs) { ob.checked = false; return false }
		if (ob.checked) {
			if (va == "F") { fields[na] = true; checkCheckBoxes(true,na); combinations = runnerTotal; betString="" }
			else { combinations++; betString += va + "," }
		}
		else {
			if (va == "F") { fields[na] = false; checkCheckBoxes(false,na); combinations = 0; betString="" }
			else { combinations--; betString = betString.replace(va + ",","") }
		}
		combinations2 = combinations;
	}
	//elseif3
	else if ((bt == "qin") || (bt == "due")) { // QIN or Duet
		
		if (ob.checked) 
		{
			//if (va == "F") {checkCheckBoxes(true,na);  }
			//else {betString += va + ","  }
			checkCheckBoxesDec(true,na,va,1);
		}
		else 
		{
			//if (va == "F") {checkCheckBoxes(false,na); }
			//else {betString = betString.replace(va + ",","") }
			checkCheckBoxesDec(false,na,va,1);
		}
		
		sel1 = new Array(); sel1 = totals[1].split(",");
		calcDuetCombination(bt);
		combinations2=combinations;
		
	}
	//else3
	else {
		ml=0;
		if      (bt == "exa") { legs=2 }
		else if (bt == "exaB") { legs=1 }
		else if (bt == "exaS") { legs=2 }
		else if (bt == "exaR") { legs=2 }
		else if (bt == "tri") { legs=3 }
		else if (bt == "triB") { legs=1 }
		else if (bt == "triS") { legs=2 }
		else if (bt == "triR") { legs=2 }
		else if (bt == "qinR") { legs=2 }
		else if (bt == "dueR") { legs=2 }
		else if (bt == "d-d") { legs=2; ml=1 }
		else if (bt == "r-d") { legs=2; ml=1 }
		else if (bt == "qad") { legs=4; ml=1 }
		else if (bt == "fst4") { legs=4; }//by ADI
		else if (bt == "fst4F") { legs=4; }//by ADI
		else if (bt == "fst4B") { legs=1; }//by ADI
		else if (bt == "fst4S") { legs=2; }//by ADI
		else if (bt == "fst4R") { legs=2; }//by ADI
		else if (bt == "qinS") { legs=2; }//by ADI
		else if (bt == "BIG6") { legs=6; ; ml=1}//by ADI
		
		//if3.2
		if (na > legs) { 
			ob.checked = false; 
			//break;
			//return false; 
		}


		//if3.3 d-d and r-d
		if ( (bt != "tri") && (bt != "triB") && (bt != "triS") && (bt != "triR") && (bt != "exa") && (bt != "exaB") && (bt != "exaS") && (bt != "exaR") && (bt != "qinR") && (bt != "dueR") /*added by ADI*/&&(bt!="fst4")&&(bt!="fst4F")&&(bt!="fst4B") && (bt!="fst4S") && (bt!="fst4R")/*added by ADI*/ && (bt!="qinS")) {
			if (va == "F") { fields[na] = ob.checked; checkCheckBoxes(ob.checked,na) }

			totals=new Array(0,0,0,0,0,0,0);
			for (i=0; i!=document.bc.elements.length; i++) {
				if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].checked) && (document.bc.elements[i].name <= legs) && (document.bc.elements[i].value.indexOf("F") == -1) ) {
					totals[parseInt(document.bc.elements[i].name)]++;
				}
			}
		}



		//if3.4
		if (ml==0) { // EXA (or boxed), TRI (or boxed)
			if ( (bt == "exa") || (bt == "exaB") || (bt == "exaS") || (bt == "exaR") ) {
				// EXACTA

				if (bt == "exaB") { totals[2] = totals[1]; }
			
				tmp=0;
				
				if(bt=="exaB")
				{
					if (ob.checked) {
						checkCheckBoxesDec(true,na,va,1); combinations++; 
					}
					else {
						checkCheckBoxesDec(false,na,va,1); combinations--;
					}
				}
				else if(bt == "exa")
				{
					if (ob.checked) {
						if (va == "F") { fields[na] = true; checkCheckBoxes(true,na); combinations = 0 }
						else { combinations++; totals[na] += va + "," }
					}
					else {
						if (va == "F") { fields[na] = false; checkCheckBoxes(false,na); combinations = 0 }
						else { combinations--; RemoveFromArray(na,va); }
					}
				}
				else // exacta RB or exacta standout
				{
					if (ob.checked) {
						if (va == "F") { fields[na] = true; checkCheckBoxesStandout(true,na); combinations = 0 }
						else { combinations++; totals[na] += va + "," }
					}
					else {
						if (va == "F") { fields[na] = false; checkCheckBoxesStandout(false,na); combinations = 0 }
						else { combinations--; RemoveFromArray(na,va); }
					}
				}

				sel1 = new Array(); sel1 = totals[1].split(",");
				sel2 = new Array(); sel2 = totals[2].split(",");
				
				if (bt != "exaB")
				{
					calcCombinations(bt);
				}
				else 
				{
					calcExactaBoxCombination(bt);
				}
				if (bt == "exaR") {
					combinations = combinations;
				}


			}
			else if ( (bt == "tri") || (bt == "triB") || (bt == "triS") || (bt == "triR") ) {
				// TRIFECTA			
				tmp=0;
				
				if(bt == "triB")
				{
					if (ob.checked) {
						checkCheckBoxesDec(true,na,va,2); combinations++; 
					}
					else {
						checkCheckBoxesDec(false,na,va,2); combinations--;
					}
				}
				else if(bt == "tri")
				{
					if (ob.checked) {
						if (va == "F") { fields[na] = true; checkCheckBoxes(true,na); combinations = 0 }
						else { combinations++; totals[na] += va + "," }
					}
					else {
						if (va == "F") { fields[na] = false; checkCheckBoxes(false,na); combinations = 0 }
						else { combinations--; totals[na] = totals[na].replace(va + ",","") }
					}
				}
				
				//edited on 07 08 07
				else
				{
					if (ob.checked) {
						if (va == "F") { fields[na] = true; checkCheckBoxesRB(true,na); combinations = 0 }
						else { combinations++; totals[na] += va + "," }
					}
					else {
						if (va == "F") { fields[na] = false; checkCheckBoxesRB(false,na); combinations = 0 }
						else { combinations--; RemoveFromArray(na,va); }
					}
				}
				
				sel1 = new Array(); sel1 = totals[1].split(",");
				if (bt == "tri") {
					sel2 = new Array(); sel2 = totals[2].split(",");
					sel3 = new Array(); sel3 = totals[3].split(",");
					calcCombinations(bt);
				}
				else if (bt == "triB") {
					//trifecta box col2 and col3 equals col1
					//alert(totals[1]);alert(totals[2]);alert(totals[3]);
					//sel2 = new Array(); totals[2] = totals[1]; sel2 = totals[2].split(",");
					//sel3 = new Array(); totals[3] = totals[1]; sel3 = totals[3].split(",");
					//alert(totals[1]);alert(totals[2]);alert(totals[3]);
					//calcCombinations(bt);
					calcTrifectaBoxCombination(bt);
				}
				else if (bt == "triS") {
					if (sel1.length==3) {
						sel2 = new Array(); sel2 = totals[1].split(",");
						sel3 = new Array(); totals[3] = totals[2]; sel3 = totals[3].split(",");
						//alert(totals[1]);alert(totals[2]);alert(totals[3]);
						calcCombinations(bt);
					}
					else {
						sel2 = new Array(); sel2 = totals[2].split(",");
						sel3 = new Array(); totals[3] = totals[2]; sel3 = totals[3].split(",");
						calcCombinations(bt);
					}
				}
				else if (bt == "triR") {
					sel1 = new Array(); sel1 = totals[1].split(",");
					sel2 = new Array(); sel2 = totals[2].split(",");
					sel3 = new Array(); sel3 = totals[2].split(",");
					tmp1 = sel1; tmp2 = sel2; tmp3 = sel2;
					roving=0;

					if (sel1.length==3) { // 2 roving bankers
						sel1 = tmp1;
						sel2 = tmp1;
						sel3 = tmp2;
						calcCombinations(bt);
						roving+=combinations;

						sel1 = tmp1;
						sel2 = tmp2;
						sel3 = tmp1;
						calcCombinations(bt);
						roving+=combinations;

						sel1 = tmp2;
						sel2 = tmp1;
						sel3 = tmp1;
						calcCombinations(bt);
						combinations += roving;
					}
					else { // 1 roving banker
						sel1 = tmp1;
						sel2 = tmp2;
						sel3 = tmp2;
						calcCombinations(bt);
						roving+=combinations;

						sel1 = tmp2;
						sel2 = tmp1;
						sel3 = tmp2;
						calcCombinations(bt);
						roving+=combinations;

						sel1 = tmp2;
						sel2 = tmp2;
						sel3 = tmp1;
						calcCombinations(bt);
						combinations += roving;
					}
				}
			}
			else if ((bt == "qinR") || (bt == "dueR"))
			{
				// quinella roving banker or duet roving banker
				tmp=0;
				if(ob.name==1)
				{
					if (ob.checked) 
					{
						totals[na] += va + "," ;
						combinations=calcQuinellaRBComb();
					}
					else 
					{
						totals[na] = totals[na].replace(va + ",",""); 
						combinations=0;
					}
				}
				else if (ob.name == 2)
				{
					if (ob.checked) 
					{
						if (va == "F") 
						{ 
							fields[na] = true; 
							checkCheckBoxesRB(true,na); 
							if(totals[1]=="") {combinations = 0 ;}
							else {combinations = calcQuinellaRBComb();}
						}
						else 
						{ 
							totals[na] += va + "," ;
							if(totals[1]=="") {combinations = 0 ;}
							else {combinations = calcQuinellaRBComb();}
							
						}
					}
					else {
						if (va == "F") 
						{ 
							fields[na] = false; 
							checkCheckBoxesRB(false,na); 
							combinations = 0;
						}
						else 
						{ 
							RemoveFromArray(na,va);
							if(totals[1]=="") {combinations = 0 ;}
							else {combinations=calcQuinellaRBComb(); }
							
						}
					}
				}
				/*
				sel1 = new Array(); sel1 = totals[1].split(",");
				sel2 = new Array(); sel2 = totals[2].split(",");

				if (bt != "exaB") calcCombinations(bt);
				else {
						for (i=0; i!=document.bc.elements.length; i++) {
							if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].checked) && (document.bc.elements[i].value.indexOf("F") == -1) )
								t++;
						}
						combinations = t * (t-1);
					}
		
				if (bt == "exaR") {
					combinations = combinations;
				}
				*/
			}
			/*FIRST 4 created by ADI*/
			else if((bt=="fst4") || (bt=="fst4F") || (bt=="fst4B") || (bt=="fst4S") || (bt=="fst4R")){
				//alert("FIRST4");
				//alert(va);
				//alert("enter first4 with comb "+combinations);
				tmp=0;
				if(bt=="fst4S")
				{
					if (ob.checked) {
						if (va == "F") { 
							fields[na] = true; 
							checkCheckBoxesStandout(true,na); 
							combinations = 0 }
						else { 
							combinations++; 
							totals[na] += va + "," }
					}
					else {
						if (va == "F") { 
							fields[na] = false; 
							checkCheckBoxesStandout(false,na); 
							combinations = 0 }
						else { 
							combinations--; 
							RemoveFromArray(na,va);
							//totals[na] = totals[na].replace(va + ",","") 
							}
					}
				}
				else if(bt=="fst4R")
				{
					if (ob.checked) {
						if (va == "F") { 
							fields[na] = true; 
							checkCheckBoxesRB(true,na); 
							combinations = 0 }
						else { 
							combinations++; 
							totals[na] += va + "," }
					}
					else {
						if (va == "F") { 
							fields[na] = false; 
							checkCheckBoxesRB(false,na); 
							combinations = 0 }
						else { 
							combinations--; 
							RemoveFromArray(na,va);
							}
					}
				}
				else if(bt=="fst4B")//added by ADI 19/12/2007
				{
					if (ob.checked) {
						checkCheckBoxesDec(true,na,va,3); combinations++; 
					}
					else {
						checkCheckBoxesDec(false,na,va,3); combinations--;
					}
				}
				else // first4 or first4flexi or first4box
				{
					if (ob.checked) {
						if (va == "F") { 
							fields[na] = true; 
							checkCheckBoxes(true,na); 
							combinations = 0 }
						else { 
							combinations++; 
							totals[na] += va + "," }
					}
					else {
						if (va == "F") { 
							fields[na] = false; 
							checkCheckBoxes(false,na); 
							combinations = 0 }
						else { 
							combinations--;
							RemoveFromArray(na,va);
							//totals[na] = totals[na].replace(va + ",","") 
							}
					}
				}
				
				//a1 = new Array(); a1 = totals[1].split(",");
				//a2 = new Array(); a2 = totals[2].split(",");
				//a3 = new Array(); a3 = totals[3].split(",");
				//a4 = new Array(); a4 = totals[4].split(",");
				//calcFirst4Combination(bt); // goto function FIRST 4
				
				if ((bt == "fst4") || (bt=="fst4F")) {
					a1 = new Array(); a1 = totals[1].split(",");
					a2 = new Array(); a2 = totals[2].split(",");
					a3 = new Array(); a3 = totals[3].split(",");
					a4 = new Array(); a4 = totals[4].split(",");
					calcFirst4Combination(bt); 
				}
				else if (bt == "fst4B") {
					a1 = new Array(); a1 = totals[1].split(",");
					calcFirst4BoxCombination(bt);
				}
				else if(bt=="fst4S")
				{
					a1 = new Array(); a1 = totals[1].split(",");
					a2 = new Array(); a2 = totals[2].split(",");
					a3 = new Array(); a3 = totals[2].split(",");
					a4 = new Array(); a4 = totals[2].split(",");
					calcFirst4Combination(bt); 
				}
				else if(bt=="fst4R")
				{
					a1 = new Array(); a1 = totals[1].split(",");
					a2 = new Array(); a2 = totals[2].split(",");
					calcFirst4RBCombination(bt); 
				}
			}
			
			//added by ADI 12/17/2007
			else if(bt=="qinS")
			{
				if (ob.checked) 
				{
					if (va == "F") 
					{ 
						fields[na] = true; 
						checkCheckBoxes(true,na); 
						combinations = 0 
					}
					else 
					{ 
						combinations++; 
						totals[na] += va + "," 
					}
				}
				else 
				{
					if (va == "F") 
					{ 
						fields[na] = false; 
						checkCheckBoxes(false,na); 
						combinations = 0 
					}
					else 
					{ 
						combinations--; 
						RemoveFromArray(na,va);
					}
				}
				
				if(bt=="qinS")
				{
					a1 = new Array(); a1 = totals[1].split(",");
					a2 = new Array(); a2 = totals[2].split(",");
					calcQuinellaStandoutCombination(bt);
				}
			}
		}
		
		//else3.4
		else { // D-D, R-D, QAD
			if ( (bt == "d-d") || (bt == "r-d") ) { combinations = totals[1] * totals[2] }
			//else if (bt == "qad") 
			else if (bt == "qad" || bt=="qadF") //added by ADI
			{ combinations = totals[1] * totals[2] * totals[3] * totals[4] }
			else if (bt=="BIG6") //added by Allan
			{ combinations = totals[1] * totals[2] * totals[3] * totals[4] * totals[5] * totals[6]}
		}
		combinations2 = combinations;
	}//endelse3


	//if4
	if (combinations2 <= 0) {combinations2 = 0; }
	var x = 1;
	if(bt == "exaR") {x = 2;}
	
	
	document.bc.betComb.value = combinations2 * x;
	
	popBetVals();
	
	//if(bt=="fst4"){
		
	//	document.bc.betComb.value = FORMULA * x;
		//document.bc.betComb.value = 56;
	//	document.getElementById('flexiText').innerHTML = Math.round(((document.bc.betAmount1.value) / (FORMULA * x))*100);
	//	}
	//document.getElementById('flexiText').innerHTML = Math.round(((document.bc.betAmount1.value) / (combinations2 * x))*100);
	//result=(((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2)
	//document.getElementById('flexiText').innerHTML = (((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2);
	//document.getElementById('flexiText').innerHTML = result;

}

function calcQuinellaRBComb()
{
	arrayRBcount = new Array(); arrayRBcount = totals[2].split(",");
	return arrayRBcount.length-1;
}

//Created by Dave Chan 27/06/2007 - Currently not using this function
function calcQuinellaR()
{
	var leg2 = 0;
	for (i=0; i!=document.bc.elements.length; i++) 
	{
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].checked) && (document.bc.elements[i].value.indexOf("F") == -1) &&  (document.bc.elements[i].name == "2") )
			leg2++;
	}
	
	cost = checkNum(document.bc.betAmount1.value) * leg2;
	
	document.bc.betCost.value = "" + cost;
}

function calcCombinations(bt) {
	// combination generator for EXA and TRI bet types
	combinations=0;
	for (i=0; i!=sel1.length-1; i++) {
		for (ii=0; ii!=sel2.length-1; ii++) {
			if (sel2[ii] != sel1[i]) {
				if ( (bt == "exa") || (bt == "exaB") || (bt == "exaS") || (bt == "exaR") ) {
					combinations++;
				}
				else {
					for (iii=0; iii!=sel3.length-1; iii++) {
						if ( (sel3[iii] != sel2[ii]) && (sel3[iii] != sel1[i]) ) {
							combinations++;
						}
					}
				}
			}
		}
	}
}

//added by ADI 12/17/2007
function calcQuinellaStandoutCombination(bt)
{
	combinations=0;
	
	A=a1.length -1;
	B=a2.length -1;
	AB=0;
	
	for (i=0; i!=a1.length-1; i++) {
		for (ii=0; ii!=a2.length-1; ii++) {
			if (a2[ii] == a1[i]) 
			{
				AB++;
			}
		}
	}
	if(A==1 && B==1 && AB==1) // this is only 1 selection in col1 and col2 and both are the same selection
	{
	}
	else
	{
		combinations=(A*B)-((AB*(AB+1))/2);
	}
}

//created by ADI calc combination First 4
function calcFirst4Combination(bt){
	/*
	a1,a2,a3,a4 will contains "" at the end of array
	so we dont care about the last index in function
	get2/3/4CountSelectionCommon --> a1.length-1;
	
	*/
	combinations=0;
	
	A=a1.length -1;
	B=a2.length -1;
	C=a3.length -1;
	D=a4.length -1;
	
	AxB=A*B;
	AxC=A*C;
	AxD=A*D;
	BxC=B*C;
	BxD=B*D;
	CxD=C*D;
	
	AnBnCnD=get4CountSelectionCommon(a1,a2,a3,a4);
	
	AnBnC=get3CountSelectionCommon(a1,a2,a3);
	AnBnD=get3CountSelectionCommon(a1,a2,a4);
	AnCnD=get3CountSelectionCommon(a1,a3,a4);
	BnCnD=get3CountSelectionCommon(a2,a3,a4);
	
	AnB=get2CountSelectionCommon(a1,a2);
	AnC=get2CountSelectionCommon(a1,a3);
	AnD=get2CountSelectionCommon(a1,a4);
	BnC=get2CountSelectionCommon(a2,a3);
	BnD=get2CountSelectionCommon(a2,a4);
	CnD=get2CountSelectionCommon(a3,a4);
	
	//alert(AnBnCnD);
	
	//FORMULA=A*B*C*D - 6*AnBnCnD + 2*((AnBnC*D)+(AnBnD*C)+(AnCnD*B)+(BnCnD*A)) + 1*((AnB*CnD)+(AnC*BnD)+(AnD*BnC)) - 1*((AnB*C*D)+(AnC*B*D)+(AnD*B*C) + (BnC*A*D)+(BnD*A*C)+(CnD*A*B));
	combinations=A*B*C*D - 6*AnBnCnD + 2*((AnBnC*D)+(AnBnD*C)+(AnCnD*B)+(BnCnD*A)) + 1*((AnB*CnD)+(AnC*BnD)+(AnD*BnC)) - 1*((AnB*C*D)+(AnC*B*D)+(AnD*B*C) + (BnC*A*D)+(BnD*A*C)+(CnD*A*B));
	//FORMULA=A*B*C*D;
	//alert(combinations);
	//combinations=get2CountSelectionCommon(a1,a2);
	//combinations=9;
	
}

function calcDuetCombination(bt)
{
	combinations=0;

	var isFSelected=false;
	A=sel1.length-1;
	
	for (i=0; i!=sel1.length-1; i++) 
	{
		if (sel1[i] == 'F') 
		{
			isFSelected=true;
		}	
	}

	if(A==1 && isFSelected==true)//F is selected
	{
		for(j=0;j<runnerTotal;j++)
		{
			combinations=combinations+j;	
		}
	}
	else if(A==2 && isFSelected==true)//F is selected and 1 Runner
	{
		combinations = runnerTotal-1;
	}
	else
	{
		for (i=0; i!=document.bc.elements.length; i++) {
			if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].checked) && (document.bc.elements[i].value.indexOf("F") == -1) )
				t++;
		}
		
		for(i=0;i<t;i++)
		{
			combinations=combinations+i;	
		}
	}
}

//added by ADI 18/12/2007
function calcExactaBoxCombination(bt)
{
	combinations=0;

	var isFSelected=false;
	A=sel1.length-1;
	
	for (i=0; i!=sel1.length-1; i++) 
	{
		if (sel1[i] == 'F') 
		{
			isFSelected=true;
		}	
	}

	if(A==1 && isFSelected==true)//F is selected
	{
		combinations=runnerTotal * (runnerTotal-1);	
	}
	else if(A==2 && isFSelected==true)//F is selected and 1 Runner
	{
		combinations = 2 * (runnerTotal-1);
	}
	else
	{
		for (i=0; i!=document.bc.elements.length; i++) 
					{
						//if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].checked) && (document.bc.elements[i].value.indexOf("F") == -1) )						//edited by ADI on 19/07/2007	
						if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name != "chkBox") && (document.bc.elements[i].checked) && (document.bc.elements[i].value.indexOf("F") == -1) )							
							t++;
					}
					combinations = t * (t-1);	
	}
}

//added by ADI 18/12/2007
function calcTrifectaBoxCombination(bt)
{
	combinations=0;
	var isFSelected=false;
	var A=sel1.length -1;
	
	for (i=0; i!=sel1.length-1; i++) 
	{
		if (sel1[i] == 'F') 
		{
			isFSelected=true;
		}	
	}
	
	if(A==1 && isFSelected==true)
	{
		RemoveFromArray(1,'F');
		for(i=1;i<=runnerTotal;i++)
		{
			totals[1] += i + ","
		}
		sel1 = new Array(); sel1=totals[1].split(",");
		sel2 = new Array(); totals[2] = totals[1]; sel2 = totals[2].split(",");
		sel3 = new Array(); totals[3] = totals[1]; sel3 = totals[3].split(",");
		
		calcCombinations(bt);	
		for(j=1;j<=runnerTotal;j++)
		{
			RemoveFromArray(1,j);
		}
		totals[1] += "F,"
	}
	else if(A==2 && isFSelected==true)
	{
		combinations = 3 * (runnerTotal-1) * (runnerTotal-2);
	}
	else if(A==3 && isFSelected==true)
	{
		combinations = 6 * (runnerTotal-2);
	}
	else
	{
		//trifecta box col2 and col3 equals col1
		sel2 = new Array(); totals[2] = totals[1]; sel2 = totals[2].split(",");
		sel3 = new Array(); totals[3] = totals[1]; sel3 = totals[3].split(",");
		
		calcCombinations(bt);	
	}
}

//added by ADI 18/12/2007
function calcFirst4BoxCombination(bt)
{
	combinations=0;
	var isFSelected=false;
	var A=a1.length -1;

	for (i=0; i!=a1.length-1; i++) 
	{
		if (a1[i] == 'F') 
		{
			isFSelected=true;
		}	
	}
	
	if(A==1 && isFSelected==true)
	{
		RemoveFromArray(1,'F');
		for(i=1;i<=runnerTotal;i++)
		{
			totals[1] += i + ","
		}
		a1 = new Array(); a1 = totals[1].split(",");
		a2 = new Array(); totals[2] = totals[1]; a2 = totals[2].split(",");
		a3 = new Array(); totals[3] = totals[1]; a3 = totals[3].split(",");
		a4 = new Array(); totals[4] = totals[1]; a4 = totals[4].split(",");
		
		calcFirst4Combination(bt); 
		
		for(j=1;j<=runnerTotal;j++)
		{
			RemoveFromArray(1,j);
		}
		totals[1] += "F,"
	}
	else if(A==2 && isFSelected==true)
	{
		combinations = 4 * (runnerTotal-1) * (runnerTotal-2) * (runnerTotal-3);	
	}
	else if(A==3 && isFSelected==true)
	{
		combinations = 12 * (runnerTotal-2) * (runnerTotal-3);	
	}
	else if(A==4 && isFSelected==true)
	{
		combinations = 24 * (runnerTotal-3);	
	}
	else
	{
		a1 = new Array(); a1 = totals[1].split(",");
		a2 = new Array(); totals[2] = totals[1]; a2 = totals[2].split(",");
		a3 = new Array(); totals[3] = totals[1]; a3 = totals[3].split(",");
		a4 = new Array(); totals[4] = totals[1]; a4 = totals[4].split(",");

		calcFirst4Combination(bt); 
	}
}


function calcFirst4RBCombination(bt)
{
	combinations=0;
	
	A=a1.length -1;
	B=a2.length -1;
	
	if(A==1)
	{
		combinations = B * (B-1) * (B-2) *4;
	}
	else if(A==2)
	{
		combinations = B * (B-1) * 12;
	}
	else if(A==3)
	{
		combinations = B * 24;
	}
}


function get2CountSelectionCommon(array1,array2){
	comb=0;
	ar1 = new Array();
	ar2 = new Array();
	ar1=array1;
	ar2=array2;
	for(i=0; i<ar1.length-1; i++){
		for(ii=0;ii<ar2.length-1;ii++){
			if(ar1[i] == ar2[ii]){
				comb++;
			}
		}
	}
	return comb;
}

function get3CountSelectionCommon(array1,array2,array3){
	comb=0;
	ar1 = new Array();
	ar2 = new Array();
	ar3 = new Array();
	ar1 = array1;
	ar2 = array2;
	ar3 = array3;
	for(i=0; i<ar1.length-1; i++){
		for(ii=0;ii<ar2.length-1;ii++){
			if(ar1[i] == ar2[ii]){
				for (iii=0; iii<ar3.length-1; iii++) {
					if (ar3[iii]==ar2[ii] ) {
							comb++;
					}
				}
			}
		}
	}
	return comb;
}

function get4CountSelectionCommon(array1,array2,array3,array4){
	comb=0;
	ar1 = new Array();
	ar2 = new Array();
	ar3 = new Array();
	ar4 = new Array();

	ar1 = array1;
	ar2 = array2;
	ar3 = array3;
	ar4 = array4;
	for(i=0; i<ar1.length-1; i++){
		for(ii=0;ii<ar2.length-1;ii++){
			if(ar1[i] == ar2[ii]){
				for (iii=0; iii<ar3.length-1; iii++) {
					if (ar3[iii]==ar2[ii] ) {
						for (iiii=0; iiii<ar4.length-1; iiii++) {
							if (ar4[iiii]==ar3[iii] ) {
								comb++;
							}
						}
					}
				}
			}
		}
	}
	return comb;
}


/*
this function will be called by checkDisable every 0.2 second
it will update:
	- total cost
	- flexi percentage (if checked)
*/
function popBetVals() {
    var betType = document.getElementById('betType');
	var bt = betType.options[betType.selectedIndex].value;
	
	if(bt=="due")
	{
		//alert(document.bc.betAmount1.value);
		//alert(combinations2);
	}
	var x = 1;
	bt = document.bc.betType.options[document.bc.betType.selectedIndex].value;
	var chkFlexi = document.getElementById('chkFlexi');
	flexiCost = 0;
	
	if(bt == "exaR") x = 2;
	
	if (bt == "e-w") 
	{
		cost = checkNum(document.bc.betAmount1.value);
		cost2 = checkNum(document.bc.betAmount2.value);
		
		if ( (cost == 0) && (cost2 == 0) ) { document.bc.betCost.value = "0.00"; return 1 } // require both WIN and PLA fields to be specified
		else if ( (cost > 0) && (cost2 == 0) ) { cost=cost; } // WIN
		else if ( (cost == 0) && (cost2 > 0) ) { cost=cost2; } // PLACE
		else {cost = cost + cost2;} 
		
	}
	else 
	{
		cost = checkNum(document.bc.betAmount1.value);
	}
	
	flexiCost = checkNum(document.bc.betAmount1.value); //for flexi calc
	
	cost = cost * combinations2 * x;//cost = amount of money * combinations * 1
	
	//alert(cost);

	if (chkFlexi.checked) //change cost if flexi checked then 
	{
		//alert(combinations2);
		cost = document.bc.betAmount1.value;
		var stringValue = String(Math.round(((document.bc.betAmount1.value) / (combinations2 * x))*100));
		if(stringValue=="Infinity")
		{
			document.getElementById('flexiText').innerHTML = "";
		}
		else
		{
			tempflexi = (((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2);
			if(tempflexi<1)
			{
			//document.getElementById('flexiText').innerHTML = Math.round(((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2);
			    document.getElementById('flexiText').innerHTML = (((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2);
			    document.getElementById('flexiText').style.color="red";
			}
			else
			{
				document.getElementById('flexiText').innerHTML = (((document.bc.betAmount1.value) / (combinations2 * x))*100).toFixed(2);
			    document.getElementById('flexiText').style.color="black";
			}
		}
	}
	else
	{
		document.getElementById('flexiText').innerHTML = ""; //if not flexi then flexi % is empty
	}
	
	if ((cost % 1) == 0) 
	{ 
		
		//cost += ".00";
	}
	else 
	{ 
		cost += "0"; 
	}
	
	
	document.bc.betCost.value = "" + cost;
}

function checkNum(v) {
	if (v == null) { return 0 } // if there's nothing to check
	if (isNaN(v)) { return 0 } // if JS's alpha test finds a non-num char
	if ((parseInt(v)+"") == "NaN") { return 0 } // if backup test finds a non-num char
	v = parseFloat(v); // convert to float
	if ((v % .5) != 0) { return 0 } // make sure it's a multiple of 50 cents
	return v; // send it back
}

function checkCheckBoxes(state,na) {
	totals[na]="";
	runner=0;

	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].name.indexOf("F") == -1) ) {
			document.bc.elements[i].checked = state;
		}
	}
	
	if (state == true) {
		for (i=0; i!=runnerTotal; i++) {
			totals[na] +=( i+1) + ","
		}
	}

	// disallow same selections across positions for tri and exa (roving / standout)
	//if ( (document.bc.elements[1].name != na) && (document.bc.elements[i].value == va) && (document.bc.elements[i].checked) ) {
		//ob.checked=false;
		//return 1;
		//break;
}

function checkCheckBoxesDec(state,na,va,maxSelected) {
	if(state==true)
	{
		totals[na] += va + ",";
	}
	else
	{
		RemoveFromArray(na,va);
	}
	
	runner=0;
	var totalselected=0;
	var Fselected=0;
	
	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na)&&(document.bc.elements[i].checked==true) && document.bc.elements[i].value!="F") {
			totalselected++;
		}
		else if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na)&&(document.bc.elements[i].checked==true) && document.bc.elements[i].value=="F") {
			Fselected++;
		}
	}
	
	
	if(Fselected==1 && totalselected>maxSelected)
	{
		for (i=0; i!=document.bc.elements.length; i++) 
		{
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na)&&(document.bc.elements[i].checked==true) && document.bc.elements[i].value==va) {
			document.bc.elements[i].checked = false;
			RemoveFromArray(na,va);
			}
		}
	}
	
	/*if (state == true) {
		for (i=0; i!=runnerTotal; i++) {
			totals[na] +=( i+1) + ","
		}
	}
*/
}


//created by ADI on 16/07/2007
function checkCheckBoxesStandout(state,na) {
	aar1 = new Array(); aar1 = totals[1].split(",");
	totals[na]="";
	runner=0;
	
	
	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].value == aar1[0]) && state==true) {
			document.bc.elements[i].checked = false;//will untick the value that equal to LEGS1
		}
		else if( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].value == aar1[0]) && state==false) {
			document.bc.elements[i].checked = false;//will untick the value that equal to LEGS1
		}
		else if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].name.indexOf("F") == -1) ) {
			document.bc.elements[i].checked = state;//will tick all the field except the one that equal to the value of LEGS1
		}
	}
	
	if (state == true) {
		for (i=0; i!=runnerTotal; i++) {
			totals[na] += (i+1) + ",";
		}
	}

	
	if(aar1[0]=="")//not tick anything in LEGS1 so we dont need to remove any value from LEGS2
	{
		
	}
	else//will delete the value that equal to value of LEGS1 in totals[na]
	{
	   totals[na] = totals[na].replace(aar1[0] + ",","");
	}
}




//created by ADI on 16/07/2007
function checkCheckBoxesRB(state,na) {
	aar1 = new Array(); aar1 = totals[1].split(",");
	arraytemp = new Array(); arraytemp=aar1;
	totals[na]="";
	runner=0;
	
	/*for (i=0; i!=document.bc.elements.length; i++){ 	
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].name.indexOf("F") == -1) ) {
			document.bc.elements[i].checked = state;
			
			for(k=0; k<aar1.length-1; k++){
				if(document.bc.elements[i].value == arraytemp[k])
				{
					document.bc.elements[i].checked = false;
					arraytemp = removeitems(arraytemp,3);
					alert(arraytemp);
					alert(aar1);
				}
			}
		}
	}*/
	
	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && ((document.bc.elements[i].value == aar1[0]) || (document.bc.elements[i].value == aar1[1]) || (document.bc.elements[i].value == aar1[2])) && state==true) {
			document.bc.elements[i].checked = false;//will untick the value that equal to LEGS1
		}
		else if( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && ((document.bc.elements[i].value == aar1[0]) || (document.bc.elements[i].value == aar1[1]) || (document.bc.elements[i].value == aar1[2])) && state==false) {
			document.bc.elements[i].checked = false;//will untick the value that equal to LEGS1
		}
		else if ( (document.bc.elements[i].type == "checkbox") && (document.bc.elements[i].name == na) && (document.bc.elements[i].name.indexOf("F") == -1) ) {
			document.bc.elements[i].checked = state;//will tick all the field except the one that equal to the value of LEGS1
		}
	}

	if (state == true) {
		for (i=0; i!=runnerTotal; i++) {
			totals[na] += (i+1) + ",";
		}
	}

	
	for(i=0;i<aar1.length-1;i++)
	{
	   totals[na] = totals[na].replace(aar1[i] + ",","");
	}
}



function removeItems(originalArray, itemsToRemove) {
	var j;
	for (var i = 0; i < itemsToRemove.length; i++) {
		j = 0;
		while (j < originalArray.length) {
			if (originalArray[j] == itemsToRemove[i]) {
			originalArray.splice(j, 1);
			} 
			else {
			j++;
			}
		}
	}
	return originalArray;
}



//created by ADI
//this function is used to remove string value from Totals[name]
function RemoveFromArray(name,value)
{
	array=new Array(); array=totals[name].split(",");
	totals[name]="";
	for(i=0;i!=array.length-1;i++)
	{
		if(array[i]==value)
		{
			
		}
		else
		{
			totals[name] += array[i] + ",";
		}
	}
}




//added by ADI on 24/07/2007
function disableCheckBoxes(column)
{
	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].name == column) && (document.bc.elements[i].disabled==false) ) {
			//alert("ayo");
			document.bc.elements[i].disabled=true;
		}
	}
}

//added by ADI on 24/07/2007
function enableCheckBoxes(column)
{
	for (i=0; i!=document.bc.elements.length; i++) {
		if ( (document.bc.elements[i].name == column) && (document.bc.elements[i].disabled==true) ) {
			//alert("ayo");
			document.bc.elements[i].disabled=false;
		}
	}
}

function betClear() {
	fields = new Array(); // used to hold field click lock
	sel1 = new Array(); // used to split selection strings on commas
	sel2 = new Array();
	sel3 = new Array();

	totals=new Array("","","","","","",""); // used for combination calc
	betString=""; // used to build a bet string
	combinations=0; // first combinations total
	combinations2=0; // final combinations total

	document.bc.explain.value = explanations[document.bc.betType.options[document.bc.betType.selectedIndex].value]
		+ "\n\nClick on the 'Reset' button each time you want to enter another bet.";
}

// text for textarea
explanations = new Array();
explanations["win"] = "Win - Simply pick the runner that you think will be first past the post at the end of the race.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runner(s) in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";


explanations["pla"] = "Place - For a Place bet you simply pick a runner and you will win if it finishes first, second or third.\n\n\Step 2.\n-Select your field size or leave it as default of 12.\n-Select your runner(s) in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nNote: Third place pays when there are more than 8 starters in the race.";


explanations["e-w"] =  "Win - Simply pick the runner that you think will be first past the post at the end of the race. \n\nPlace - For a Place bet you simply pick a runner and you will win if it finishes first, second or third. \n\nStep 2.\n-Select your field size or leave it as default of 12. \n-Select your runner(s) in column 1. \n\nStep 3. Enter your Win amount and/or Place amount eg. 0.50, 1, 15, 45.50 without a $. \n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s)."; 




explanations["qin"] = "Quinella - The object of a Quinella is to pick the first two past the post. It makes no difference what order they finish in.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runners in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nPlacing Field and Selection bets: You are able to select a maximum of 1 runner and the field in either order in column one only.\n\nOptions. Select a bet type option: Roving Banker.\n(the Bet Type Description will change to reflect the option you select).";

explanations["qinR"] = "Roving Banker Quinella - The Roving Banker Quinella is where you have a runner you believe will finish first or second, with one or more runners to fill the other placing.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your roving banker runner in column 1.\n-Select one or more runners to fill the other placing in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";


explanations["qinS"] = "Standout Quinella - The Standout Quinella requires you to combine the runner you believe will finish first or second (your standout) and two or more runners to finish in the other position. To win, your standout runner must finish in first or second place with any of your other selections filling the other place.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your standout runner in column 1.\n-Select two or more runners in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";



explanations["due"] = "Duet - The Duet bet requires you to correctly select two of the three placegetters in any order.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select a minimum of two runners in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nPlacing Field and Selection bets: You are able to select a maximum of 1 runner and the field in either order in column one only.\n\nOptions. Select a bet type option: Roving Banker.\n(the Bet Description will change to reflect the option you select).\n\nNote: Duet will only be available on races that have 8 runners or more.\nMore: The Duet will pay three Dividends for the combinations 1st and 2nd, 1st and 3rd or 2nd and 3rd.";

explanations["dueR"] = "Roving Banker Duet - The Roving Banker Duet is where you have a runner you believe will finish first, second or third, with two or more runners to fill the other placing.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your roving banker runner in column 1.\n-Select one or more runners to fill the other placing in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";

explanations["exa"] = "Exacta - An Exacta bet requires you to select the two runners that you think will finish first and second, in the exact finishing order.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runner(s) to finish first in column 1.\n-Select your runner(s) to finish second in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Select a bet type option: Box or Roving Banker.\n(the Bet Description will change to reflect the option you select).";




explanations["exaB"] = "Box Exacta - The Box Exacta requires you to select two or more runners from which any two can finish first and second, in either order.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runners in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nPlacing Field and Selection bets: You are able to select a maximum of 1 runner and the field in either order in column one only.";

explanations["exaS"] = "Standout Exacta - The Standout Exacta requires you to combine the runner you believe will Win (your standout) and two or more runners to finish second. To win, your standout runner must finish in first place with any of your other selections filling second place.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your standout runner in column 1.\n-Select two or more runners to finish second in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";

explanations["exaR"] = "Roving Banker Exacta - The Roving Banker Exacta is where you have a runner you believe will finish first or second, with two or more runners to fill the other placing.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your roving banker runner in column 1.\n-Select one or more runners to fill the other placing in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).";

explanations["tri"] = "Trifecta - A trifecta bet requires you to select the first three placegetters in any one race, in the exact finishing order.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runner(s) to finish first in column 1.\n-Select your runner(s) to finish second in column 2.\n-Select your runner(s) to finish third in column 3.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions.-Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\n-Select a bet type option: Box or Roving Banker.\n(the Bet Description will change to reflect the option you select).";

explanations["triB"] = "Box Trifecta - The Box Trifecta covers all possible combinations of your selections. So long as three of your selections finish first, second and third in any order, you will win.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runners in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nPlacing Field and Selection bets: You are able to select a maximum of 2 runners and the field in either order in column one only.\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend."; 

explanations["triS"] = "Standout Trifecta - In a Standout Trifecta you can select the winner of a race (your standout), and two or more runners to finish second and third (in any order).\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your standout in column 1.\n-Select two or more runners to finish second and third (in any order) in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend. \n\nStandout Trifecta example: Select number 3 as your standout selection to Win, with runners 5,7 and 8 to finish second and third. For you to win the Trifecta, number 3 must finish first, with any two of the other three selections filling the remaining two placings (in any order).";

explanations["triR"] = "Roving Banker Trifecta - This is where you believe that one or two runners will definitely finish 1st, 2nd or 3rd. You can place your bet by picking your favourite runner to finish in any place within your bet and complete the Trifecta with any number of other runners to fill the other placing(s).\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your roving banker runner(s) (maximum of 2 runners) in column 1.\n-Select two or more runners to fill the other placing(s) in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\nRoving Banker Trifecta example: Select runner 1 as your Roving Banker selection, with runners 2,3 and 4 to run the other two placings. For you to win the Trifecta, number 1 must finish first, second or third place with any two of the other runners filling the remaining two placings.\nYou can take up to two Roving Banker selections in a race, but both Roving Banker selections must finish in first, second or third.";

explanations["fst4"] = "First 4 -  A First 4 bet requires you to select the first four placegetters in any one race, in the exact finishing order.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runner(s) to finish first in column 1.\n-Select your runner(s) to finish second in column 2.\n-Select your runner(s) to finish third in column 3.\n-Select your runner(s) to finish fourth in column 4.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions.-Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n-Select a bet type option: Box or Roving Banker.\n(the Bet Description will change to reflect the option you select).";

explanations["fst4R"] = "Roving Banker First 4 - This bet requires you to select one, two or three runners that you believe will definitely finish 1st, 2nd, 3rd or 4th. You can take up to 3 selections as your Roving Banker(s) with other runners to fill the remaining place(s).\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your roving banker runner(s) (maximum of 3 runners) in column 1.\n-Select three or more runners to fill the other placing(s) in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\nRoving Banker First 4 example: Select runner 1 as your Roving Banker selection, with runners 2, 3, 4 and 6 to run the other three placings. For you to win the First 4, number 1 must finish first, second, third or fourth place with any three of the other runners filling the remaining three placings.\nYou can take up to three Roving Banker selections in a race, but all Roving Banker selections must finish in first, second, third or fourth.";

explanations["fst4S"] = "Standout First 4 - In a Standout First 4 you can select the winner of a race (your standout), and three or more runners to finish second, third and fourth (in any order).\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your standout in column 1.\n-Select three or more runners to finish second, third and fourth (in any order) in column 2.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\nStandout First 4 example: Select number 3 as your standout selection to Win, with runners 5, 6, 7, 8 to finish second, third and fourth. For you to win the First 4, number 3 must finish first, with any three of the other four selections filling the remaining three placings (in any order).";

explanations["fst4B"] = "Box First 4 - The Box First 4 covers all possible combinations of your selections. So long as four of your selections finish first, second, third and fourth in any order, you will win.\n\nStep 2.\n-Select your field size or leave it as default of 12.\n-Select your runners in column 1.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nPlacing Field and Selection bets: You are able to select a maximum of 3 runners and the field in either order in column one only.\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend."; 


explanations["d-d"] = "Daily Double - With the Daily Double, you select the winners of two races nominated by the TAB.\n\nStep 2.\n-Leave the Field size as default of 12 or select your Field size according to the greater field size of the 2 legs ie. if the first leg field size is 10 and the second leg field size is 15, set the field size as 15. Note: Both field sizes will reflect this number.\n-Select your runner(s) in the Leg 1 column.\n-Select your runner(s) in the Leg 2 column.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nNote: Both field sizes will reflect this number' on a new line.";

explanations["r-d"] = "Running Double - The Running Double requires you to select the winners of any two consecutive races in the same meeting. You select the races you wish to bet on, however they must be consecutive.\n\nStep 2.\n-Leave the Field size as default of 12 or select your Field size according to the greater field size of the 2 legs ie. if the first leg field size is 10 and the second leg field size is 15, set the field size as 15. Note: Both field sizes will reflect this number.\n-Select your runner(s) in the Leg 1 column.\n-Select your runner(s) in the Leg 2 column.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nNote: Both field sizes will reflect this number' on a new line.";

explanations["qad"] = "Quaddie - A Quaddie requires you select the winners of the four races nominated by the TAB.\n\nStep 2.\n-Leave the Field size as default of 12 or select your Field size according to the greater field size of the 4 legs ie. if the first leg field size is 10, the second leg field size is 15, the third leg field size is 20 and the fourth leg field size is 18, set thefield size as 20. Note: All field sizes will reflect this number.\n-Select your runner(s) in the Leg 1 column.\n-Select your runner(s) in the Leg 2 column.\n-Select your runner(s) in Leg 3 column.\n-Select your runner(s) in Leg 4 column.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows  you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\nNote: Both field sizes will reflect this number' on a new line.";

explanations["BIG6"] = "BIG6 - A BIG6 requires you select the winners of the six races nominated by the TAB.\n\nStep 2.\n-Leave the Field size as default of 12 or select your Field size according to the greater field size of the 6 legs. Note: All field sizes will reflect  this number.\n-Select your runner(s) in the Leg 1 column.\n-Select your runner(s) in the Leg 2 column.\n-Select your runner(s) in Leg 3 column.\n-Select your runner(s) in Leg 4 column.\n-Select your runner(s) in Leg 5 column.\n-Select your runner(s) in Leg 6 column.\n\nStep 3. Enter your bet amount eg. 0.50, 1, 15, 45.50 without a $.\n\nStep 4. The calculator will automatically calculate the bet cost and number of combination(s).\n\nOptions. Check the Flexi checkbox if you wish to take out a Flexi Bet.\nFlexi betting allows you to include as many selections as you want, at a bet amount that you nominate. If you win you will get a percentage of the full dividend.\n\nNote: Both field sizes will reflect this number' on a new line.";

function redraw(x) {
	document.bc.action='index.asp?bt=' + document.bc.betType.selectedIndex + "&fs=" + x;
	document.bc.submit();
}
