<!--

function Payout(stakeId, payoutId, price, stretch_price)
{
    var txtStake = document.getElementById(stakeId);
    if(txtStake != null){
	    var tbPayout = document.getElementById(payoutId);
	    if(tbPayout != null){
	        if((stretch_price != 0) && ((txtStake.value *100) % (stretch_price*100) == 0) ){
	            tbPayout.value = FormatAsMoney((50.0/stretch_price)*txtStake.value);
	        }
	        else{
	            tbPayout.value = FormatAsMoney(txtStake.value * price); 	            
	        }
	    }
	}
}

function StakeFromPayout(stakeId, payoutId, price, stretch_price){    
    var txtStake = document.getElementById(stakeId);
    if(txtStake != null){
	    var tbPayout = document.getElementById(payoutId);
	    if(tbPayout != null){	       
	        if((stretch_price != 0) && ((tbPayout.value%50) == 0)){		                  
	            txtStake.value = FormatAsMoney((tbPayout.value *stretch_price)/50.0);
	        }
	        else{
	            if(price != 0){	            
	                txtStake.value = FormatAsMoney(tbPayout.value / price);
	            }
	        }
	    } 
	}    
}

function TotalStake()
{
	totalStake = 0;	
	var div_bet_list = "divBetList";
	var div_input = document.getElementsByTagName("input");	
	if(div_input != null){
	    var stake_inputs = 0;
	    for(var i=0;i<div_input.length;i++) {
		    var stake = 0;		
		    if (div_input[i].type == "text" && div_input[i].id != null && div_input[i].id.indexOf("txtStake") != -1){				
			    stake =  div_input[i].value*1;	
			    stake_inputs++;		
		    }		
		    totalStake += stake;			
	    }
	    if(stake_inputs >0){
	        var lblTotalStake = document.getElementById("lblTotalStake");
	        if(lblTotalStake != null){	
	            lblTotalStake.innerHTML = "Total&nbsp;stake:&nbsp;"+FormatAsMoney(totalStake);
	        }
	    }
	}
}

function FormatAsMoney(m) {
    m -= 0;
    m = (Math.round(m*100))/100;
    return (m == Math.floor(m)) ? m + '.00' : ( (m*10 == Math.floor(m*10)) ? m + '0' : m);
}

//called when open/exotic bet 'times bet taken' is changed
function TimesBetTaken(numOfTimesBetTkn, stkId, combId){		
	txtStake = findObj(stkId);	
	txtComb = findObj(combId);		
	txtStake.value = FormatAsMoney(numOfTimesBetTkn.value*txtComb.value);		
	
}
//called when open/exotic bet stake is changed
function openBetsStake(stakeTxtBx, combId, numBetTakenId){		
	txtNumTaken = findObj(numBetTakenId);	
	txtComb = findObj(combId);		
	txtNumTaken.value = stakeTxtBx.value/txtComb.value;//FormatAsMoney(stakeTxtBx.value/txtComb.value);		
}

//-->
