﻿//Show and hide extended content automatically onload and page resize
function LowResMode() {
    var widthPage = document.documentElement.clientWidth;
    var widthPanel = 1024 + 120;
    var checked = parent.document.URL.indexOf('?LowRes')

    if (widthPage < widthPanel && checked == -1 && parent.document.URL.toLowerCase().indexOf('bet.aspx') > -1) {
        __doPostBack('LowRes', '');
    }
    else if (widthPage > widthPanel && checked != -1 && parent.document.URL.toLowerCase().indexOf('bet.aspx') > -1) {
        __doPostBack('NoLowRes', '');
    }
}


//fades layer in and out effects
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac3 = 100;

function opacIn(sourceid) {
    if (sourceid.length == 0)
        return;

    if (document.getElementById(sourceid) == null)
        return;
                
    if (opac3 > 40) {
        opac3 -= 20;
        if (ie5) document.getElementById(sourceid).filters.alpha.opacity = opac3;
        if (ns6) document.getElementById(sourceid).style.MozOpacity = opac3 / 100;
        setTimeout(function() { opacIn(sourceid) }, 5);
    } else {
        //calls opacOut() function, therefore creating the loop
        opacOut(sourceid);
    }

}

function opacOut(sourceid) {
    if (sourceid.length == 0)
        return;

    if (document.getElementById(sourceid) == null)
        return;

    if (opac3 < 100) {
        opac3 += 20;
        if (ie5) document.getElementById(sourceid).filters.alpha.opacity = opac3;
        if (ns6) document.getElementById(sourceid).style.MozOpacity = opac3 / 100;
        setTimeout(function() { opacOut(sourceid) }, 5);
    } else {
        // opacIn();
    }
}

//submit stake
function SubmitStake(source, value, e) {
    var characterCode;

    if (e && e.which) { //if which property of event object is supported (NN4)
        e = e
        characterCode = e.which //character code is contained in NN4's which property
    }
    else {
        e = event
        characterCode = e.keyCode //character code is contained in IE's keyCode property
    }

    if (characterCode == 13 && value.length > 0) {
        __doPostBack("txtBetAmount", "");
        return false;
    }
    return true;
}

//calculate possible winning
function WinCalc(sender, e) {

    if (e && e.which) { //if which property of event object is supported (NN4)
        e = e
        characterCode = e.which //character code is contained in NN4's which property
    }
    else {
        e = event
        characterCode = e.keyCode //character code is contained in IE's keyCode property
    }

    var quote = parseFloat(document.getElementsByName('ctl00$cphSiteContent$txtBetQuote')[0].value.replace(",", "."));
    sender.value = sender.value.replace("€ ", "");
    var betValue = sender.value;
    var result = (quote * betValue.replace(",", "."));
    document.getElementById('ctl00_cphSiteContent_txtBetTotalWin').value = "€ " + (quote * betValue.replace(",", ".")).toFixed(2); //.toFixed(2);
    
    if (!(characterCode == 8 && sender.value.replace("€ ", "").length == 0)) {
        sender.value = "€ " + sender.value.replace("€ ", "");
    }
            
}

function PrintPage() {
    window.print();
}

function HideMessage(id1, id2) {
    document.getElementById(id1).style.visibility = "hidden";
    document.getElementById(id2).style.visibility = "hidden";
}