var G_Stake = 0;
var G_Potential = 0;
var G_Stake = 0;
var G_TotalStake = 0;
var G_NumberOfBets = 0;

var G_BetSlipOdds = new Array(14);
var G_BetSlipNumberOfRows = 0;

var G_OddsChanged = new Array(14);

for (I_OddChangedIndex = 0; I_OddChangedIndex < G_OddsChanged.length; I_OddChangedIndex++)
{
	G_OddsChanged[I_OddChangedIndex] = 0;
}

var G_LongMenu = false;

function RoundNumber(number, decimal_points) 
{
	if (!decimal_points)
	{
	    return Math.round(number);
	}
	else if (number == 0) 
	{
		var decimals = "";
		
		for (var i=0; i<decimal_points; i++)
		{
		    decimals += "0";
		}
		
		return "0." + decimals;
	}
    else
    {
	    var exponent = Math.pow(10,decimal_points);
	    var num = Math.round((number * exponent)).toString();
	
	    return num.slice(0, -1 * decimal_points) + "." + num.slice(-1 * decimal_points)
	}
}

function NumericValidate(P_Field, P_Event)
{
    var L_Key;
    var L_KeyCharacter;
	
    var L_Event;
	
    var L_HighlightedText = '';
    var L_HighlightActive = false;
	
    if (P_Field.setSelectionRange)
    {
	    L_HighlightedText = P_Field.value.substring(P_Field.selectionStart, P_Field.selectionEnd);
    }
    else if (document.getSelection)
    {
	    L_HighlightedText = document.getSelection();
    }
    else if (document.selection)
    {
	    L_HighlightedText = document.selection.createRange().text;
    }

    if (L_HighlightedText != '')
    {
        L_HighlightActive = true;
    }
	
    if (P_Event)
    {
        if (!P_Event)
        {
            L_Event = window.event;
        }
        else
        {
            L_Event = P_Event;
        }
	    
        if (L_Event.keyCode)
        {
            L_Key = L_Event.keyCode;
        }
        else if (L_Event.which)
        {
            L_Key = L_Event.which;
        }	    
	    
        L_KeyCharacter = String.fromCharCode(L_Key);
	    
        if (L_HighlightActive == true)
        {
            if ((("0123456789").indexOf(L_KeyCharacter) > -1))
	        {
		        return true;
	        }
	        else if (((".").indexOf(L_KeyCharacter) > -1) && (P_Field.value.indexOf(".") == -1)) 
	        {
		        return true;
	        }
	        else
	        {
		        return false;
	        }
        }
        else
        {   
	        if ((L_Key == 8) || (L_Key == 9) || (L_Key == 13) || (L_Key == 27) || ((L_Key >= 35) &&  (L_Key <= 40) ))
	        {
		        return true;
	        }
	        else if (((".").indexOf(L_KeyCharacter) > -1) && (P_Field.value.indexOf(".") == -1)) 
	        {
		        return true;
	        }
	        else if ((L_HighlightActive == false) && ((P_Field.value.indexOf(".") > -1) && ((P_Field.value.length - P_Field.value.indexOf(".")) > 2)))
	        {
	            return false;
	        }
	        else if ((("0123456789").indexOf(L_KeyCharacter) > -1))
	        {
		        return true;
	        }
	        else
	        {
		        return false;
	        }
        }
    }
    else
    {
       return true;
    }
}

function JSRoundToTwoDecimal(P_Number)
{
    return RoundNumber(P_Number, 2);
}

function CreateBrowserCookie(P_Name, P_Value) 
{
	document.cookie = P_Name + "=" + P_Value + "; path=/";
}

function CreateCookie(P_Name, P_Value, P_Days) 
{
    var L_Expires = "";
	
	if (P_Days > 0) 
	{
		var L_Date = new Date();
		
		L_Date.setTime(L_Date.getTime() + (P_Days * 24 * 60 * 60 * 1000));
		
		L_Expires = "; expires=" + L_Date.toGMTString();
	}
		
	document.cookie = P_Name + "=" + P_Value + L_Expires + "; path=/";
}

function ReadCookie(P_Name) 
{
	var L_NameEquals = P_Name + "=";
	var L_ParsedCookie = document.cookie.split(';');
	
	for(var I_Index = 0; I_Index < L_ParsedCookie.length; I_Index++) 
	{
		var L_Cookie = L_ParsedCookie[I_Index];
		
		while (L_Cookie.charAt(0) == ' ')
		{
		    L_Cookie = L_Cookie.substring(1, L_Cookie.length);
		}
		
		if (L_Cookie.indexOf(L_NameEquals) == 0) 
		{
		    return L_Cookie.substring(L_NameEquals.length, L_Cookie.length);
		}
	}
	
	return null;
}

function EraseCookie(P_Name) 
{
	CreateCookie(P_Name, "", -1);
}

function SetPotential()
{
	var L_Type = (1 * $('F_BetSlipType').value);

	G_Stake = 0;
	G_Potential = 0;
	G_Stake = 0;
	G_TotalStake = 0;
	G_NumberOfBets = 0;

	if ((L_Type == 1) || (L_Type == 2) || (L_Type == 3))
	{
	    var L_BonusOn = false;
	    var L_BonusMultiples = new Array();
	    
	    if ($('F_Co_BonusMultiples').innerHTML != '')
	    {
	        L_ParsedBonusData = $('F_Co_BonusMultiples').innerHTML.split(',');
	        
	        if (L_ParsedBonusData[0] == '1')
	        {
	            L_BonusOn = true;
	             
	            for (I_BonusIndex = 1; I_BonusIndex < L_ParsedBonusData.length; I_BonusIndex++)
	            {
	                L_BonusMultiples[(I_BonusIndex - 1)] = L_ParsedBonusData[I_BonusIndex];
	            }
	        }
	    }
	    
		$('F_BetSlipNumberOfBets').innerHTML = 1;
		$('F_BetSlipTotalStake').innerHTML = JSRoundToTwoDecimal((1 * $('F_StakeSlip').value));
		$('F_BetSlipPotential').innerHTML = JSRoundToTwoDecimal(((1 * $('F_BetSlipTotalOdd').innerHTML) * $('F_StakeSlip').value));
		
		if ($('F_BetSlipBonus') != null)
		{
		    $('F_BetSlipBonus').innerHTML = JSRoundToTwoDecimal(((1 * $('F_BetSlipPotential').innerHTML) * (L_BonusMultiples[G_BetSlipNumberOfRows - 1] / 100)));
		}

		for (I_Index = 0; I_Index < G_BetSlipNumberOfRows; I_Index++)
		{
			$('F_BankDiv_' + I_Index).innerHTML = '&nbsp';
			$('F_Bank_' + I_Index).value = 0;
		}
	}
	else if (L_Type == 4)
	{
		var L_Potential = 0;

		$('F_BetSlipNumberOfBets').innerHTML = G_BetSlipNumberOfRows;
		$('F_BetSlipTotalStake').innerHTML = JSRoundToTwoDecimal(($('F_StakeSlip').value * G_BetSlipNumberOfRows));

		for (I_Index = 0; I_Index < G_BetSlipNumberOfRows; I_Index++)
		{
			L_Potential += ((1 * G_BetSlipOdds[I_Index]) * $('F_StakeSlip').value);

			$('F_BankDiv_' + I_Index).innerHTML = '&nbsp';
			$('F_Bank_' + I_Index).value = 0;
		}

		$('F_BetSlipPotential').innerHTML = JSRoundToTwoDecimal(L_Potential);
		
		if ($('F_BetSlipBonus') != null)
		{
		    $('F_BetSlipBonus').innerHTML = '0.00';
		}
	}
	else if ((L_Type >= 1000) && (L_Type < 13000))
	{
		G_Stake = (1 * $('F_StakeSlip').value);

		CalculateSystemPotential(L_Type);
		$('F_BetSlipNumberOfBets').innerHTML = G_NumberOfBets;
		$('F_BetSlipPotential').innerHTML = JSRoundToTwoDecimal(G_Potential);
		$('F_BetSlipTotalStake').innerHTML = JSRoundToTwoDecimal(G_TotalStake);

		for (I_Index = 0; I_Index < G_BetSlipNumberOfRows; I_Index++)
		{
			if ($('F_BankDiv_' + I_Index).innerHTML == '&nbsp;')
			{
				$('F_BankDiv_' + I_Index).innerHTML = $('F_BankTransferDiv_' + I_Index).innerHTML;
			}
		}
		
		if ($('F_BetSlipBonus') != null)
		{
		    $('F_BetSlipBonus').innerHTML = '0.00';
		}
	}

	if (('' + $('F_BetSlipTotalStake').innerHTML) == 'NaN')
	{
		$('F_BetSlipTotalStake').innerHTML = '---';
	}

	if (('' + $('F_BetSlipPotential').innerHTML) == 'NaN')
	{
		$('F_BetSlipPotential').innerHTML = '---';
	}

	return true;
}

function CalculateSystemPotential(P_Type)
{
	var L_SystemPotential = 0;
	var L_OffsetString = "";
	var L_Offset = 0;
	var L_Bankers = new Array(14);
	var L_WriteLine = true;

	G_NumberOfBets = 0;
	G_Potential = 0;

	if ((P_Type >= 1000) && (P_Type < 13000))
	{
		L_OffsetString = "" + P_Type;
		L_Offset = (1 * L_OffsetString.substring(0, 1 + (L_OffsetString.length - 4)));
		L_Offset--;
	}

	for (I_BankerIndex = 0; I_BankerIndex < G_BetSlipNumberOfRows; I_BankerIndex++)
	{
		if ($('F_Bank_' + I_BankerIndex).value == '1')
		{
			L_Bankers[I_BankerIndex] = 1;
		}
		else
		{
			L_Bankers[I_BankerIndex] = 0;
		}
	}

	// Iteration 1
	for (I_A = 0; I_A < G_BetSlipNumberOfRows; I_A++)
	{
		// Iteration 2
		for (I_B = (I_A + 1); I_B < G_BetSlipNumberOfRows; I_B++)
		{
			if (G_BetSlipNumberOfRows == (3 + L_Offset))
			{
				L_WriteLine = true;

				for (I_BankX = 0; I_BankX < 14; I_BankX++)
				{
					if (((I_BankX != I_A) && (I_BankX != I_B)) && (L_Bankers[I_BankX] == 1))
					{
						L_WriteLine = false;
					}
				}

				if (L_WriteLine == true)
				{
					L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]))));
					G_NumberOfBets++;
				}
			}
			else
			{
				// Iteration 3
				for (I_C = (I_B + 1); I_C < G_BetSlipNumberOfRows; I_C++)
				{
					if (G_BetSlipNumberOfRows == (4 + L_Offset))
					{
						L_WriteLine = true;

						for (I_BankX = 0; I_BankX < 14; I_BankX++)
						{
							if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C)) && (L_Bankers[I_BankX] == 1))
							{
								L_WriteLine = false;
							}
						}

						if (L_WriteLine == true)
						{
							L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]))));
							G_NumberOfBets++;
						}
					}
					else
					{
						// Iteration 4
						for (I_D = (I_C + 1); I_D < G_BetSlipNumberOfRows; I_D++)
						{
							if (G_BetSlipNumberOfRows == (5 + L_Offset))
							{
								L_WriteLine = true;

								for (I_BankX = 0; I_BankX < 14; I_BankX++)
								{
									if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D)) && (L_Bankers[I_BankX] == 1))
									{
										L_WriteLine = false;
									}
								}

								if (L_WriteLine == true)
								{
									L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]))));
									G_NumberOfBets++;
								}
							}
							else
							{
								// Iteration 5
								for (I_E = (I_D + 1); I_E < G_BetSlipNumberOfRows; I_E++)
								{
									if (G_BetSlipNumberOfRows == (6 + L_Offset))
									{
										L_WriteLine = true;

										for (I_BankX = 0; I_BankX < 14; I_BankX++)
										{
											if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E)) && (L_Bankers[I_BankX] == 1))
											{
												L_WriteLine = false;
											}
										}

										if (L_WriteLine == true)
										{
											L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]))));
											G_NumberOfBets++;
										}
									}
									else
									{
										// Iteration 6
										for (I_F = (I_E + 1); I_F < G_BetSlipNumberOfRows; I_F++)
										{
											if (G_BetSlipNumberOfRows == (7 + L_Offset))
											{
												L_WriteLine = true;

												for (I_BankX = 0; I_BankX < 14; I_BankX++)
												{
													if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F)) && (L_Bankers[I_BankX] == 1))
													{
														L_WriteLine = false;
													}
												}

												if (L_WriteLine == true)
												{
													L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]))));
													G_NumberOfBets++;
												}
											}
											else
											{
												// Iteration 7
												for (I_G = (I_F + 1); I_G < G_BetSlipNumberOfRows; I_G++)
												{
													if (G_BetSlipNumberOfRows == (8 + L_Offset))
													{
														L_WriteLine = true;

														for (I_BankX = 0; I_BankX < 14; I_BankX++)
														{
															if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G)) && (L_Bankers[I_BankX] == 1))
															{
																L_WriteLine = false;
															}
														}

														if (L_WriteLine == true)
														{
															L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]))));
															G_NumberOfBets++;
														}
													}
													else
													{
														// Iteration 8
														for (I_H = (I_G + 1); I_H < G_BetSlipNumberOfRows; I_H++)
														{
															if (G_BetSlipNumberOfRows == (9 + L_Offset))
															{
																L_WriteLine = true;

																for (I_BankX = 0; I_BankX < 14; I_BankX++)
																{
																	if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H)) && (L_Bankers[I_BankX] == 1))
																	{
																		L_WriteLine = false;
																	}
																}

																if (L_WriteLine == true)
																{
																	L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]))));
																	G_NumberOfBets++;
																}
															}
															else
															{
																// Iteration 9
																for (I_I = (I_H + 1); I_I < G_BetSlipNumberOfRows; I_I++)
																{
																	if (G_BetSlipNumberOfRows == (10 + L_Offset))
																	{
																		L_WriteLine = true;

																		for (I_BankX = 0; I_BankX < 14; I_BankX++)
																		{
																			if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H) && (I_BankX != I_I)) && (L_Bankers[I_BankX] == 1))
																			{
																				L_WriteLine = false;
																			}
																		}

																		if (L_WriteLine == true)
																		{
																			L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]) * (1 * G_BetSlipOdds[I_I]))));
																			G_NumberOfBets++;
																		}
																	}
																	else
																	{
																		// Iteration 10
																		for (I_J = (I_I + 1); I_J < G_BetSlipNumberOfRows; I_J++)
																		{
																			if (G_BetSlipNumberOfRows == (11 + L_Offset))
																			{
																				L_WriteLine = true;

																				for (I_BankX = 0; I_BankX < 14; I_BankX++)
																				{
																					if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H) && (I_BankX != I_I) && (I_BankX != I_J)) && (L_Bankers[I_BankX] == 1))
																					{
																						L_WriteLine = false;
																					}
																				}

																				if (L_WriteLine == true)
																				{
																					L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]) * (1 * G_BetSlipOdds[I_I]) * (1 * G_BetSlipOdds[I_J]))));
																					G_NumberOfBets++;
																				}
																			}
																			else
																			{
																				// Iteration 11
																				for (I_K = (I_J + 1); I_K < G_BetSlipNumberOfRows; I_K++)
																				{
																					if (G_BetSlipNumberOfRows == (12 + L_Offset))
																					{
																						L_WriteLine = true;

																						for (I_BankX = 0; I_BankX < 14; I_BankX++)
																						{
																							if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H) && (I_BankX != I_I) && (I_BankX != I_J) && (I_BankX != I_K)) && (L_Bankers[I_BankX] == 1))
																							{
																								L_WriteLine = false;
																							}
																						}

																						if (L_WriteLine == true)
																						{
																							L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]) * (1 * G_BetSlipOdds[I_I]) * (1 * G_BetSlipOdds[I_J]) * (1 * G_BetSlipOdds[I_K]))));
																							G_NumberOfBets++;
																						}
																					}
																					else
																					{
																						// Iteration 12
																						for (I_L = (I_K + 1); I_L < G_BetSlipNumberOfRows; I_L++)
																						{
																							if (G_BetSlipNumberOfRows == (13 + L_Offset))
																							{
																								L_WriteLine = true;

																								for (I_BankX = 0; I_BankX < 14; I_BankX++)
																								{
																									if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H) && (I_BankX != I_I) && (I_BankX != I_J) && (I_BankX != I_K) && (I_BankX != I_L)) && (L_Bankers[I_BankX] == 1))
																									{
																										L_WriteLine = false;
																									}
																								}
		
																								if (L_WriteLine == true)
																								{
																									L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]) * (1 * G_BetSlipOdds[I_I]) * (1 * G_BetSlipOdds[I_J]) * (1 * G_BetSlipOdds[I_K]) * (1 * G_BetSlipOdds[I_L]))));
																									G_NumberOfBets++;
																								}
																							}
																							else
																							{
																								// Iteration 13
																								for (I_M = (I_L + 1); I_M < G_BetSlipNumberOfRows; I_M++)
																								{
																									if (G_BetSlipNumberOfRows == (14 + L_Offset))
																									{
																										L_WriteLine = true;

																										for (I_BankX = 0; I_BankX < 14; I_BankX++)
																										{
																											if (((I_BankX != I_A) && (I_BankX != I_B) && (I_BankX != I_C) && (I_BankX != I_D) && (I_BankX != I_E) && (I_BankX != I_F) && (I_BankX != I_G) && (I_BankX != I_H) && (I_BankX != I_I) && (I_BankX != I_J) && (I_BankX != I_K) && (I_BankX != I_L)) && (L_Bankers[I_BankX] == 1))
																											{
																												L_WriteLine = false;
																											}
																										}
		
																										if (L_WriteLine == true)
																										{
																											L_SystemPotential += ((1 * (G_Stake * (1 * G_BetSlipOdds[I_A]) * (1 * G_BetSlipOdds[I_B]) * (1 * G_BetSlipOdds[I_C]) * (1 * G_BetSlipOdds[I_D]) * (1 * G_BetSlipOdds[I_E]) * (1 * G_BetSlipOdds[I_F]) * (1 * G_BetSlipOdds[I_G]) * (1 * G_BetSlipOdds[I_H]) * (1 * G_BetSlipOdds[I_I]) * (1 * G_BetSlipOdds[I_J]) * (1 * G_BetSlipOdds[I_K]) * (1 * G_BetSlipOdds[I_L]) * (1 * G_BetSlipOdds[I_M]))));
																											G_NumberOfBets++;
																										}
																									}
																								}
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	G_TotalStake = G_Stake * G_NumberOfBets;

	if ((L_SystemPotential / G_TotalStake) > 1000)
	{
		L_SystemPotential = 1000 * G_TotalStake;
	}

	G_Potential = L_SystemPotential;
}

function KeyUpCard(P_CardText)
{
	if ($('F_Card' + P_CardText).value.length == 4)
	{
		$('F_Card' + (P_CardText + 1)).focus();
	}

	return true;
}

function openBig(P_Url)
{
	var popup=window.open(P_Url, "popup", "height=" + (screen.availHeight-100) + ",width=" + (screen.availWidth-100) + ",scrollbars, resizable");
}

function ATC(P_Type, P_Odd, P_OddID, P_Sign, P_EventID, P_Event, P_DivisionID, bonus_enabled)
{
    // DATA: TYPE [0] - ODD [1] - ODD_ID [2] - SIGN[3] - EVENT_ID [4] - EVENT_DESC [5] - HORSE_RACING [6] - FORECAST [7] - ANTEPOST [8] - LIVEBET [9] - ID_GIRONE [10]
    
    var L_Data = $('F_Co_Info').innerHTML.split('|');
    var L_NumberOfRows = (L_Data.length - 1);
    
    var L_FoundMatch = false;
	var L_SameEvent = false;
	var L_Full = false;

	// Type = 0 - Normal Event
	// Type = 1 - Normal HorseRacing Event
	// Type = 2 - Forecast HorseRacing Event
	// Type = 3 - Antepost Event
	// Type = 4 - LiveBet
	
	

	if ((P_Type == 0) || (P_Type == 3) || (P_Type == 4))
	{
		if (L_NumberOfRows < 14)
		{
			for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
			{
			    var L_ParsedData = L_Data[I_Index].split('_');
			    
				if ((1 * P_OddID) == (1 * L_ParsedData[2]))
				{		
					L_FoundMatch = true;
				}
	
				if ((1 * P_EventID) == (1 * L_ParsedData[4]))
				{		
					L_SameEvent = true;
				}
			}
		}
		else
		{
			L_Full = true;
		}
	}
	else if (P_Type == 1)
	{
		var I_Index = 0;

		while (I_Index < L_NumberOfRows)
		{
		    var L_ParsedData = L_Data[I_Index].split('_');
		    
			if (L_Data[I_Index] != null)
			{
				if (((1 * L_ParsedData[2]) == (1 * P_OddID)) && ((1 * L_ParsedData[3]) == (1 * P_EventID)))
				{
					L_SameEvent = true;
				}
			}

			I_Index++;
		}
	}
	else if (P_Type == 2)
	{
		var I_Index = 0;

		while (I_Index < L_NumberOfRows)
		{
		    var L_ParsedData = L_Data[I_Index].split('_');
		    
			if (L_Data[I_Index] != null)
			{
				if (L_ParsedData[6] == 0)
				{
					DFC(L_ParsedData[2], false);
					I_Index--;
					L_NumberOfRows--;
				}
				else if ((1 * L_ParsedData[2]) == (1 * P_OddID))
				{
					DFC(L_ParsedData[2], false);
					I_Index--;
					L_NumberOfRows--;
				}
			}

			I_Index++;
		}

		for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
		{
			if ((1 * P_EventID) == (1 * L_ParsedData[4]))
			{		
				L_SameEvent = true;
			}
		}
	}

	if ((L_FoundMatch == false) && (L_SameEvent == false) && (L_Full == false))
	{
	    L_HorseRacing = 0;
	    L_Forecast = 0;
	    L_Antepost = 0;
	    L_LiveBet = 0;
	    
		if (P_Type == 1)
		{
			L_HorseRacing = 1;
			L_Forecast = 0;
			L_Antepost = 0;
			L_LiveBet = false;
		}
		else if (P_Type == 2)
		{
			L_HorseRacing = 1;
			L_Forecast = 1;
			L_Antepost = 0;
			L_LiveBet = 0;
		}
		else if (P_Type == 3)
		{
			L_HorseRacing = 0;
			L_Forecast = 0;
			L_Antepost = 1;
			L_LiveBet = 0;
		}
		else if (P_Type == 4)
		{
			L_HorseRacing = 0;
			L_Forecast = 0;
			L_Antepost = 0;
			L_LiveBet = 1;
		}
		else if (P_Type == 0)
		{
			L_HorseRacing = 0;
			L_Forecast = 0;
			L_Antepost = 0;
			L_LiveBet = 0;
		}
		
		$('F_Co_Info').innerHTML = $('F_Co_Info').innerHTML.replace('undefined', '') + P_Type + '_' + P_Odd + '_' + P_OddID + '_' + P_Sign + '_' + P_EventID + '_' + P_Event + '_' + L_HorseRacing + '_' + L_Forecast + '_' + L_Antepost + '_' + L_LiveBet + '_' + P_DivisionID + '|';
	}
	else if (L_FoundMatch == true)
	{
		$('F_Co_MSG').innerHTML = $('F_Co_MSG_SameOdd').innerHTML;
	}
	else if (L_SameEvent == true)
	{
		$('F_Co_MSG').innerHTML = $('F_Co_MSG_SameEvent').innerHTML;
	}
	else if (L_Full == true)
	{
		$('F_Co_MSG').innerHTML = $('F_Co_MSG_Full').innerHTML;
	}
    
    ATC_Render(bonus_enabled);
}

function ATC_Box(P_Type, P_Info, P_EventID, P_Event)
{
    var L_ParsedInfo = P_Info.split('_');

    ATC(P_Type, L_ParsedInfo[1], L_ParsedInfo[0], L_ParsedInfo[2], P_EventID, P_Event);
}

function DFC(P_OddID, P_Render)
{

    var L_Data = $('F_Co_Info').innerHTML.split('|');
    var L_NumberOfRows = (L_Data.length - 1);

    var L_InfoString;

    if (L_NumberOfRows > 0)
    {
        for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
        {
            var L_ParsedData = L_Data[I_Index].split('_');

            if ((1 * L_ParsedData[2]) != (1 * P_OddID))
            {
                L_InfoString = L_InfoString + L_Data[I_Index] + '|';
            }
        }
    }

    $('F_Co_Info').innerHTML = L_InfoString;
    
    if ($('F_DataOdd_' + P_OddID) != null)
    {
        $('F_DataOdd_' + P_OddID).className = 'Events_Odds';
    }
    if (window.parent.document.getElementById('F_DataOdd_' + P_OddID) != null)
    {
        window.parent.document.getElementById('F_DataOdd_' + P_OddID).className = 'Events_Odds';
    }

    if (P_Render == true)
    {
        ATC_Render();
    }
    
    
}

function DFC_All()
{
	var L_Found = false;
	var L_Data = $('F_Co_Info').innerHTML.split('|');
    var L_NumberOfRows = (L_Data.length - 1);

	while (L_NumberOfRows > 0)
	{
	    var L_ParsedData = L_Data[(L_NumberOfRows - 1)].split('_');

		DFC(L_ParsedData[2], false);

		L_Data = $('F_Co_Info').innerHTML.split('|');
        L_NumberOfRows = (L_Data.length - 1);
	}

	ATC_Render();
}

function HighlightSelectedOdds(P_Parent)
{
    if (P_Parent == false)
    {
        var L_Data = $('F_Co_Info').innerHTML.split('|');
        var L_NumberOfRows = (L_Data.length - 1);
       
       
        if (L_NumberOfRows > 0)
        {
            for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
            {
                var L_ParsedData = L_Data[I_Index].split('_');
                
                if ($('F_DataOdd_' + L_ParsedData[2]) != null)
	            {
	                $('F_DataOdd_' + L_ParsedData[2]).className = 'Events_OddsSelected';
	            }
	        }
	    }
    }
    else
    {
        var L_Data = window.parent.document.getElementById('F_Co_Info').innerHTML.split('|');
        var L_NumberOfRows = (L_Data.length - 1);
       
       
        if (L_NumberOfRows > 0)
        {
            for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
            {
                var L_ParsedData = L_Data[I_Index].split('_');
                
                if (window.parent.document.getElementById('F_DataOdd_' + L_ParsedData[2]) != null)
	            {
	                window.parent.document.getElementById('F_DataOdd_' + L_ParsedData[2]).className = 'Events_OddsSelected';
	            }
	        }
	    }
    }
}

function ATC_Render_Return(bonus_enabled)
{
    var L_NewRow = '';
    var L_TotalOdd = 1;
    
    var L_Data = $('F_Co_Info').innerHTML.split('|');
    var L_NumberOfRows = (L_Data.length - 1);
   
    var L_RowString = new Array();
       
    if (L_NumberOfRows > 0)
    {
        L_RowString[L_RowString.length] = '<div class="BetSlip_Title">Selection</div>';

        for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
        {
            var L_ParsedData = L_Data[I_Index].split('_');
            

            L_RowString[L_RowString.length] = '<div class="BetSlip_Row" id="F_BetSlipRow_' + L_ParsedData[2] + '">';

            L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both; margin-top: 2px;" class="DottedLight_DIV"><!-- --></div>';
            L_RowString[L_RowString.length] = '<div style="height: 2px; clear: both;"><!-- --></div>';

            L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow">';
            L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow1">';
            L_RowString[L_RowString.length] = '<div class="BetSlip_Event">' + L_ParsedData[5] + '</div>';
            L_RowString[L_RowString.length] = '<div class="BetSlip_Close"><a href="javascript:DFC(' + L_ParsedData[2] + ', true);"><img src="images/dustbin.gif" class="BetSlip_CloseImage" /></a></div>';

            if (L_ParsedData[1] > 0)
            {
                L_RowString[L_RowString.length] = '<div class="BetSlip_Odd">' + L_ParsedData[1] + '</div>';
            }
            else
            {
                L_RowString[L_RowString.length] = '<div class="BetSlip_Odd">SP</div>';
            }

            L_RowString[L_RowString.length] = '<div class="BetSlip_Sign">' + L_ParsedData[3] + '</div>';
            L_RowString[L_RowString.length] = '</div>';
            L_RowString[L_RowString.length] = '</div>';

            L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow">';
            L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow2">';
            L_RowString[L_RowString.length] = '<a href="default.asp?sec=events&arg=' + L_ParsedData[10] + '" class="BetSlip_Category">' + 'Division' + '</a>';


            L_RowString[L_RowString.length] = '<span id="F_BankTransferDiv_' + I_Index + '" style="display: none;"><a id="F_BankLink_' + I_Index + '" class="BetSlip_Banker" href="#" onclick="if ($(\'F_Bank_' + I_Index + '\').value == \'0\') { this.className = \'BetSlip_BankerSelected\'; $(\'F_Bank_' + I_Index + '\').value = \'1\'; } else { this.className = \'BetSlip_Banker\'; $(\'F_Bank_' + I_Index + '\').value = \'0\'; } SetPotential();">BANK</a></span><span class="coupon" id="F_BankDiv_' + I_Index + '">&nbsp;</span>';

            L_RowString[L_RowString.length] = '</div>';
            L_RowString[L_RowString.length] = '</div>';

            L_RowString[L_RowString.length] = '<div style="height: 1px; clear: both; margin-top: 1px;"><!-- --></div>';

            L_RowString[L_RowString.length] = '</div>';
        }

        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both; margin-top: 2px;" class="Dotted_DIV"><!-- --></div>';
            L_RowString[L_RowString.length] = '<div style="height: 2px; clear: both;"><!-- --></div>';
    }
    else
    {
        L_RowString[L_RowString.length] = '<div style="clear: both; height: 70px; padding: 0; margin: 0;"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div style="width: 100%; margin-bottom: 10px;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="RightMenuDiv">' + $('F_Co_EmptyString').innerHTML + '</div>';
        L_RowString[L_RowString.length] = '<div style="width: 100%; margin-top: 10px;" class="DottedLight_DIV"><!-- --></div>';    
    }
    
    if ( $('F_Co_MSG').innerHTML != '')
	{
	    L_RowString[L_RowString.length] = '<div class="BetSlip_Row">';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 0px; padding-bottom: 4px;">';

        L_RowString[L_RowString.length] = '<div style="clear: both; padding: 2px; margin: 0; font-family: Verdana; font-size: 9px; font-weight: bold; color: #FFFF00; text-transform: uppercase;">';

            L_RowString[L_RowString.length] = '<table cellpadding="0" cellspacing="0" style="border-width: 0px; width: 100%;">';
            L_RowString[L_RowString.length] = '<tr>';
            L_RowString[L_RowString.length] = '<td>';
            L_RowString[L_RowString.length] = '<div style="width: 15px; height: 15px; margin-bottom: 5px; background-image: url(\'images/warning_blue.gif\');" id="F_WarningIcon"></div>';
            L_RowString[L_RowString.length] = '</td>';
            L_RowString[L_RowString.length] = '<td>';
            L_RowString[L_RowString.length] = '<div style="width: 15px; height: 15px; float: left; width: 175px; margin-left: 5px; padding-top: 1px;" id="F_WarningText">';
            L_RowString[L_RowString.length] = $('F_Co_MSG').innerHTML;
            L_RowString[L_RowString.length] = '</div>';
            L_RowString[L_RowString.length] = '</td>';
            L_RowString[L_RowString.length] = '</tr>';
            L_RowString[L_RowString.length] = '</table>';
            L_RowString[L_RowString.length] = '<div style="clear: both;"><!-- --></div>';
            L_RowString[L_RowString.length] = '<div style="width: 100%; margin-top: 3px; margin-bottom: 5px;" class="Dotted_DIV"><!-- --></div>';

        L_RowString[L_RowString.length] = '</div>';
        
        $('F_Co_MSG').innerHTML = '';
	}
	
    if (L_NumberOfRows > 0)
	{
	    L_RowString[L_RowString.length] = '<div class="BetSlip_Row">';

        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';

				L_RowString[L_RowString.length] = ('<div style="float: left;">' + $('F_Co_MSG_Stake').innerHTML + ':</div>');
				L_RowString[L_RowString.length] = ('<div style="float: right;"><input type="text" id="F_StakeSlip" name="F_StakeSlip" class="site_text" value="" onkeypress="return NumericValidate(this, event);" onkeyup="return SetPotential();" maxlength="6" style="font-size:9px; width: 101px;"></div>');
				
		L_RowString[L_RowString.length] = '</div>';
		L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';		
				
				L_RowString[L_RowString.length] = ('<div style="float: left;">' + $('F_Co_MSG_System').innerHTML + ':</div>');

					L_RowString[L_RowString.length] = ('<div style="float: right;"><select id="F_BetSlipType" onchange="return SetPotential();" style="font-size:9px; width: 105px;">');

						if (L_Forecast == true)
						{
							L_RowString[L_RowString.length] = ('<option value="2">' + $('F_Co_MSG_Forecast').innerHTML + '</option>');
						}
						else if (L_NumberOfRows > 2)
						{
							L_RowString[L_RowString.length] = ('<option value="3">' + $('F_Co_MSG_Multiple').innerHTML + '</option>');

							if (L_NumberOfRows == 3)
							{
								L_RowString[L_RowString.length] = ('<option value="1020">' + $('F_Co_MSG_System').innerHTML + ' 2/3</option>');
							}
							else if (L_NumberOfRows == 4)
							{
								L_RowString[L_RowString.length] = ('<option value="2021">' + $('F_Co_MSG_System').innerHTML + ' 2/4</option>');
								L_RowString[L_RowString.length] = ('<option value="1022">' + $('F_Co_MSG_System').innerHTML + ' 3/4</option>');
							}
							else if (L_NumberOfRows == 5)
							{
								L_RowString[L_RowString.length] = ('<option value="3023">' + $('F_Co_MSG_System').innerHTML + ' 2/5</option>');
								L_RowString[L_RowString.length] = ('<option value="2024">' + $('F_Co_MSG_System').innerHTML + ' 3/5</option>');
								L_RowString[L_RowString.length] = ('<option value="1025">' + $('F_Co_MSG_System').innerHTML + ' 4/5</option>');
							}
							else if (L_NumberOfRows == 6)
							{
								L_RowString[L_RowString.length] = ('<option value="4026">' + $('F_Co_MSG_System').innerHTML + ' 2/6</option>');
								L_RowString[L_RowString.length] = ('<option value="3027">' + $('F_Co_MSG_System').innerHTML + ' 3/6</option>');
								L_RowString[L_RowString.length] = ('<option value="2028">' + $('F_Co_MSG_System').innerHTML + ' 4/6</option>');
								L_RowString[L_RowString.length] = ('<option value="1029">' + $('F_Co_MSG_System').innerHTML + ' 5/6</option>');
							}
							else if (L_NumberOfRows == 7)
							{
								L_RowString[L_RowString.length] = ('<option value="5030">' + $('F_Co_MSG_System').innerHTML + ' 2/7</option>');
								L_RowString[L_RowString.length] = ('<option value="4031">' + $('F_Co_MSG_System').innerHTML + ' 3/7</option>');
								L_RowString[L_RowString.length] = ('<option value="3032">' + $('F_Co_MSG_System').innerHTML + ' 4/7</option>');
								L_RowString[L_RowString.length] = ('<option value="2033">' + $('F_Co_MSG_System').innerHTML + ' 5/7</option>');
								L_RowString[L_RowString.length] = ('<option value="1034">' + $('F_Co_MSG_System').innerHTML + ' 6/7</option>');
							}
							else if (L_NumberOfRows == 8)
							{
								L_RowString[L_RowString.length] = ('<option value="6035">' + $('F_Co_MSG_System').innerHTML + ' 2/8</option>');
								L_RowString[L_RowString.length] = ('<option value="5036">' + $('F_Co_MSG_System').innerHTML + ' 3/8</option>');
								L_RowString[L_RowString.length] = ('<option value="4037">' + $('F_Co_MSG_System').innerHTML + ' 4/8</option>');
								L_RowString[L_RowString.length] = ('<option value="3038">' + $('F_Co_MSG_System').innerHTML + ' 5/8</option>');
								L_RowString[L_RowString.length] = ('<option value="2039">' + $('F_Co_MSG_System').innerHTML + ' 6/8</option>');
								L_RowString[L_RowString.length] = ('<option value="1040">' + $('F_Co_MSG_System').innerHTML + ' 7/8</option>');
							}
							else if (L_NumberOfRows == 9)
							{
								L_RowString[L_RowString.length] = ('<option value="7041">' + $('F_Co_MSG_System').innerHTML + ' 2/9</option>');
								L_RowString[L_RowString.length] = ('<option value="6042">' + $('F_Co_MSG_System').innerHTML + ' 3/9</option>');
								L_RowString[L_RowString.length] = ('<option value="5043">' + $('F_Co_MSG_System').innerHTML + ' 4/9</option>');
								L_RowString[L_RowString.length] = ('<option value="4044">' + $('F_Co_MSG_System').innerHTML + ' 5/9</option>');
								L_RowString[L_RowString.length] = ('<option value="3045">' + $('F_Co_MSG_System').innerHTML + ' 6/9</option>');
								L_RowString[L_RowString.length] = ('<option value="2046">' + $('F_Co_MSG_System').innerHTML + ' 7/9</option>');
								L_RowString[L_RowString.length] = ('<option value="1047">' + $('F_Co_MSG_System').innerHTML + ' 8/9</option>');
							}
							else if (L_NumberOfRows == 10)
							{
								L_RowString[L_RowString.length] = ('<option value="8048">' + $('F_Co_MSG_System').innerHTML + ' 2/10</option>');
								L_RowString[L_RowString.length] = ('<option value="7049">' + $('F_Co_MSG_System').innerHTML + ' 3/10</option>');
								L_RowString[L_RowString.length] = ('<option value="6050">' + $('F_Co_MSG_System').innerHTML + ' 4/10</option>');
								L_RowString[L_RowString.length] = ('<option value="5051">' + $('F_Co_MSG_System').innerHTML + ' 5/10</option>');
								L_RowString[L_RowString.length] = ('<option value="4052">' + $('F_Co_MSG_System').innerHTML + ' 6/10</option>');
								L_RowString[L_RowString.length] = ('<option value="3053">' + $('F_Co_MSG_System').innerHTML + ' 7/10</option>');
								L_RowString[L_RowString.length] = ('<option value="2054">' + $('F_Co_MSG_System').innerHTML + ' 8/10</option>');
								L_RowString[L_RowString.length] = ('<option value="1055">' + $('F_Co_MSG_System').innerHTML + ' 9/10</option>');
							}
							else if (L_NumberOfRows == 11)
							{
								L_RowString[L_RowString.length] = ('<option value="9056">' + $('F_Co_MSG_System').innerHTML + ' 2/11</option>');
								L_RowString[L_RowString.length] = ('<option value="8057">' + $('F_Co_MSG_System').innerHTML + ' 3/11</option>');
								L_RowString[L_RowString.length] = ('<option value="7058">' + $('F_Co_MSG_System').innerHTML + ' 4/11</option>');
								L_RowString[L_RowString.length] = ('<option value="6059">' + $('F_Co_MSG_System').innerHTML + ' 5/11</option>');
								L_RowString[L_RowString.length] = ('<option value="5060">' + $('F_Co_MSG_System').innerHTML + ' 6/11</option>');
								L_RowString[L_RowString.length] = ('<option value="4061">' + $('F_Co_MSG_System').innerHTML + ' 7/11</option>');
								L_RowString[L_RowString.length] = ('<option value="3062">' + $('F_Co_MSG_System').innerHTML + ' 8/11</option>');
								L_RowString[L_RowString.length] = ('<option value="2063">' + $('F_Co_MSG_System').innerHTML + ' 9/11</option>');
								L_RowString[L_RowString.length] = ('<option value="1064">' + $('F_Co_MSG_System').innerHTML + ' 10/11</option>');
							}
							else if (L_NumberOfRows == 12)
							{
								L_RowString[L_RowString.length] = ('<option value="10065">' + $('F_Co_MSG_System').innerHTML + ' 2/12</option>');
								L_RowString[L_RowString.length] = ('<option value="9066">' + $('F_Co_MSG_System').innerHTML + ' 3/12</option>');
								L_RowString[L_RowString.length] = ('<option value="8067">' + $('F_Co_MSG_System').innerHTML + ' 4/12</option>');
								L_RowString[L_RowString.length] = ('<option value="7068">' + $('F_Co_MSG_System').innerHTML + ' 5/12</option>');
								L_RowString[L_RowString.length] = ('<option value="6069">' + $('F_Co_MSG_System').innerHTML + ' 6/12</option>');
								L_RowString[L_RowString.length] = ('<option value="5070">' + $('F_Co_MSG_System').innerHTML + ' 7/12</option>');
								L_RowString[L_RowString.length] = ('<option value="4071">' + $('F_Co_MSG_System').innerHTML + ' 8/12</option>');
								L_RowString[L_RowString.length] = ('<option value="3072">' + $('F_Co_MSG_System').innerHTML + ' 9/12</option>');
								L_RowString[L_RowString.length] = ('<option value="2073">' + $('F_Co_MSG_System').innerHTML + ' 10/12</option>');
								L_RowString[L_RowString.length] = ('<option value="1074">' + $('F_Co_MSG_System').innerHTML + ' 11/12</option>');
							}
							else if (L_NumberOfRows == 13)
							{
								L_RowString[L_RowString.length] = ('<option value="11075">' + $('F_Co_MSG_System').innerHTML + ' 2/13</option>');
								L_RowString[L_RowString.length] = ('<option value="10076">' + $('F_Co_MSG_System').innerHTML + ' 3/13</option>');
								L_RowString[L_RowString.length] = ('<option value="9077">' + $('F_Co_MSG_System').innerHTML + ' 4/13</option>');
								L_RowString[L_RowString.length] = ('<option value="8078">' + $('F_Co_MSG_System').innerHTML + ' 5/13</option>');
								L_RowString[L_RowString.length] = ('<option value="7079">' + $('F_Co_MSG_System').innerHTML + ' 6/13</option>');
								L_RowString[L_RowString.length] = ('<option value="6080">' + $('F_Co_MSG_System').innerHTML + ' 7/13</option>');
								L_RowString[L_RowString.length] = ('<option value="5081">' + $('F_Co_MSG_System').innerHTML + ' 8/13</option>');
								L_RowString[L_RowString.length] = ('<option value="4082">' + $('F_Co_MSG_System').innerHTML + ' 9/13</option>');
								L_RowString[L_RowString.length] = ('<option value="3083">' + $('F_Co_MSG_System').innerHTML + ' 10/13</option>');
								L_RowString[L_RowString.length] = ('<option value="2084">' + $('F_Co_MSG_System').innerHTML + ' 11/13</option>');
								L_RowString[L_RowString.length] = ('<option value="1085">' + $('F_Co_MSG_System').innerHTML + ' 12/13</option>');
							}
							else if (L_NumberOfRows == 14)
							{
								L_RowString[L_RowString.length] = ('<option value="12086">' + $('F_Co_MSG_System').innerHTML + ' 2/14</option>');
								L_RowString[L_RowString.length] = ('<option value="11087">' + $('F_Co_MSG_System').innerHTML + ' 3/14</option>');
								L_RowString[L_RowString.length] = ('<option value="10088">' + $('F_Co_MSG_System').innerHTML + ' 4/14</option>');
								L_RowString[L_RowString.length] = ('<option value="9089">' + $('F_Co_MSG_System').innerHTML + ' 5/14</option>');
								L_RowString[L_RowString.length] = ('<option value="8090">' + $('F_Co_MSG_System').innerHTML + ' 6/14</option>');
								L_RowString[L_RowString.length] = ('<option value="7091">' + $('F_Co_MSG_System').innerHTML + ' 7/14</option>');
								L_RowString[L_RowString.length] = ('<option value="6092">' + $('F_Co_MSG_System').innerHTML + ' 8/14</option>');
								L_RowString[L_RowString.length] = ('<option value="5093">' + $('F_Co_MSG_System').innerHTML + ' 9/14</option>');
								L_RowString[L_RowString.length] = ('<option value="4094">' + $('F_Co_MSG_System').innerHTML + ' 10/14</option>');
								L_RowString[L_RowString.length] = ('<option value="3095">' + $('F_Co_MSG_System').innerHTML + ' 11/14</option>');
								L_RowString[L_RowString.length] = ('<option value="2096">' + $('F_Co_MSG_System').innerHTML + ' 12/14</option>');
								L_RowString[L_RowString.length] = ('<option value="1097">' + $('F_Co_MSG_System').innerHTML + ' 13/14</option>');
							}
						}
						else if (L_NumberOfRows == 2)
						{
							L_RowString[L_RowString.length] = ('<option value="2">' + $('F_Co_MSG_Double').innerHTML + '</option>');
						}
						else if (L_NumberOfRows == 1)
						{
							L_RowString[L_RowString.length] = ('<option value="1">' + $('F_Co_MSG_Single').innerHTML + '</option>');
						}

					L_RowString[L_RowString.length] = ('</select></div>');
			
                L_RowString[L_RowString.length] = '</div>';				
                
                L_RowString[L_RowString.length] = '<div style="clear: both;"><!-- --></div>';
			    L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both; margin-top: 8px;" class="Dotted_DIV"><!-- --></div>';
			    
                L_RowString[L_RowString.length] = '</div>';				
            }
    
    
    
    if (L_NumberOfRows > 0)
	{
	    var L_HorsePresent = false;
	    var L_LivePresent = false;
	    var L_Forecast = false;
	    
	    var L_BonusOn = false;
	    var L_BonusMultiples = new Array();
	    
	    if ($('F_Co_BonusMultiples').innerHTML != '')
	    {
	        L_ParsedBonusData = $('F_Co_BonusMultiples').innerHTML.split(',');
	        
	        if (L_ParsedBonusData[0] == '1')
	        {
	            L_BonusOn = true;
	             
	            for (I_BonusIndex = 1; I_BonusIndex < L_ParsedBonusData.length; I_BonusIndex++)
	            {
	                L_BonusMultiples[(I_BonusIndex - 1)] = L_ParsedBonusData[I_BonusIndex];
	            }
	        }
	    }
	    
		window.parent.G_BetSlipNumberOfRows = L_NumberOfRows;

		for (I_Index = 0; I_Index < L_NumberOfRows; I_Index++)
		{
		    var L_ParsedData = L_Data[I_Index].split('_'); 
		    
			window.parent.G_BetSlipOdds[I_Index] = JSRoundToTwoDecimal(L_ParsedData[1]);
			
			L_TotalOdd = L_TotalOdd * window.parent.G_BetSlipOdds[I_Index];
			
			if (L_TotalOdd > 1000)
			{
			    L_TotalOdd = 1000;
			}
			
			if ((L_ParsedData[6] == 1) && (L_ParsedData[7] == 0))
			{
				L_HorsePresent = true;
			}

			if (L_ParsedData[9] == 1)
			{
				L_LivePresent = true;
			}
			
			if ((I_Index == 0)  && (L_ParsedData[7] == 1))
			{
			    L_Forecast = true;
			}
		}
		
		L_TotalOdd = JSRoundToTwoDecimal(L_TotalOdd); 


		L_RowString[L_RowString.length] = '<div class="BetSlip_Title">Summary</div>';

        L_RowString[L_RowString.length] = '<div class="BetSlip_Row" style="font-size: 10px;">';
        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';
        L_RowString[L_RowString.length] = '<div style="float: left;">' + $('F_Co_MSG_TotalOdd').innerHTML + ':</div>';
        L_RowString[L_RowString.length] = '<div style="float: right;" id="F_BetSlipTotalOdd">' + L_TotalOdd + '</div>';
        L_RowString[L_RowString.length] = '<div style="clear: both;"></div>';
        L_RowString[L_RowString.length] = '</div>';
        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';
        L_RowString[L_RowString.length] = '<div style="float: left;">Number of Combinations:</div>';
        L_RowString[L_RowString.length] = '<div style="float: right;" id="F_BetSlipNumberOfBets">1</div>';
        L_RowString[L_RowString.length] = '<div style="clear: both;"></div>';
        L_RowString[L_RowString.length] = '</div>';
        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';
        L_RowString[L_RowString.length] = '<div style="float: left;">Total Stake:</div>';
        L_RowString[L_RowString.length] = '<div style="float: right;" id="F_BetSlipTotalStake">0.00</div>';
        L_RowString[L_RowString.length] = '<div style="clear: both;"></div>';
        L_RowString[L_RowString.length] = '</div>';
        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';
        L_RowString[L_RowString.length] = '<div style="float: left;">' + $('F_Co_MSG_PotentialWin').innerHTML + ':</div>';
        L_RowString[L_RowString.length] = '<div style="float: right;" id="F_BetSlipPotential">0.00</div>';
        L_RowString[L_RowString.length] = '<div style="clear: both;"></div>';
        L_RowString[L_RowString.length] = '</div>';
        
        if ((L_NumberOfRows > 4) && (L_BonusOn == true)&& (bonus_enabled == "1"))
	    {
            L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
            L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 4px; padding-bottom: 4px;">';
            L_RowString[L_RowString.length] = '<div style="float: left;">Bonus:</div>';
            L_RowString[L_RowString.length] = '<div style="float: right;" id="F_BetSlipBonus">0.00</div>';
            L_RowString[L_RowString.length] = '<div style="clear: both;"></div>';
            L_RowString[L_RowString.length] = '</div>';
        }
        
        
        L_RowString[L_RowString.length] = '<div style="width: 100%; clear: both;" class="DottedLight_DIV"><!-- --></div>';
        L_RowString[L_RowString.length] = '<div class="BetSlip_InnerRow" style="padding-top: 8px; padding-bottom: 0px;">';
        L_RowString[L_RowString.length] = '<div style="float: left;"><a href="javascript:DFC_All();" class="BetSlip_Button">Clear Bet Slip</a></div>';
        L_RowString[L_RowString.length] = '<div style="float: right;"><a href="#" onclick="$(\'F_Stake\').value = $(\'F_StakeSlip\').value; $(\'F_SavedBetSlip\').value = ReadCookie(\'BetSlip\'); $(\'F_Type\').value = $(\'F_BetSlipType\').value; $(\'F_ReviewForm\').submit();" class="BetSlip_Button">Confirm</a></div>';
        L_RowString[L_RowString.length] = '</div>';
        L_RowString[L_RowString.length] = '</div>';
	}

    return L_RowString.join('');
}

function ATC_Render(bonus_enabled)
{
    $('F_Co').innerHTML = ATC_Render_Return(bonus_enabled);
        
    CreateBrowserCookie("BetSlip", $('F_Co_Info').innerHTML);
    
    HighlightSelectedOdds(false);
}

function ATC_Render2()
{
    window.frames['F_DataFrame'].document.getElementById('F_Co').innerHTML = ATC_Render_Return();   
}

function QuickEvent(P_EventID, P_Index)
{
    var L_Found = false;
    
    if (P_EventID.substring(0, 1) == 'H')
    {
        if ($('F_QuickDataH_' + P_EventID) != null)
        {
            var L_Data = $('F_QuickDataH_' + P_EventID).innerHTML;
            
            var L_ParsedData = L_Data.split('|');

            
            $('F_QuickEventName_' + P_Index).value = L_ParsedData[2];
            $('F_QuickFullEventID_' + P_Index).value = 'H_' + L_ParsedData[0] + '_' + L_ParsedData[1] + '_' + L_ParsedData[3];
            $('F_QuickSign_' + P_Index).options.length = 0;

            $('F_QuickSign_' + P_Index).options[0] = new Option('W', 'W');
            $('F_QuickSign_' + P_Index).options[1] = new Option('P', 'P');
            $('F_QuickSign_' + P_Index).options[2] = new Option('1st', '1');
            $('F_QuickSign_' + P_Index).options[3] = new Option('2nd', '2');
            
            L_Found = true;
            
            $('F_QuickSign_' + P_Index).focus();
        }
    }
    else
    {
        var L_LoopIndex = (1 * $('F_Prefix').innerHTML);
        
        while ((L_LoopIndex > 10) && (L_Found == false))
        {
            if ($('F_QuickData_' + L_LoopIndex + '' + P_EventID) != null)
            {
                var L_Data = $('F_QuickData_' + L_LoopIndex + '' + P_EventID).innerHTML;

                var L_ParsedData = L_Data.split('|');

                var L_Odds = L_ParsedData[2].split('~');

                $('F_QuickEventName_' + P_Index).value = L_ParsedData[1];
                $('F_QuickFullEventID_' + P_Index).value = L_LoopIndex + '' + P_EventID;
                $('F_QuickSign_' + P_Index).options.length = 0;

                for (I_OddsIndex = 0; I_OddsIndex < (L_Odds.length - 1); I_OddsIndex++)
                {
                    L_ParsedOdds = L_Odds[I_OddsIndex].split(',');
                    
                    $('F_QuickSign_' + P_Index).options[I_OddsIndex] = new Option(L_ParsedOdds[1] + ' [' + JSRoundToTwoDecimal(L_ParsedOdds[2]) + ']', L_ParsedOdds[0] + '_' + L_ParsedOdds[2] + '_' + L_ParsedOdds[1]);
                }
                
                L_Found = true;
                
                $('F_QuickSign_' + P_Index).focus();
            }
            
            L_LoopIndex--;
        }
    }
    
    if (L_Found == false)
    {
        $('F_QuickEventName_' + P_Index).value = '';
        $('F_QuickSign_' + P_Index).options.length = 0;
    }
 
    return true;
}

function SubmitQuickBet()
{
    for (I_QuickIndex = 0; I_QuickIndex < 14; I_QuickIndex++)
    {
        if ( ($('F_QuickSign_' + I_QuickIndex).options.length > 0) &&
             ($('F_QuickEventID_' + I_QuickIndex).value != '') )
        {
            if ($('F_QuickFullEventID_' + I_QuickIndex).value.substring(0, 1) == 'H')
            {
                var L_ParsedInfo = $('F_QuickFullEventID_' + I_QuickIndex).value.split('_');
                
                if ($('F_QuickSign_' + I_QuickIndex).value == 'W')
                {
                    ATC(1, 0, 1, 'W', L_ParsedInfo[1], L_ParsedInfo[3], L_ParsedInfo[2]);
                }
                else if ($('F_QuickSign_' + I_QuickIndex).value == 'P')
                {
                    ATC(1, 0, 2, 'P', L_ParsedInfo[1], L_ParsedInfo[3], L_ParsedInfo[2]);
                }
                else if ($('F_QuickSign_' + I_QuickIndex).value == '1')
                {
                    ATC(2, 0, 1, '(1)', L_ParsedInfo[1], L_ParsedInfo[3], L_ParsedInfo[2]);
                }
                else if ($('F_QuickSign_' + I_QuickIndex).value == '2')
                {
                    ATC(2, 0, 2, '(2)', L_ParsedInfo[1], L_ParsedInfo[3], L_ParsedInfo[2]);
                }
            }
            else
            {
                var L_ParsedInfo = $('F_QuickSign_' + I_QuickIndex).value.split('_');
    
                ATC(0, L_ParsedInfo[1], L_ParsedInfo[0], L_ParsedInfo[2], $('F_QuickFullEventID_' + I_QuickIndex).value, $('F_QuickEventName_' + I_QuickIndex).value);
            }
        }
    }
}

function ResetQuickBet()
{
    for (I_Index = 0; I_Index < 14; I_Index++)
    {
        $('F_QuickEventID_' + I_Index).value = '';
        $('F_QuickEventName_' + I_Index).value = '';
        $('F_QuickSign_' + I_Index).options.length = 0;
    }
}