function show( objName )
{
  var o = document.getElementById( objName );
  o.style.display = ( o.style.display == 'none' ) ? '' : 'none';
}
function bet( sportP, leagueP, oidP )
{
  formObj = document.forms.betform;
  formObj.sport.value = sportP;
  formObj.league.value = leagueP;
  formObj.oid.value = oidP;
  formObj.submit();
}

function bet2( sportP, leagueP, oidP )
{
  formObj                                 = document.forms.betform;
  formObj.action                          = actionUrl;
  document.getElementById("formDo").value = "login";
  formObj.sport.value                     = sportP;
  formObj.league.value                    = leagueP;
  formObj.oid.value                       = oidP;
  formObj.submit();
}


function round(variable)
{
		t_variable = variable + '';
    if (t_variable.match(/^[1-9]([0-9])*$/))
		{
			t_variable += '.00';
			return t_variable;
		}
    if (t_variable.match(/^[1-9]([0-9])*\.$/))
		{
			t_variable += '00';
			return t_variable;
		}
    if (t_variable.match(/^[1-9]([0-9])*\.[0-9]{1}$/))
		{
			t_variable += '0';
			return t_variable;
		}

    var test_adding = '';
    var test_preadding = '';

    var value_string = '';
    value_string +=  variable;

    start_position = value_string.indexOf('.');
    if (start_position == -1)
    {
        return variable;
    }
    else
    {
        new_value = value_string.substr(0, start_position+3);
        test_adding = parseInt(value_string.substring(start_position+3, start_position+4));
        last_digit = parseInt(value_string.substring(start_position+2, start_position+3));
        first_digit = parseInt(value_string.substring(start_position+1, start_position+2));
        integer_part = parseInt(value_string.substr(0, start_position));

        if (test_adding >= 5)
        {
            if (last_digit != 9){ last_digit += 1;}
            else
            {
                last_digit = 0;
                if (first_digit != 9){ first_digit += 1;}
                else
                {
                    first_digit = 0;
                    integer_part += 1;
                }
            }
        }
        new_value = '' + integer_part + '.' + first_digit + last_digit;

        if (new_value.match(/^[1-9]([0-9])*$/))           new_value += '.00';
        if (new_value.match(/^[1-9]([0-9])*\.$/))         new_value += '00';
        if (new_value.match(/^[1-9]([0-9])*\.[0-9]{1}$/)) new_value += '0';

				return new_value;
    }
}


function getMaxWin(maxKoef, stakeValue)
{
	return round(round(maxKoef) * round(stakeValue));

}

function calcmw(formObj)
{
	var stakeObj = formObj.stake;
	maxCoef = parseFloat( document.getElementById( "oddval" ).value );

	if ( stakeObj.value == '' )
	{
		return;
	}

	var maxWinObj = document.getElementById("maxwin");

	var sv = stakeObj.value;
	if ( !sv.match(/^[1-9][0-9]*(\.[0-9]{1,2})?$/) )
	{
		alert (SCRIPTS_BET_HINT1);
	}

	newVal = getMaxWin(maxCoef, sv);
	if ( newVal != "NaN" )
  {
	  maxWinObj.value = newVal;
  }
}

function showAccDetails(){
    if($("#moreDetails").length){
        if($("#moreDetails").css("display")=="table"){
            $("#moreDetails").hide();
        }else{
            $("#moreDetails").show();
        }
    }
}

