// version 0.05 13.02.2009
function openWin(sourceFile, winWidth, winHeight, xPos, yPos) {
    posStr = "";
    if (typeof(xPos) != 'undefined' && typeof(yPos) != 'undefined') {
        var posStr = ",left=" + xPos + ",top=" + yPos;
    }
    if (document.all) window.open(sourceFile, "PopUp", "height=" + (winHeight) + ",width=" + (winWidth) + ",innerWidth=" + winWidth + ",innerHeight=" + winHeight + posStr + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
    else window.open(sourceFile, "PopUp", "innerWidth=" + (winWidth) + ",innerHeight=" + (winHeight) + posStr + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

function openNamedPopUp(popupName, sourceFile, xPos, yPos, winWidth, winHeight, scrollbars) {
    if (document.all) window.open(sourceFile, popupName, "height=" + (winHeight) + ",width=" + (winWidth) + ",scrollbars=" + scrollbars + ",innerWidth=" + winWidth + ",innerHeight=" + winHeight + ",left=" + xPos + ",top=" + yPos + ",toolbar=no,location=no,status=no,menubar=no,resizable=no");
    else window.open(sourceFile, popupName, "innerWidth=" + (winWidth) + ",innerHeight=" + (winHeight) + ",left=" + (xPos) + ",top=" + (yPos) + ",scrollbars=" + scrollbars + ",toolbar=no,location=no,status=no,menubar=no,resizable=no");
}

function changeImgSrc(tag, filename) {
    if (tag != null) {
        var currentTagSrc = tag.src;
        var path = "";
        var idx = currentTagSrc.lastIndexOf("/");
        if (idx != -1 && filename.charAt(0) != '/') {
            path = currentTagSrc.substring(0, idx) + "/";
        }
        tag.src = path + filename;
    }
}

function sendForm(formname, command) {
    document.forms[formname].elements['command'].value = command;
    document.forms[formname].submit();
    return false;
}

function preloadImages() {
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i,j = d.MM_p.length,a = preloadImages.arguments;
        for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) {
                d.MM_p[j] = new Image;
                d.MM_p[j++].src = a[i];
            }
    }
}

function submitFormWithReturn(e, formname) {
    var key;
    if (window.event)
        key = window.event.keyCode;//IE
    else
        key = e.which; //FireFox
    if (key == 13) {
        document.forms[formname].submit();
    }
}

function isAcrobatInstalled() {
    var acrobat = new Object();
    // Set some base values
    acrobat.installed = false;
    acrobat.version = '0.0';

    if (navigator.plugins && navigator.plugins.length)
    {
        for (x = 0; x < navigator.plugins.length; x++)
        {
            if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
            {
                acrobat.version = parseFloat(navigator.plugins[x].description.split('Version ')[1]);

                if (acrobat.version.toString().length == 1) acrobat.version += '.0';

                acrobat.installed = true;
                break;
            } else if (navigator.plugins[x].description.indexOf('Adobe') != -1) {
                acrobat.installed = true;
                break;
            }
        }
    }
    else if (window.ActiveXObject)
    {
        for (var x = 2; x < 10; x++) {
            try {
                var oAcro = new ActiveXObject('PDF.PdfCtrl.' + x);
                if (oAcro) {
                    acrobat.installed = true;
                    acrobat.version = x + '.0';
                }
            } catch(e) {
            }
        }

        try {
            var oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');
            if (oAcro4) {
                acrobat.installed = true;
                acrobat.version = '4.0';
            }
        } catch(e) {
        }

        try {
            var oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
            if (oAcro7) {
                acrobat.installed = true;
                acrobat.version = '7.0';
            }
        } catch(e) {
        }
    }

    acrobat.ver4 = (acrobat.installed && parseInt(acrobat.version) >= 4);
    acrobat.ver5 = (acrobat.installed && parseInt(acrobat.version) >= 5);
    acrobat.ver6 = (acrobat.installed && parseInt(acrobat.version) >= 6);
    acrobat.ver7 = (acrobat.installed && parseInt(acrobat.version) >= 7);
    acrobat.ver8 = (acrobat.installed && parseInt(acrobat.version) >= 8);
    acrobat.ver9 = (acrobat.installed && parseInt(acrobat.version) >= 9);
    return acrobat.installed;
}

function checkAcrobat(actionString, smallWindow) {
    var height = smallWindow ? 400 : 600;
    var width = smallWindow ? 400 : 800;
    if (isAcrobatInstalled()) {
        openCentered(actionString, width, height);
    } else {
        width = 400;
        height = 200;
        openCentered("/history/acrobatversion.do", width, height);
    }
}

function checkedPdfDownload(url, obj) {
    if (obj != null) {
        if (isAcrobatInstalled()) {
            obj.href = url;
        } else {
            obj.href = "#";
            var width = 400;
            var height = 200;
            openCentered("/history/acrobatversion.do", width, height);
        }
    }
}

function disableOrig(id) {
    try {
        var doc = opener.document;
        var el = doc.getElementById('origlink' + id);
        el.parentNode.className = "textLinkInactive";
        el.onclick = "";
        el.style.color = "#868686";
    } catch (e) {
    }
}

function openCentered4(url, width, height, scrollbars) {
    var leftPos = (screen.width - width) / 2;
    var topPos = (screen.height - height) / 2;
    window.open(url, "swisslos", "width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + ",menubar=no,status=no,toolbar=no,scrollbars=" + scrollbars);
}

function openCentered3(url, width, height) {
    var leftPos = (screen.width - width) / 2;
    var topPos = (screen.height - height) / 2;
    window.open(url, "swisslos", "width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + ",menubar=no,status=no,toolbar=no");
}

function openCentered2(actionString, smallWindow) {
    var height = smallWindow ? 400 : 600;
    var width = smallWindow ? 400 : 800;
    openCentered3(actionString, width, height);
}

function openCentered() {
    if (arguments.length == 4) {
        openCentered4(arguments[0],arguments[1],arguments[2],arguments[3]);
    } else if (arguments.length == 3) {
        openCentered3(arguments[0],arguments[1],arguments[2]);
    } else {
        openCentered2(arguments[0],arguments[1]);
    }

}

function popupCentered(popupName, page, height, width)
{
    var newwindow;
    var leftPos = (screen.width - width) / 2;
    var topPos = (screen.height - height) / 2;
    newwindow = window.open(page, popupName, "height=" + height + ",width=" + width + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=no,resizable=no");
    if (window.focus) {
        newwindow.focus()
    }
}

function changeBalanceAmount(amount) {
    document.getElementById("balanceAmount").innerHTML = amount;
}

function changeBalanceAmount(amount, promotion) {

    document.getElementById("balanceAmount").innerHTML = amount;
    
    var promotionAmount = document.getElementById("promotionAmount");
    if(promotionAmount != null){
    	promotionAmount.innerHTML = promotion;
    }
}

function selfblockhide() {
    document.getElementById('selfblockinfobox').style.visibility = "hidden";
}

function selfblockshow(e, txt, offsetX, offsetY) {
    var PositionX = 0;
    var PositionY = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
    {
        PositionX = e.pageX;
        PositionY = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
        PositionX = e.clientX + document.body.scrollLeft;
        PositionY = e.clientY + document.body.scrollTop;
    }

    document.getElementById("selfblockinfotext").innerHTML = txt;
    document.getElementById('selfblockinfobox').style.left = (235) + 'px';
    document.getElementById('selfblockinfobox').style.top = (PositionY) + 'px';
    document.getElementById('selfblockinfobox').style.visibility = "visible";
}

