﻿var Mackolik = Mackolik || {};
Mackolik.Coupon = {
    iddaaLink: APP_ROOT + "/iddaa-Programi",
    imagePath: IMG_PATH,
    SEND: USR_APP_ROOT + "/Bilyoner/CouponSend.aspx",
    couponCreatorId: 2,
    seperator: '*',
    cookieManager: new Mackolik.CookieManager("mackolik_coupon", 1, '/', '', '~'),
    ekstraCookieManager: new Mackolik.CookieManager("mackolik_coupon2", 1, '/', '', '~'),
    openedCookieManager: new Mackolik.CookieManager("mackolik_copen", 1, '/', '', '~'),
    couponFaceInitialized: false,
    couponTimer: 0,
    controlArray: new Array(),
    selTeamArray: new Array(),
    gameTypeArray: new Array(),
    couponHashmap: new Object(),
    systemHashmap: new Object(),
    totalBet: 1,
    userName: "",
    userRefId: "",
    topofset: 0,
    oldscrolltop: 0,
    lastUpdateTimeValue: 0,
    checkUpdatePeriod: 5000,

    addToCoupon: function(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2) {
        window.open("http://run.admost.com/adx/goto.ashx?pbk=4629-4048-958&redir=" + escape("http://www.tuttur.com/landing/?refid=aac1dba2-7945-45ed-813f-a06cc391dec9&iddaa=" + iddaaId));
        return;
        if (type != "H") {
            h1 = 0;
            h2 = 0;
        }
        var cookie = this.getCoupons();
        if (cookie && cookie.length == 15) {
            alert("En fazla 15 maç seçebilirsiniz.");
            if (this.couponFaceInitialized) { YAHOO.mackolik.container.kuponpanel.show(); }
            return;
        }

        if (this.couponFaceInitialized) {
            this.addToHashmaps(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2, true);
            this.repaintCouponFace();
        } else {
            YAHOO.mackolik.container.kuponpanel.show();
        }
    },
    getCoupons: function() {
        var coupons = [];
        var cookie = this.cookieManager.get_Cookie();
        if (!cookie) {
            return null;
        }
        var cookie_array = cookie.split('~');
        for (var i = 0; i < cookie_array.length; i++) {
            coupons.push(cookie_array[i].split(this.seperator));
        }
        return coupons;
    },
    deleteCoupon: function() {
        this.cookieManager.delete_Cookie();
        this.initializeHashmaps();
        this.updateLastUpdate();
    },
    deleteCouponMatch: function(iddaaId) {
        var cookie = this.getCoupons();
        if (cookie && cookie.length > 0) {
            for (var i = 0; i < cookie.length; i++) {
                if (cookie[i][0] == iddaaId) {
                    this.deleteCurrentHashmap(iddaaId, cookie[i][6]);
                    cookie.remove(i);
                    i = i - 1;
                }
            }
        }
        this.createCouponCookie(cookie);
        this.calculateSystemCount();
    },
    updateLastUpdate: function() {
        var timeValue = this.getTimeValue();
        this.ekstraCookieManager.set_Cookie(timeValue);
        this.lastUpdateTimeValue = timeValue;
    },
    getTimeValue: function() {
        var time = new Date();
        var timeValue = time.getMonth() * 1000 * 61 * 61 * 25 * 32 + time.getDate() * 1000 * 61 * 61 * 25 + time.getHours() * 1000 * 61 * 61 + time.getMinutes() * 1000 * 61 + time.getSeconds() * 1000 + time.getMilliseconds();
        return timeValue;
    },
    checkCookieChanged: function() {
        var cookie = this.ekstraCookieManager.get_Cookie();

        if (!cookie || cookie * 1 > this.lastUpdateTimeValue * 1) {
            this.initializeHashmaps();
            this.repaintCouponFace();
            this.lastUpdateTimeValue = this.getTimeValue();
        } else {
            clearTimeout(this.couponTimer);
            this.couponTimer = setTimeout("Mackolik.Coupon.checkCookieChanged()", this.checkUpdatePeriod);
        }
    },
    createCouponCookie: function(cookieArray) {
        var cookieString = '';
        var cookieStringArray = [];
        if (cookieArray && cookieArray.length > 0) {
            for (var i = 0; i < cookieArray.length; i++) {
                cookieStringArray.push(cookieArray[i].join(this.seperator));
            }
            cookieString = cookieStringArray.join('~');
        }

        this.cookieManager.set_Cookie(cookieString);
        this.updateLastUpdate();
    },
    initializeCouponFace: function(clickerId, containerId) {
        YAHOO.namespace("mackolik.container");
        YAHOO.mackolik.container.kuponpanel = new YAHOO.widget.Panel("kuponpanel", { width: "400px", visible: false, draggable: true, close: true, underlay: "shadow", zIndex: "99999" });
        YAHOO.mackolik.container.kuponpanel.setHeader("<div style=\"font-family: Verdana; font-size: 13px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KUPONUM</div>");
        YAHOO.mackolik.container.kuponpanel.setBody(Mackolik.Coupon.getCouponInnerHTML());
        YAHOO.mackolik.container.kuponpanel.setFooter(Mackolik.Coupon.getFooter());
        YAHOO.mackolik.container.kuponpanel.render(containerId);
        YAHOO.util.Event.addListener(clickerId, "click", Mackolik.Coupon.repaintCouponFace, YAHOO.mackolik.container.kuponpanel, true);
        YAHOO.mackolik.container.kuponpanel.subscribe("hide", function() { Mackolik.Coupon.openedCookieManager.set_Cookie("0"); clearTimeout(Mackolik.Coupon.couponTimer); });
        Mackolik.Coupon.couponFaceInitialized = true;
        Mackolik.Coupon.initializeHashmaps();
        Mackolik.Coupon.oldscrolltop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
        Mackolik.Coupon.lastUpdateTimeValue = Mackolik.Coupon.getTimeValue();

        var opened = this.openedCookieManager.get_Cookie();
        if (opened == null || opened == "0") {
            YAHOO.mackolik.container.kuponpanel.show();
            YAHOO.mackolik.container.kuponpanel.hide();
        } else {
            Mackolik.Coupon.repaintCouponFace();
        }

        if (window.onscroll != null) {
            var avoldOnscroll = window.onscroll;
            window.onscroll = function(e) {
                avoldOnscroll(e);
                Mackolik.Coupon.onScroll();
            };
        } else {
            window.onscroll = Mackolik.Coupon.onScroll;
        }

    },
    onScroll: function() {
        var dif = Math.max(document.body.scrollTop, document.documentElement.scrollTop) - Mackolik.Coupon.oldscrolltop;
        document.getElementById("kuponpanel_c").style.top = (document.getElementById("kuponpanel_c").offsetTop + dif) + "px";
        Mackolik.Coupon.oldscrolltop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
    },
    initializeHashmaps: function() {
        this.controlArray = new Array();
        this.selTeamArray = new Array();
        this.gameTypeArray = new Array();
        this.couponHashmap = new Object();
        this.systemHashmap = new Object();
        this.totalBet = 1;

        var couponArray = this.getCoupons();
        var sbCoupon = new StringBuilder();

        if (!couponArray || couponArray.length <= 0) {
            this.initValidation(0);
            return;
        }

        for (var i = 0; i < couponArray.length; i++) {
            var coupon = couponArray[i];
            var type = coupon[2];
            var iddaaId = coupon[0];
            var oran = coupon[1];
            var tahmin = coupon[3];
            var takim1 = coupon[4];
            var takim2 = coupon[5];
            var macId = coupon[6];
            var takim1Id = coupon[7];
            var takim2Id = coupon[8];
            var mbs = coupon[9];
            var h1 = coupon[10];
            var h2 = coupon[11];
            this.addToHashmaps(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2, false);
        }

        this.calculateSystemCount();
    },
    repaintCouponFace: function() {
        if (!Mackolik.Coupon.couponFaceInitialized) {
            return;
        }
        Mackolik.Coupon.openedCookieManager.set_Cookie("1");
        YAHOO.mackolik.container.kuponpanel.setBody(Mackolik.Coupon.getCouponInnerHTML());
        clearTimeout(this.couponTimer);
        this.couponTimer = setTimeout("Mackolik.Coupon.checkCookieChanged()", this.checkUpdatePeriod);
        Mackolik.Coupon.calculateSystemCount();
        YAHOO.mackolik.container.kuponpanel.show();
    },
    getCouponInnerHTML: function() {
        var sbCoupon = new StringBuilder();
        var data = Mackolik.Coupon.getCoupons();
        var addedItems = new Array();

        if (!data) {
            sbCoupon.append('<table width="100%" cellspacing=0 cellpadding=1 border=1 style="border-collapse:collapse;border-color:#cccccc;" id="tblCoupon">');
            sbCoupon.append('<tr class="puan_header bg2" height=18 align=center><td style="color:#BB0000;">Kupon oluşturmak için oranlara tıklayınız.</td></tr>');
            sbCoupon.append('</table>');
            return sbCoupon;
        }
        var header = '<table width="100%" cellspacing=0 cellpadding=1 border=1 style="border-collapse:collapse;border-color:#cccccc;" id="tblCoupon">';
        var headerRow = '<tr align=center class="puan_header bg2"><td title="Banko">B</td><td>Kod</td><td>MBS</td><td>H1</td><td>Maç</td><td>H2</td><td title="Oyun">O</td><td title="Tahmin">T</td><td>Oran</td><td><img src="' + this.imagePath + '/sil-buton.gif" style="cursor:pointer;" onclick="Mackolik.Coupon.deleteCoupon();Mackolik.Coupon.repaintCouponFace();"></td></tr>';
        var columns = '<colgroup><col width=9 /><col width=26 /><col width=26 /><col width=16 /><col width=170 /><col width=16 /><col width=24 /><col width=24 /><col width=34 /><col width=19 /></colgroup>';
        var rowFormat = '<tr class="alt{10}" align="center"><td><input type="checkbox" style="margin:-2px;" id="bankochk" name="bankochk" {13} onclick="Mackolik.Coupon.setBanko({0}, this);"/></td><td><b><a href="javascript:popComparison({6})">{0}</a></b></td><td>{9}</td><td>{11}</td><td align=left nowrap><a title="{1}" href="javascript:popTeam({7});">{14}</a> - <a title="{2}" href="javascript:popTeam({8});">{15}</a></td><td>{12}</td><td><img src="' + this.imagePath + '/{3}.gif"/></td><td><span id="selTeam{0}">{4}</span></td><td><span id=\"oran{0}\">{5}</span></td><td><a href="javascript:Mackolik.Coupon.deleteCouponMatch({0});Mackolik.Coupon.repaintCouponFace();"><img src="' + this.imagePath + '/sil-2.gif"/></td></tr>';
        // 0: Kod, 1: Takim1, 2: Takim2, 3: Oyun, 4: Tahmin, 5: Oran, 6: MBS

        var total = 1;
        var i = 0;
        sbCoupon.append(header);
        sbCoupon.append(columns);
        sbCoupon.append(headerRow);

        for (e in this.couponHashmap) {
            var tahminString = this.couponHashmap[e].selTeam;
            if (this.couponHashmap[e].gameType == "AU") {
                tahminString = (tahminString == 1) ? "Alt" : "Üst";
            }
            if (this.couponHashmap[e].gameType == 'MS' && this.couponHashmap[e].bet1 != '') {
                sbCoupon.appendFormat(rowFormat, this.couponHashmap[e].id, this.couponHashmap[e].team1, this.couponHashmap[e].team2, this.couponHashmap[e].gameType, this.couponHashmap[e].selTeam + "/" + this.couponHashmap[e].selTeam1, this.couponHashmap[e].bet + "/" + this.couponHashmap[e].bet1, this.couponHashmap[e].matchId, this.couponHashmap[e].team1Id, this.couponHashmap[e].team2Id, this.couponHashmap[e].mbs, (i % 2) + 1, this.couponHashmap[e].h1 == 0 ? "&nbsp;" : this.couponHashmap[e].h1, this.couponHashmap[e].h2 == 0 ? "&nbsp;" : this.couponHashmap[e].h2, this.couponHashmap[e].banko == 1 ? "CHECKED" : "", this.getMatchTeamName(this.couponHashmap[e].team1, this.couponHashmap[e].team2), this.getMatchTeamName(this.couponHashmap[e].team2, this.couponHashmap[e].team1));
            }
            else {
                sbCoupon.appendFormat(rowFormat, this.couponHashmap[e].id, this.couponHashmap[e].team1, this.couponHashmap[e].team2, this.couponHashmap[e].gameType, tahminString, this.couponHashmap[e].bet, this.couponHashmap[e].matchId, this.couponHashmap[e].team1Id, this.couponHashmap[e].team2Id, this.couponHashmap[e].mbs, (i % 2) + 1, this.couponHashmap[e].h1 == 0 ? "&nbsp;" : this.couponHashmap[e].h1, this.couponHashmap[e].h2 == 0 ? "&nbsp;" : this.couponHashmap[e].h2, this.couponHashmap[e].banko == 1 ? "CHECKED" : "", this.getMatchTeamName(this.couponHashmap[e].team1, this.couponHashmap[e].team2), this.getMatchTeamName(this.couponHashmap[e].team2, this.couponHashmap[e].team1));
            }
            i++;
        }
        this.recalculateBet();
        sbCoupon.appendFormat('<tr class="puan_header bg2"><td colspan=7 align=right>Toplam Oran:</td><td colspan=\"2\" align=right><span id="totalBet" style="font-weight:bold">{0}</span></td></tr>', this.formatValue(this.totalBet, 2));
        sbCoupon.append('</table>');
        return sbCoupon;
    },
    getMatchTeamName: function(currentteam, opponent) {
        var fixParameter = 8; // Takım ismi bu uzunlukta ya da kucukse hepsini goster
        var maxTotal = 20; // Toplam bunun ustune cikma

        var totalLength = currentteam.length + opponent.length;
        if (totalLength <= maxTotal) {
            return currentteam;
        }
        var calculatedlength;
        if (currentteam.length > fixParameter && opponent.length > fixParameter) {
            calculatedlength = Math.round((currentteam.length / totalLength) * maxTotal);
        } else if (currentteam.length <= fixParameter) {
            calculatedlength = currentteam.length;
        } else {
            calculatedlength = maxTotal - opponent.length;
        }

        return currentteam.substring(0, calculatedlength);

    },
    getFooter: function() {
        var sbCouponFooter = new StringBuilder();
        sbCouponFooter.append('<table width="100%" cellpadding=0 cellspacing=0 class="rowData" id="systemtable"><tr><td class="v9px"><font color="#ff6600" style="margin-left: 4px;font-weight:bold;">Sistem :</font></td></tr><tr><td><table class="couponsystemtbl"><tr><td id="systemtd1"><input type="checkbox" id="system1" value="1" onclick="Mackolik.Coupon.setSystem(this);">1</td><td id="systemtd2"><input type="checkbox" id="system2" value="2" onclick="Mackolik.Coupon.setSystem(this);">2</td><td id="systemtd3"><input type="checkbox" id="system3" value="3" onclick="Mackolik.Coupon.setSystem(this);">3</td><td id="systemtd4"><input type="checkbox" id="system4" value="4" onclick="Mackolik.Coupon.setSystem(this);">4</td><td id="systemtd5"><input type="checkbox" id="system5" value="5" onclick="Mackolik.Coupon.setSystem(this);">5</td><td id="systemtd6"><input type="checkbox" id="system6" value="6" onclick="Mackolik.Coupon.setSystem(this);">6</td><td id="systemtd7"><input type="checkbox" id="system7" value="7" onclick="Mackolik.Coupon.setSystem(this);">7</td><td id="systemtd8"><input type="checkbox" id="system8" value="8" onclick="Mackolik.Coupon.setSystem(this);">8</td><td id="systemtd9"><input type="checkbox" id="system9" value="9" onclick="Mackolik.Coupon.setSystem(this);">9</td><td id="systemtd10"><input type="checkbox" id="system10" value="10" onclick="Mackolik.Coupon.setSystem(this);">10</td><td id="systemtd11"><input type="checkbox" id="system11" value="11" onclick="Mackolik.Coupon.setSystem(this);">11</td><td id="systemtd12"><input type="checkbox" id="system12" value="12" onclick="Mackolik.Coupon.setSystem(this);">12</td><td id="systemtd13"><input type="checkbox" id="system13" value="13" onclick="Mackolik.Coupon.setSystem(this);">13</td><td id="systemtd14"><input type="checkbox" id="system14" value="14" onclick="Mackolik.Coupon.setSystem(this);">14</td><td id="systemtd15"><input type="checkbox" id="system15" value="15" onclick="Mackolik.Coupon.setSystem(this);">15</td></tr></table></td></tr></table>');
        sbCouponFooter.append('<table width="100%" class="rowData"><tr><td colspan="3" class="v9px"><b>Misli : </b><select name="multiplier" id="multiplier" onchange="Mackolik.Coupon.initValidation(0);" class="formSelect th11 fntBold" size="1"><option value="1"> 1  </option><option value="2"> 2   </option><option value="3"> 3  </option><option value="4"> 4   </option><option value="5"> 5   </option><option value="6"> 6  </option><option value="7"> 7   </option><option value="8"> 8   </option><option value="10"> 10  </option><option value="12"> 12   </option><option value="14"> 14   </option><option value="15"> 15    </option><option value="18"> 18   </option><option value="20"> 20   </option><option value="21"> 21  </option><option value="24"> 24   </option><option value="28"> 28   </option><option value="30"> 30  </option><option value="35"> 35   </option><option value="36"> 36   </option><option value="40"> 40   </option><option value="42"> 42  </option><option value="48"> 48  </option><option value="50"> 50  </option><option value="56"> 56  </option><option value="60"> 60  </option><option value="70"> 70   </option><option value="72"> 72  </option><option value="80"> 80  </option><option value="84"> 84  </option><option value="90"> 90  </option><option value="100"> 100  </option><option value="105"> 105  </option><option value="120"> 120  </option><option value="126"> 126  </option><option value="140"> 140  </option><option value="144"> 144  </option><option value="150"> 150  </option><option value="160"> 160  </option><option value="168"> 168  </option><option value="180"> 180  </option><option value="200"> 200  </option><option value="210"> 210  </option><option value="240"> 240  </option><option value="250"> 250  </option><option value="252"> 252  </option><option value="280"> 280  </option><option value="300"> 300  </option><option value="320"> 320  </option><option value="336"> 336  </option><option value="350"> 350  </option><option value="400"> 400  </option><option value="420"> 420  </option><option value="480"> 480  </option><option value="500"> 500  </option><option value="504"> 504  </option><option value="540"> 540  </option><option value="560"> 560  </option><option value="600"> 600  </option><option value="630"> 630  </option><option value="700"> 700  </option><option value="720"> 720  </option><option value="750"> 750  </option><option value="800"> 800  </option><option value="840"> 840  </option><option value="960"> 960  </option></select></td></tr><tr><td class="v9px"><b>Kolon Sayısı :</b><br><input type="text" disabled id="couponNum" class="kupon-inpt" style="color:#000000;background-color:#DCE3E9;text-align:right;width:100px;"></td><td class="v9px"><b>Kupon Bedeli (TL):</b><br><input type="text" disabled id="couponValue" class="kupon-inpt" style="color:#000000;background-color:#DCE3E9;text-align:right;width:100px;"></td><td class="v9px"><b>Maksimum Kazanç (TL):</b><br><input type="text" disabled id="maximumGain" class="kupon-inpt" style="color:#000000;background-color:#DCE3E9;text-align:right"><input type="hidden" name="userName" id="userName" /><input type="hidden" name="refId" id="refId" /><input type="hidden" name="url" id="url"></td></tr>');
        sbCouponFooter.append("<tr><td colspan=\"3\"><img src=\"" + this.imagePath + "/kuponumoyna.gif\" id=\"createCoupon\" style=\"float:left;cursor:pointer;\" onclick=\"Mackolik.Coupon.SendToBilyoner()\"><div style=\"width:200px; float:right;\"><a href=\"" + this.iddaaLink + "\"><b>İddaa Programı için tıklayınız.</b></a></div></td></tr></table>");
        return sbCouponFooter;
    },
    prepareAddCouponLink: function(iddaaId, oran, oyun, tahmin, takim1, takim2, match_id, takim1Id, takim2Id, minmatch, handikap1, handikap2, macDurum) {
        var couponLink = new StringBuilder();

        // Tuttur
        //couponLink.append(oran);
        couponLink.append("<a href=\"http://run.admost.com/adx/goto.ashx?pbk=4629-4048-958&redir=" + escape("http://www.tuttur.com/landing/?refid=aac1dba2-7945-45ed-813f-a06cc391dec9&iddaa=" + iddaaId) + "\" target=\"_blank\" >" + oran + "</a>");
        return couponLink;
        // Tuttur

        if (macDurum == 0) {
            couponLink.append("<a href=\"javascript:Mackolik.Coupon.addToCoupon('" + iddaaId + "'");
            couponLink.append(",'" + oran + "'");
            couponLink.append(",'" + oyun + "'");
            couponLink.append(",'" + tahmin + "'");
            couponLink.append(",'" + takim1 + "'");
            couponLink.append(",'" + takim2 + "'");
            couponLink.append("," + match_id);
            couponLink.append("," + takim1Id);
            couponLink.append("," + takim2Id);
            couponLink.append("," + (minmatch == '' ? 4 : minmatch));
            couponLink.append(",'" + handikap1 + "'");
            couponLink.append(",'" + handikap2 + "')\">");
            couponLink.append(oran + "</a>");
        } else {
            couponLink.append(oran);
        }
        return couponLink;
    },
    addToHashmaps: function(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2, addcookie) {
        if (this.rowControl(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2, addcookie)) {
            this.controlArray[macId] = iddaaId;
            this.selTeamArray[iddaaId] = tahmin;
            this.gameTypeArray[iddaaId] = type;
            this.couponHashmap[iddaaId] = new this.CouponRow(iddaaId, oran, type, tahmin, 0, mbs, "", "", "", h1, h2, macId, takim1Id, takim2Id, takim1, takim2);
            this.couponHashmap[iddaaId].matchStr = takim1 + "-" + takim2;
            this.calculateSystemCount();
            this.initValidation(0);
            return true;
        } else {
            return false;
        }
    },
    setSystem: function(systemObj) {
        if (systemObj.checked) {
            this.systemHashmap[systemObj.value] = systemObj.value;
        }
        else {
            delete this.systemHashmap[systemObj.value];
        }

        this.initValidation(0)
    },
    setBanko: function(bIddaaId, chObj) {
        if (chObj.checked) {
            this.couponHashmap[bIddaaId].banko = 1;
        }
        else {
            this.couponHashmap[bIddaaId].banko = 0;
        }

        this.calculateSystemCount();
        this.initValidation(0)
    },
    recalculateBet: function() {
        var retVal = 1;
        for (e in this.couponHashmap) {
            if (this.couponHashmap[e].bet1.length > 0 && this.couponHashmap[e].bet1 * 1 > this.couponHashmap[e].bet * 1) {
                retVal = retVal * this.couponHashmap[e].bet1;
            } else {
                retVal = retVal * this.couponHashmap[e].bet
            }
        }
        this.totalBet = retVal
        var totalBetObj = document.getElementById("totalBet");
        if (totalBetObj) {
            totalBetObj.innerHTML = this.formatValue(this.totalBet, 2);
        }

    },
    calculateSystemCount: function() {
        var bankocount = 0;
        var maxmbs = 0;
        var couponcount = 0;
        var showsystem = false;
        for (e in this.couponHashmap) {
            if (this.couponHashmap[e].banko == 1) {
                bankocount = bankocount + 1;
            }
            if (this.couponHashmap[e].mbs > maxmbs) {
                maxmbs = this.couponHashmap[e].mbs;
            }
            couponcount = couponcount + 1;
        }
        for (var i = 1; i < 16; i++) {
            if (i >= maxmbs - bankocount && i <= couponcount - bankocount) {
                document.getElementById("systemtd" + i).style.display = "";
                showsystem = true;
            } else {
                document.getElementById("systemtd" + i).style.display = "none";
                document.getElementById("system" + i).checked = false;
            }
        }
        if (showsystem) {
            document.getElementById("systemtable").style.display = "";
        } else {
            document.getElementById("systemtable").style.display = "none";
        }

    },
    deleteCurrentHashmap: function(sIddaaId, macId) {
        this.controlArray[macId] = undefined;
        this.selTeamArray[sIddaaId] = undefined;
        this.gameTypeArray[sIddaaId] = undefined;
        delete this.couponHashmap[sIddaaId];
        this.recalculateBet();
        this.initValidation(0);
    },
    rowControl: function(iddaaId, oran, type, tahmin, takim1, takim2, macId, takim1Id, takim2Id, mbs, h1, h2, addcookie) {
        if (this.controlArray[macId] == undefined) this.controlArray[macId] = -1;

        if (this.gameTypeArray[iddaaId] == undefined) this.gameTypeArray[iddaaId] = -1;
        if (this.gameTypeArray[iddaaId] == -1 || (this.gameTypeArray[iddaaId] == "MS" && type == "MS")) {
            if (this.selTeamArray[iddaaId] != tahmin && this.controlArray[macId] != -1 && this.controlArray[macId] != 3 && this.controlArray[macId] == iddaaId) {
                var k = 0;
                this.couponHashmap[iddaaId].selTeam1 = tahmin
                this.couponHashmap[iddaaId].bet1 = oran
                this.controlArray[macId] = 3
                this.selTeamArray[iddaaId] = tahmin
                if (addcookie) {
                    var cookie_value = iddaaId + this.seperator + oran + this.seperator + type + this.seperator + tahmin + this.seperator + takim1 + this.seperator + takim2 + this.seperator + macId + this.seperator + takim1Id + this.seperator + takim2Id + this.seperator + mbs + this.seperator + h1 + this.seperator + h2;
                    this.cookieManager.add_Cookie(cookie_value);
                    this.updateLastUpdate();
                }
                this.recalculateBet();
                this.initValidation(0);
                return false;
            }
            else if (this.controlArray[macId] != -1)
                return false;
        }
        else
            return false;

        if (addcookie) {
            var cookie_value = iddaaId + this.seperator + oran + this.seperator + type + this.seperator + tahmin + this.seperator + takim1 + this.seperator + takim2 + this.seperator + macId + this.seperator + takim1Id + this.seperator + takim2Id + this.seperator + mbs + this.seperator + h1 + this.seperator + h2;
            this.cookieManager.add_Cookie(cookie_value);
            this.updateLastUpdate();
        }
        this.recalculateBet();
        return true;
    },
    initValidation: function(isAlert) {
        var count = 0;
        var bCount = 0;
        var MStr = new Array();
        var MBSStr = new Array();
        var ORStr = new Array();
        var ORStr1 = new Array();
        var BStr = new Array();
        var SStr = new Array();
        var retVal = "";
        var validCouponNum = 0;
        var validTotalBet = 0;
        var validMaxBet = 0;
        var validationArray = new Array();
        var doubleMatchColumnNum = 1;
        var doubleMatchNum = 0;
        var bankoDoubleMatchNum = 0;

        for (e in this.couponHashmap) {
            MStr[count] = this.couponHashmap[e].id;
            MBSStr[count] = this.couponHashmap[e].mbs;
            ORStr[count] = this.couponHashmap[e].bet;
            ORStr1[count] = this.couponHashmap[e].bet1;
            if (this.couponHashmap[e].banko != 0) {
                BStr[bCount] = this.couponHashmap[e].id;
                bCount++;
            }
            if (this.couponHashmap[e].selTeam1 != undefined && this.couponHashmap[e].selTeam1.length > 0) {
                doubleMatchNum++;
                doubleMatchColumnNum = doubleMatchColumnNum * 2;
            }

            if (this.couponHashmap[e].banko != 0 && this.couponHashmap[e].selTeam1 != undefined && this.couponHashmap[e].selTeam1.length > 0) {
                bankoDoubleMatchNum++;
            }

            count++;
        }

        for (i = count; i < 15; i++) {
            MStr[i] = "0";
            MBSStr[i] = "0";
            ORStr[i] = "0";
            ORStr1[i] = "0";
            BStr[i] = "0";
        }

        for (i = bCount; i < 15; i++) {
            BStr[i] = "0";
        }
        count = 0

        for (e in this.systemHashmap) {
            SStr[count] = this.systemHashmap[e]
            count++;
        }

        for (i = count; i < 15; i++) {
            SStr[i] = "0";
        }

        retVal = this.ValidateCoupon(MStr, MBSStr, ORStr, BStr, SStr, doubleMatchColumnNum, doubleMatchNum, bankoDoubleMatchNum, bCount, ORStr1);

        var iMisli = 1;
        var misli = document.getElementById("multiplier");

        if (misli) {
            iMisli = parseInt(misli.value, 10);
        }

        if (retVal == "NOK") {
            document.getElementById("couponNum").value = "1"
            document.getElementById("couponValue").value = iMisli;
            document.getElementById("maximumGain").value = "1"; //this.formatValue(this.totalBet * iMisli, 2);
        }
        else {
            validationArray = retVal.split("-");
            document.getElementById("couponNum").value = validationArray[1];
            document.getElementById("couponValue").value = (parseInt(validationArray[1], 10) * iMisli);
            document.getElementById("maximumGain").value = this.formatValue(parseFloat(validationArray[2]) * iMisli, 2);
            if (document.getElementById("totalBet")) {
                document.getElementById("totalBet").innerHTML = this.formatValue(validationArray[3], 2);
            }
        }
        return retVal;
    },
    formatCurrency: function(num) {
        num = num.toString().replace(/\$|\,/g, '');
        if (isNaN(num))
            num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 100 + 0.50000000001);
        cents = num % 100;
        num = Math.floor(num / 100).toString();
        if (cents < 10)
            cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
            num = num.substring(0, num.length - (4 * i + 3)) + ',' +
	    num.substring(num.length - (4 * i + 3));
        return (((sign) ? '' : '-') + num + '.' + cents);
    },
    formatValue: function(decimalValue, decimalNum) {
        var retVal;
        retVal = Math.round(decimalValue * Math.pow(10, decimalNum)) / Math.pow(10, decimalNum);
        retVal = this.formatCurrency(retVal);
        return retVal
    },
    CouponRow: function(id, bet, gameType, selTeam, banko, mbs, selTeam1, bet1, matchStr, h1, h2, matchId, team1Id, team2Id, team1, team2) {
        this.id = id;
        this.bet = bet;
        this.gameType = gameType;
        this.selTeam = selTeam;
        this.banko = banko;
        this.mbs = mbs;
        this.selTeam1 = selTeam1;
        this.bet1 = bet1;
        this.matchStr = matchStr;
        this.h1 = h1;
        this.h2 = h2;
        this.matchId = matchId;
        this.team1Id = team1Id;
        this.team2Id = team2Id;
        this.team1 = team1;
        this.team2 = team2;
    },
    DoubleCouponRow: function(id, banko) {
        this.id = id;
        this.banko = banko;
    },

    INSTR: function(findStr, findStrPart, arg1, arg2) {
        if (findStr.indexOf(findStrPart) != -1)
            return true;
        else
            return false;
    },

    BIL_SK: function(pSayi1, pSayi2) {
        var retval = 0;
        var i = 0;
        var aRetNum, aPay, aPayda1, aPayda2, aTempSayi;

        if (pSayi1 <= 0 || pSayi2 <= 0 || pSayi1 > 15 || pSayi2 > 15 || pSayi1 < pSayi2)
            return 0

        if (pSayi2 == 0)
            return 0;

        aPay = 1;
        aPayda1 = 1;
        aPayda2 = 1;
        for (i = 1; i <= pSayi1; i++) {
            aPay = aPay * i;
        }
        for (i = 1; i <= pSayi2; i++) {
            aPayda1 = aPayda1 * i;
        }
        aTempSayi = pSayi1 - pSayi2;
        for (i = 1; i <= aTempSayi; i++) {
            aPayda2 = aPayda2 * i;
        }

        retval = aPay / (aPayda1 * aPayda2);

        return retval;
    },
    insertCouponParams: function(userOk) {
        var validationStr = "";
        var validationArray = "";
        var usr = "";
        var systemStr = "";
        var URLStr = "";
        var prmStr = "";
        var couponNum = 0;
        var tmpSysStr = "";
        var gameTypeStr = "";
        for (e in this.couponHashmap) {
            if (this.couponHashmap[e].gameType == "AU") {
                gameTypeStr = "UO";
            } else {
                gameTypeStr = this.couponHashmap[e].gameType;
            }
            prmStr = prmStr + this.couponHashmap[e].id + "|" + gameTypeStr + "|" + this.couponHashmap[e].selTeam + "|" + this.couponHashmap[e].bet + "|";
            prmStr = prmStr + this.couponHashmap[e].selTeam1 + "|" + this.couponHashmap[e].bet1 + "|" + this.couponHashmap[e].mbs + "|" + this.couponHashmap[e].banko + "$";
        }

        for (e in this.systemHashmap) {
            if (this.systemHashmap[e].length == 1)
                tmpSysStr = "0" + this.systemHashmap[e];
            else
                tmpSysStr = this.systemHashmap[e];
            systemStr = systemStr + tmpSysStr + "-";
        }

        systemStr = systemStr.substr(0, systemStr.length - 1, 1);
        validationStr = this.initValidation(1);
        if (validationStr != "NOK") {
            validationArray = validationStr.split("-");
            URLStr = "couponNum=" + validationArray[1];
            URLStr = URLStr + "&totalBet=" + this.formatValue(validationArray[2], 2);
            URLStr = URLStr + "&systemStr=" + systemStr;
            URLStr = URLStr + "&prmStr=" + escape(prmStr).replace(/\+/g, "%2B");
            if (userOk)
                URLStr = URLStr + "&usr=" + this.userName;

            maxbet = this.formatValue(validationArray[2], 2);
            return URLStr;
        }
        else {
            alert("Kuponunuz Hatalı");
            return null;
        }
    },
    bilyonerParams: function() {
        var iMisli = 1;
        var misli = document.getElementById("multiplier");
        if (misli) {
            iMisli = parseInt(misli.value, 10);
        }
        var bilyonerStr = "ai=PVfvoXwCLBU=&misli=" + iMisli;
        var systemStr = "";
        var prmStr = "";
        bilyonerStr += "&sistem=";

        for (e in this.systemHashmap) {
            systemStr += "|" + this.systemHashmap[e];
        }

        bilyonerStr += systemStr;
        for (e in this.couponHashmap) {
            prmStr = prmStr + this.couponHashmap[e].id + "*" + this.couponHashmap[e].banko + "*" + this.couponHashmap[e].bet + "*" + this.convertGametype(this.couponHashmap[e].gameType) + "*";
            prmStr = prmStr + "" + "*" + this.couponHashmap[e].mbs + "*" + this.couponHashmap[e].selTeam + "*~";
            if (this.couponHashmap[e].selTeam1 != undefined && this.couponHashmap[e].bet1 != undefined && this.couponHashmap[e].bet1.length > 0) {
                prmStr = prmStr + this.couponHashmap[e].id + "*" + this.couponHashmap[e].banko + "*" + this.couponHashmap[e].bet1 + "*" + this.convertGametype(this.couponHashmap[e].gameType) + "*";
                prmStr = prmStr + "" + "*" + this.couponHashmap[e].mbs + "*" + this.couponHashmap[e].selTeam1 + "*~";
            }
        }
        bilyonerStr += "&sonuc=" + prmStr + "&maxbet=" + maxbet + "&affinfo=" + "" + "&refId=" + this.userRefId;
        bilyonerStr = this.replaceTRChar(bilyonerStr);
        return bilyonerStr;
    },
    SendToBilyoner: function() {
        var ICPString = this.insertCouponParams(true);
        if (ICPString != null) {
            var bilyonerStr = this.bilyonerParams();
            window.open(this.SEND + "?creator=" + this.couponCreatorId + "&" + ICPString + "&" + bilyonerStr, 'Kuponum', 'toolbar=0,menubar=1,resizable=1,scrollbars=1,width=800,height=600,left=0,top=0');
        }
    },
    replaceTRChar: function(replaceStr) {
        var retVal = "";
        retVal = replaceStr.replace('İ', 'I');
        retVal = retVal.replace('Ğ', 'G');
        retVal = retVal.replace('Ö', 'O');
        retVal = retVal.replace('Ü', 'U');
        retVal = retVal.replace('Ş', 'S');
        retVal = retVal.replace('Ç', 'C');
        retVal = retVal.replace('ı', 'i');
        retVal = retVal.replace('ğ', 'g');
        retVal = retVal.replace('ö', 'o');
        retVal = retVal.replace('ş', 's');
        retVal = retVal.replace('ç', 'c');
        retVal = retVal.replace('ü', 'u');
        return retVal;
    },
    convertGametype: function(myGameType) {
        var retVal = "";

        switch (myGameType) {
            case "MS":
                retVal = "F";
                break;
            case "H":
                retVal = "H";
                break;
            case "CS":
                retVal = "DC";
                break;
            case "IM":
                retVal = "SF";
                break;
            case "SK":
                retVal = "SC";
                break;
            case "UO":
                retVal = "UO";
                break;
            case "AU":
                retVal = "UO";
                break;
            case "IY":
                retVal = "S";
                break;
            case "TG":
                retVal = "GS";
                break;
        }
        return retVal;
    },
    ValidateCoupon: function(MAC, MBS, ORAN, BANKO, SISTEM, doubleMatchColumnNum, doubleMatchNum, bankoDoubleMatchNum, bCount, ORAN1) {
        var I = 0;
        var J = 0;
        var J1 = 0;
        var J2 = 0;
        var J3 = 0;
        var J4 = 0;
        var J5 = 0;
        var J6 = 0;
        var J7 = 0;
        var J8 = 0;
        var J9 = 0;
        var J10 = 0;
        var J11 = 0;
        var J12 = 0;
        var J13 = 0;
        var J14 = 0;
        var J15 = 0;

        var MACSAYISI = 0;
        var BANKOSAYISI = 0;
        var NSISTEM = 0;
        var SISTEMSAYISI = 0;
        var ISSISTEM = 0;
        var BANKO_STR = "";
        var BANKO_KONTROL = 0;
        var BANKO_OK = 0;

        var VORAN = 0;
        var VTOPLAMORAN = 0;
        var VTOPLAMORANHEPSI = 0;
        var VTOPLAMKUPON = 0;
        var VILKDEGER = 0;
        var VARADEGER = 0;
        var VSONDEGER = 0;

        var B1 = 0;
        var B2 = 0;
        var B3 = 0;
        var B4 = 0;
        var B5 = 0;
        var B6 = 0;
        var B7 = 0;
        var B8 = 0;
        var B9 = 0;
        var B10 = 0;
        var B11 = 0;
        var B12 = 0;
        var B13 = 0;
        var B14 = 0;
        var B15 = 0;
        var VMBS_OK = 1;

        B1 = BANKO[0];
        B2 = BANKO[1];
        B3 = BANKO[2];
        B4 = BANKO[3];
        B5 = BANKO[4];
        B6 = BANKO[5];
        B7 = BANKO[6];
        B8 = BANKO[7];
        B9 = BANKO[8];
        B10 = BANKO[9];
        B11 = BANKO[10];
        B12 = BANKO[11];
        B13 = BANKO[12];
        B14 = BANKO[13];
        B15 = BANKO[14];

        BANKO_KONTROL = B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8 + B9 + B10 + B11 + B12 + B13 + B14 + B15;

        VORAN = 0;
        VTOPLAMORAN = 0;
        VTOPLAMKUPON = 0;
        VTOPLAMORANHEPSI = 1;
        NSISTEM = 0;
        MACSAYISI = 0;
        BANKOSAYISI = 0;
        J = 0;

        for (i = 0; i < 15; i++) {

            if (ORAN1[i] && ORAN1[i] != undefined && ORAN1[i] != "")
                if (ORAN1[i] > ORAN[i])
                ORAN[i] = ORAN1[i]

            if (!(ORAN[i] == 0 || ORAN[i] == "")) {
                VTOPLAMORANHEPSI = VTOPLAMORANHEPSI * ORAN[i];
            }

            if (!(MAC[i] == 0 || MAC[i] == "")) {
                MACSAYISI = MACSAYISI + 1;
            }
            if (!(BANKO[i] == 0 || BANKO[i] == "")) {
                BANKOSAYISI = BANKOSAYISI + 1;
            }
            if (!(SISTEM[i] == 0 || SISTEM[i] == "")) {
                NSISTEM = NSISTEM + 1;
            }
        }
        ISSISTEM = NSISTEM;
        if (SISTEM[0] == 0 || SISTEM[0] == "") {
            SISTEM[0] = MACSAYISI;
            BANKOSAYISI = 0;
            NSISTEM = 1;
            BANKO_KONTROL = 0;
        }

        BANKOSAYISI = parseInt(BANKOSAYISI, 10)


        for (i = 0; i < NSISTEM; i++) {
            SISTEMSAYISI = parseInt(SISTEM[i], 10) + BANKOSAYISI;


            for (J1 = 0; J1 < (MACSAYISI - SISTEMSAYISI + 1); J1++) {
                if (SISTEMSAYISI == 1) {

                    J = J + 1;
                    if (MBS[J1] == 1) {
                        VORAN = ORAN[J1];
                        if (VORAN > 500000) { VORAN = 500000; }
                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1]);
                    }
                    else
                        VMBS_OK = 0;
                } else {
                    for (J2 = J1 + 1; J2 < (MACSAYISI - SISTEMSAYISI + 2); J2++) {
                        if (SISTEMSAYISI == 2) {
                            if (BANKO_KONTROL > 0) {
                                BANKO_STR = MAC[J1] + '0' + MAC[J2];
                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0) {
                                    BANKO_OK = 1;
                                } else {
                                    BANKO_OK = 0;
                                }
                            } else {
                                BANKO_OK = 1;
                            }
                            if (BANKO_OK == 1) {
                                J = J + 1;
                                if (MBS[J1] == 1 || MBS[J2] == 1 || (MBS[J1] == 2 && MBS[J2] == 2)) {
                                    VORAN = ORAN[J1] * ORAN[J2];
                                    if (VORAN > 500000) { VORAN = 500000; }
                                    VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                    VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                    //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2]);															
                                }
                                else
                                    VMBS_OK = 0;
                            }
                        } else {
                            for (J3 = J2 + 1; J3 < (MACSAYISI - SISTEMSAYISI + 3); J3++) {
                                if (SISTEMSAYISI == 3) {
                                    if (BANKO_KONTROL > 0) {
                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3];
                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0) {
                                            BANKO_OK = 1;
                                        } else {
                                            BANKO_OK = 0;
                                        }
                                    }
                                    else {
                                        BANKO_OK = 1;
                                    }
                                    if (BANKO_OK == 1) {
                                        J = J + 1;
                                        if (MBS[J1] == 1 || MBS[J2] == 1 || MBS[J3] == 1 || (MBS[J1] <= 2 && MBS[J2] <= 2) || (MBS[J1] <= 2 && MBS[J3] <= 2) || (MBS[J2] <= 2 && MBS[J3] <= 2) || (MBS[J1] <= 3 && MBS[J2] <= 3 && MBS[J3] <= 3)) {
                                            VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3];
                                            if (VORAN > 500000) { VORAN = 500000; }
                                            VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                            VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                            //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3]);																	
                                        }
                                        else
                                            VMBS_OK = 0;
                                    }
                                }
                                else {
                                    for (J4 = J3 + 1; J4 < (MACSAYISI - SISTEMSAYISI + 4); J4++) {
                                        if (SISTEMSAYISI == 4) {
                                            if (BANKO_KONTROL > 0) {
                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4];
                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0) {
                                                    BANKO_OK = 1;
                                                } else {
                                                    BANKO_OK = 0;
                                                }
                                            } else {
                                                BANKO_OK = 1;
                                            }
                                            if (BANKO_OK == 1) {
                                                J = J + 1;
                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4];
                                                if (VORAN > 500000) { VORAN = 500000; }
                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4]);																			
                                            }
                                        } else {
                                            for (J5 = J4 + 1; J5 < (MACSAYISI - SISTEMSAYISI + 5); J5++) {
                                                if (SISTEMSAYISI == 5) {
                                                    J = J + 1;
                                                    if (BANKO_KONTROL > 0) {
                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5];
                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0) {
                                                            BANKO_OK = 1;
                                                        } else {
                                                            BANKO_OK = 0;
                                                        }
                                                    } else {
                                                        BANKO_OK = 1;
                                                    }
                                                    if (BANKO_OK == 1) {
                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5];
                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5]);											
                                                    }
                                                } else {
                                                    for (J6 = J5 + 1; J6 < (MACSAYISI - SISTEMSAYISI + 6); J6++) {
                                                        if (SISTEMSAYISI == 6) {
                                                            J = J + 1;
                                                            if (BANKO_KONTROL > 0) {
                                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6];

                                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0 && this.INSTR(BANKO_STR, B6, 1, 1) > 0) {
                                                                    BANKO_OK = 1;
                                                                }
                                                                else {
                                                                    BANKO_OK = 0;
                                                                }
                                                            } else {
                                                                BANKO_OK = 1;
                                                            }

                                                            if (BANKO_OK == 1) {
                                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6];
                                                                if (VORAN > 500000) { VORAN = 500000; }
                                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6]);
                                                            }
                                                        } else {
                                                            for (J7 = J6 + 1; J7 < (MACSAYISI - SISTEMSAYISI + 7); J7++) {
                                                                if (SISTEMSAYISI == 7) {
                                                                    J = J + 1;
                                                                    if (BANKO_KONTROL > 0) {
                                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7];
                                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																		    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0) {
                                                                            BANKO_OK = 1;
                                                                        } else {
                                                                            BANKO_OK = 0;
                                                                        }
                                                                    } else {
                                                                        BANKO_OK = 1;
                                                                    }
                                                                    if (BANKO_OK == 1) {
                                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7];
                                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7]);
                                                                    }
                                                                } else {
                                                                    for (J8 = J7 + 1; J8 < (MACSAYISI - SISTEMSAYISI + 8); J8++) {
                                                                        if (SISTEMSAYISI == 8) {
                                                                            J = J + 1;
                                                                            if (BANKO_KONTROL > 0) {
                                                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8];
                                                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																				    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0) {
                                                                                    BANKO_OK = 1;
                                                                                } else {
                                                                                    BANKO_OK = 0;
                                                                                }
                                                                            } else {
                                                                                BANKO_OK = 1;
                                                                            }
                                                                            if (BANKO_OK == 1) {
                                                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8];
                                                                                if (VORAN > 500000) { VORAN = 500000; }
                                                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8]);
                                                                            }
                                                                        } else {
                                                                            for (J9 = J8 + 1; J9 < (MACSAYISI - SISTEMSAYISI + 9); J9++) {
                                                                                if (SISTEMSAYISI == 9) {
                                                                                    J = J + 1;
                                                                                    if (BANKO_KONTROL > 0) {
                                                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9];
                                                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																						    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0) {
                                                                                            BANKO_OK = 1;
                                                                                        } else {
                                                                                            BANKO_OK = 0;
                                                                                        }
                                                                                    } else {
                                                                                        BANKO_OK = 1;
                                                                                    }
                                                                                    if (BANKO_OK == 1) {
                                                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9];
                                                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9]);
                                                                                    }
                                                                                } else {
                                                                                    for (J10 = J9 + 1; J10 < (MACSAYISI - SISTEMSAYISI + 10); J10++) {
                                                                                        if (SISTEMSAYISI == 10) {
                                                                                            J = J + 1;
                                                                                            if (BANKO_KONTROL > 0) {
                                                                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10];
                                                                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																								    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0) {
                                                                                                    BANKO_OK = 1;
                                                                                                } else {
                                                                                                    BANKO_OK = 0;
                                                                                                }
                                                                                            } else {
                                                                                                BANKO_OK = 1;
                                                                                            }
                                                                                            if (BANKO_OK == 1) {
                                                                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10];
                                                                                                if (VORAN > 500000) { VORAN = 500000; }
                                                                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10]);
                                                                                            }
                                                                                        } else {
                                                                                            for (J11 = J10 + 1; J11 < (MACSAYISI - SISTEMSAYISI + 11); J11++) {
                                                                                                if (SISTEMSAYISI == 11) {
                                                                                                    J = J + 1;
                                                                                                    if (BANKO_KONTROL > 0) {
                                                                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10] + '0' + MAC[J11];
                                                                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																										    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0
																										    && this.INSTR(BANKO_STR, B11, 1, 1) > 0) {
                                                                                                            BANKO_OK = 1;
                                                                                                        } else {
                                                                                                            BANKO_OK = 0;
                                                                                                        }
                                                                                                    } else {
                                                                                                        BANKO_OK = 1;
                                                                                                    }
                                                                                                    if (BANKO_OK == 1) {
                                                                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10] * ORAN[J11];
                                                                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10] + ' - ' + MAC[J11]);
                                                                                                    }
                                                                                                } else {
                                                                                                    for (J12 = J11 + 1; J12 < (MACSAYISI - SISTEMSAYISI + 12); J12++) {
                                                                                                        if (SISTEMSAYISI == 12) {
                                                                                                            J = J + 1;
                                                                                                            if (BANKO_KONTROL > 0) {
                                                                                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10] + '0' + MAC[J11] + '0' + MAC[J12];
                                                                                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																												    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0
																												    && this.INSTR(BANKO_STR, B11, 1, 1) > 0 && this.INSTR(BANKO_STR, B12, 1, 1) > 0) {
                                                                                                                    BANKO_OK = 1;
                                                                                                                } else {
                                                                                                                    BANKO_OK = 0;
                                                                                                                }
                                                                                                            } else {
                                                                                                                BANKO_OK = 1;
                                                                                                            }
                                                                                                            if (BANKO_OK == 1) {
                                                                                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10] * ORAN[J11] * ORAN[J12];
                                                                                                                if (VORAN > 500000) { VORAN = 500000; }
                                                                                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10] + ' - ' + MAC[J11] + ' - ' + MAC[J12]);
                                                                                                            }
                                                                                                        } else {
                                                                                                            for (J13 = J12 + 1; J13 < (MACSAYISI - SISTEMSAYISI + 13); J13++) {
                                                                                                                if (SISTEMSAYISI == 13) {
                                                                                                                    J = J + 1;
                                                                                                                    if (BANKO_KONTROL > 0) {
                                                                                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10] + '0' + MAC[J11] + '0' + MAC[J12] + '0' + MAC[J13];
                                                                                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																														    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0
																														    && this.INSTR(BANKO_STR, B11, 1, 1) > 0 && this.INSTR(BANKO_STR, B12, 1, 1) > 0 && this.INSTR(BANKO_STR, B13, 1, 1) > 0) {
                                                                                                                            BANKO_OK = 1;
                                                                                                                        } else {
                                                                                                                            BANKO_OK = 0;
                                                                                                                        }
                                                                                                                    } else {
                                                                                                                        BANKO_OK = 1;
                                                                                                                    }
                                                                                                                    if (BANKO_OK == 1) {
                                                                                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10] * ORAN[J11] * ORAN[J12] * ORAN[J13];
                                                                                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                                                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10] + ' - ' + MAC[J11] + ' - ' + MAC[J12] + ' - ' + MAC[J13]);
                                                                                                                    }
                                                                                                                } else {
                                                                                                                    for (J14 = J13 + 1; J14 < (MACSAYISI - SISTEMSAYISI + 14); J14++) {
                                                                                                                        if (SISTEMSAYISI == 14) {
                                                                                                                            J = J + 1;
                                                                                                                            if (BANKO_KONTROL > 0) {
                                                                                                                                BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10] + '0' + MAC[J11] + '0' + MAC[J12] + '0' + MAC[J13] + '0' + MAC[J14];
                                                                                                                                if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																																    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0
																																    && this.INSTR(BANKO_STR, B11, 1, 1) > 0 && this.INSTR(BANKO_STR, B12, 1, 1) > 0 && this.INSTR(BANKO_STR, B13, 1, 1) > 0 && this.INSTR(BANKO_STR, B14, 1, 1) > 0) {
                                                                                                                                    BANKO_OK = 1;
                                                                                                                                } else {
                                                                                                                                    BANKO_OK = 0;
                                                                                                                                }
                                                                                                                            } else {
                                                                                                                                BANKO_OK = 1;
                                                                                                                            }
                                                                                                                            if (BANKO_OK == 1) {
                                                                                                                                VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10] * ORAN[J11] * ORAN[J12] * ORAN[J13] * ORAN[J14];
                                                                                                                                if (VORAN > 500000) { VORAN = 500000; }
                                                                                                                                VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                                                VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                                                //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10] + ' - ' + MAC[J11] + ' - ' + MAC[J12] + ' - ' + MAC[J13] + ' - ' + MAC[J14]);
                                                                                                                            }
                                                                                                                        } else {
                                                                                                                            for (J15 = J14 + 1; J15 < (MACSAYISI - SISTEMSAYISI + 15); J15++) {
                                                                                                                                if (SISTEMSAYISI == 15) {
                                                                                                                                    J = J + 1;
                                                                                                                                    if (BANKO_KONTROL > 0) {
                                                                                                                                        BANKO_STR = MAC[J1] + '0' + MAC[J2] + '0' + MAC[J3] + '0' + MAC[J4] + '0' + MAC[J5] + '0' + MAC[J6] + '0' + MAC[J7] + '0' + MAC[J8] + '0' + MAC[J9] + '0' + MAC[J10] + '0' + MAC[J11] + '0' + MAC[J12] + '0' + MAC[J13] + '0' + MAC[J14] + '0' + MAC[J15];
                                                                                                                                        if (this.INSTR(BANKO_STR, B1, 1, 1) > 0 && this.INSTR(BANKO_STR, B2, 1, 1) > 0 && this.INSTR(BANKO_STR, B3, 1, 1) > 0 && this.INSTR(BANKO_STR, B4, 1, 1) > 0 && this.INSTR(BANKO_STR, B5, 1, 1) > 0
																																		    && this.INSTR(BANKO_STR, B6, 1, 1) > 0 && this.INSTR(BANKO_STR, B7, 1, 1) > 0 && this.INSTR(BANKO_STR, B8, 1, 1) > 0 && this.INSTR(BANKO_STR, B9, 1, 1) > 0 && this.INSTR(BANKO_STR, B10, 1, 1) > 0
																																		    && this.INSTR(BANKO_STR, B11, 1, 1) > 0 && this.INSTR(BANKO_STR, B12, 1, 1) > 0 && this.INSTR(BANKO_STR, B13, 1, 1) > 0 && this.INSTR(BANKO_STR, B14, 1, 1) > 0 && this.INSTR(BANKO_STR, B15, 1, 1) > 0) {
                                                                                                                                            BANKO_OK = 1;
                                                                                                                                        } else {
                                                                                                                                            BANKO_OK = 0;
                                                                                                                                        }
                                                                                                                                    } else {
                                                                                                                                        BANKO_OK = 1;
                                                                                                                                    }
                                                                                                                                    if (BANKO_OK == 1) {
                                                                                                                                        VORAN = ORAN[J1] * ORAN[J2] * ORAN[J3] * ORAN[J4] * ORAN[J5] * ORAN[J6] * ORAN[J7] * ORAN[J8] * ORAN[J9] * ORAN[J10] * ORAN[J11] * ORAN[J12] * ORAN[J13] * ORAN[J14] * ORAN[J15];
                                                                                                                                        if (VORAN > 500000) { VORAN = 500000; }
                                                                                                                                        VTOPLAMORAN = VTOPLAMORAN + VORAN;
                                                                                                                                        VTOPLAMKUPON = VTOPLAMKUPON + 1;
                                                                                                                                        //alert(VTOPLAMKUPON + ' - ' + VORAN + ' - ' + VTOPLAMORAN + ' - ' + MAC[J1] + ' - ' + MAC[J2] + ' - ' + MAC[J3] + ' - ' + MAC[J4] + ' - ' + MAC[J5] + ' - ' + MAC[J6] + ' - ' + MAC[J7] + ' - ' + MAC[J8] + ' - ' + MAC[J9] + ' - ' + MAC[J10] + ' - ' + MAC[J11] + ' - ' + MAC[J12] + ' - ' + MAC[J13] + ' - ' + MAC[J14] + ' - ' + MAC[J15]);
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if (ISSISTEM == 0) {
            VTOPLAMKUPON = VTOPLAMKUPON * doubleMatchColumnNum;
        }

        if (doubleMatchNum > 0 && ISSISTEM > 0) {
            MACSAYISI = MACSAYISI - BANKOSAYISI;
            doubleMatchNum = doubleMatchNum - bankoDoubleMatchNum;
            VTOPLAMKUPON = 0;

            for (var i = 0; i < NSISTEM; i++) {
                VILKDEGER = this.BIL_SK(MACSAYISI - doubleMatchNum, SISTEM[i]);
                VARADEGER = 0;

                for (var j = 1; j < 16; j++) {
                    VARADEGER = VARADEGER + (this.BIL_SK(doubleMatchNum, j) * this.BIL_SK(MACSAYISI - doubleMatchNum, SISTEM[i] - j) * Math.pow(2, j));
                }
                VSONDEGER = this.BIL_SK(doubleMatchNum, SISTEM[i]) * Math.pow(2, SISTEM[i]);
                VTOPLAMKUPON = VTOPLAMKUPON + ((VILKDEGER + VARADEGER + VSONDEGER) * Math.pow(2, bankoDoubleMatchNum));
            }
        }

        if (VTOPLAMKUPON > 0 && VMBS_OK == 1)
            return (J + '-' + VTOPLAMKUPON + '-' + VTOPLAMORAN + '-' + VTOPLAMORANHEPSI);
        else
            return "NOK";
    }
}

