﻿Mackolik = Mackolik || {};
Mackolik.Program = Mackolik.Program  || {};
Mackolik.Program.IYMS = Mackolik.Program.IYMS  || {};

Mackolik.Program.IYMS = {
    getGroupProgram: function() {
        this.writeLoading();
        var url = APP_ROOT + '/Program/ProgramData.aspx?type=' + Mackolik.Program.type + '&sortValue=' + Mackolik.Program.sortValue + '&week=' + Mackolik.Program.week + '&day=' + Mackolik.Program.day + '&sort=' + Mackolik.Program.sort + '&sortDir=' + Mackolik.Program.sortDir + '&groupId=' + Mackolik.Program.groupId;
        var callback = new AjaxCallback(
            function(response) { Mackolik.Program.IYMS.getProgramCompleted(response) }, null,
            function(response) { });
        var transaction = YAHOO.util.Connect.asyncRequest('GET', url, callback);
    },
    writeLoading: function() {
        document.getElementById('dvIYMS').innerHTML = Mackolik.Program.loadingMsg;
    },
    getProgram: function() {

        this.getGroupProgram(Mackolik.Program.type, Mackolik.Program.sortValue, Mackolik.Program.week, Mackolik.Program.day, Mackolik.Program.sort, Mackolik.Program.sortDir, Mackolik.Program.groupId);
    },
    getProgramCompleted: function(response) {
        try {
            var data = eval("(" + response.responseText + ")");
            if (Mackolik.Program.sortValue == "ALTG_ADI10")
                this.writeProgramByGroup(data);
            else if (Mackolik.Program.sortValue == "DATE")
                this.writeProgramByDate(data);
        }
        catch (err) {
            //this.errorHandler();
        }
    },

    writeProgramByDate: function(livedata) {
        var header = '<table width="770" border=0 cellpadding=0 cellspacing=0  id=resultsList align="left" style="border: 1px solid rgb(204, 204, 204);">';
        var dateFormat = '<tr class="groupHeader dateHeader" height=15><td colspan="6" width="30" colspan="2" style="padding-left:10px;"><b>{0}</b></td></tr>';
        var dateFormat2 = '<tr class="groupHeader dateHeader" height=15><td width="30" colspan="2" style="padding-left:10px;"><b>{0}</b></td><td colspan="22"></td></tr>';


        var rowFormat = '<tr class="groupHeader dateHeader"><td width="120"><b>{4} &nbsp; {1}</b></td>'; //Saat
        rowFormat = rowFormat + '<td width="40"><a href="javascript:popComparison({2})"><b>{3}</b></a></td>';
        rowFormat = rowFormat + '<td width="40">&nbsp;<a href="javascript:popLeague({27})">{25}</a></td>'//altGrupAd10

        rowFormat = rowFormat + '<td align="left" width="220"><a style="font-size: 11px;" href="javascript:popTeam({7})">{8}</a> - <a style="font-size: 11px;" href="javascript:popTeam({11})">{12}</a> </td>';

        rowFormat = rowFormat + '{14}'; //iy
        rowFormat = rowFormat + '{15}'; //ms
        rowFormat = rowFormat + '<tr><td colspan=6  bgcolor=FFFFFF><table id=resultsList cellpadding=0 cellspacing=0 border=0 width=100%>'
        rowFormat = rowFormat + '<tr><td width="20">&nbsp;&nbsp;</td><td width="30"><b>1/1</b></td>';
        rowFormat = rowFormat + '{16}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/1</b></td>';
        rowFormat = rowFormat + '{17}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/1</b></td>';
        rowFormat = rowFormat + '{18}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr>';
        rowFormat = rowFormat + '<tr><td width="30">&nbsp;&nbsp;</td><td width="5%"><b>1/X</b></td>';
        rowFormat = rowFormat + '{19}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/X</b></td>';
        rowFormat = rowFormat + '{20}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/X</b></td>';
        rowFormat = rowFormat + '{21}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr>';
        rowFormat = rowFormat + '<tr><td width="20">&nbsp;&nbsp;</td><td width=30"><b>1/2</b></td>';
        rowFormat = rowFormat + '{22}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/2</b></td>';
        rowFormat = rowFormat + '{23}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/2</b></td>';
        rowFormat = rowFormat + '{24}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr></table><br/></td><tr>';

        var weekStatus = true;
        if (Mackolik.Program.week != Mackolik.Program.currentWeek) {
            weekStatus = false;
        }


        var sbScores = new StringBuilder();
        sbScores.append(header);
        var dateData = livedata.m;

        var k = 0;
        for (var j = 0; j < dateData.length; j++) {

            var data = dateData[j].m;

            if (data.length == 0)
                sbScores.append('<tr><td bgcolor=#CED7D2></td><td colspan=23 bgcolor=#CED7D2><b>Bu kriterlere uygun maç bulunamadi.</b></td></tr>');

            for (var i = 0; i < data.length; i++, k++) {
                var matchData = data[i];
                var score = '';
                var match_status = '';
                var stadium_status = '&nbsp;';
                var classname = (k % 2) == 1 ? "row1" : "row2";
                var saat = matchData[6];
                var tarih = matchData[7];
                var match_id = matchData[0];
                var iddaId = matchData[10];

                var flag1 = "&nbsp;"
                var flag2 = "&nbsp;"

                var macSonuc1 = matchData[8];
                var macSonuc2 = matchData[9];
                var IYSonuc1 = matchData[11];
                var IYSonuc2 = matchData[12];
                var macDurum = matchData[5];
                var takim1 = matchData[1];
                var takim1Id = matchData[2];
                var takim2 = matchData[3];
                var takim2Id = matchData[4];

                var bold1 = (macSonuc1 > macSonuc2) && macDurum >= 4 ? "<b>" : "";
                var bold2 = (macSonuc1 > macSonuc2) && macDurum >= 4 ? "</b>" : "";
                var bold3 = (macSonuc1 < macSonuc2) && macDurum >= 4 ? "<b>" : "";
                var bold4 = (macSonuc1 < macSonuc2) && macDurum >= 4 ? "</b>" : "";

                if (macDurum == 9) {
                    htsonuc = 'ERT';
                } else if (macDurum == 11) {
                    htsonuc = 'Yrdk.';
                } else {
                    htsonuc = macDurum >= 2 ? IYSonuc1 + ' - ' + IYSonuc2 : '&nbsp;';
                }
                var ms;

                if (macDurum < 4) {
                    ms = '<a href=\"javascript:popMatch(' + match_id + ')\">v</a>';
                } else {
                    if (macDurum == 9) {
                        ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">ERT.</a></b>';
                    } else if (macDurum == 11) {
                        ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">Yrdk.</a></b>';
                    } else {
                        ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">' + macSonuc1 + ' - ' + macSonuc2 + '</a></b>';
                    }
                }
                var imo_iy_ms11 = matchData[13];
                var imo_iy_ms01 = matchData[14];
                var imo_iy_ms21 = matchData[15];
                var imo_iy_ms10 = matchData[16];
                var imo_iy_ms00 = matchData[17];
                var imo_iy_ms20 = matchData[18];
                var imo_iy_ms12 = matchData[19];
                var imo_iy_ms02 = matchData[20];
                var imo_iy_ms22 = matchData[21];
                var mbs = matchData[25];
                mbs = mbs * 1;
                if (mbs < 3 && mbs > 0) {
                    mbs = 1;
                } else {
                    mbs = 2;
                }

                var imo_iy11background = (IYSonuc1 > IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms11_td = '<td width="40" style="color:#16387C;' + imo_iy11background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms11, 'IM', '1/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy01background = (IYSonuc1 == IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms01_td = '<td width="40" style="color:#16387C;' + imo_iy01background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms01, 'IM', 'X/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy21background = (IYSonuc1 < IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms21_td = '<td width="40" style="color:#16387C;' + imo_iy21background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms21, 'IM', '2/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                var imo_iy10background = (IYSonuc1 > IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms10_td = '<td width="40" style="color:#16387C;' + imo_iy10background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms10, 'IM', '1/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy00background = (IYSonuc1 == IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms00_td = '<td width="40" style="color:#16387C;' + imo_iy00background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms00, 'IM', 'X/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy20background = (IYSonuc1 < IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms20_td = '<td width="40" style="color:#16387C;' + imo_iy20background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms20, 'IM', '2/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                var imo_iy12background = (IYSonuc1 > IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms12_td = '<td width="40" style="color:#16387C;' + imo_iy12background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms12, 'IM', '1/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy02background = (IYSonuc1 == IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms02_td = '<td width="40" style="color:#16387C;' + imo_iy02background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms02, 'IM', 'X/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                var imo_iy22background = (IYSonuc1 < IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                var iyms22_td = '<td width="40" style="color:#16387C;' + imo_iy22background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms22, 'IM', '2/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                iy_td = macDurum >= 2 ? '<td width="80"><a href="javascript:popMatch(' + match_id + ')"> IY:' + IYSonuc1 + ' - ' + IYSonuc2 + '</a></td>' : '<td width="80">&nbsp</td>'
                ms_td = macDurum >= 4 ? '<td width="280"><a href="javascript:popMatch(' + match_id + ')"> MS:' + macSonuc1 + ' - ' + macSonuc2 + '</a></td>' : '<td width="80">&nbsp</td>'

                var altGrupAd10 = matchData[22];
                var grupId = matchData[23];
                var altGrId = matchData[24];


                //                                   0        1      2         3      4     5      6     7        8     9     10      11       12     13      14     15      16        17        18        19        20         21       22        23       24         25         26     27
                sbScores.appendFormat(rowFormat, classname, saat, match_id, iddaId, tarih, flag1, bold1, takim1Id, takim1, bold2, bold3, takim2Id, takim2, bold4, iy_td, ms_td, iyms11_td, iyms01_td, iyms21_td, iyms10_td, iyms00_td, iyms20_td, iyms12_td, iyms02_td, iyms22_td, altGrupAd10, grupId, altGrId);

            }



        }
        document.getElementById('dvIYMS').innerHTML = sbScores;

    }
    ,

    writeProgramByGroup: function(livedata) {
        var header = '<table width="770" border=0 cellpadding=0 cellspacing=0  id=resultsList align="left" style="border: 1px solid rgb(204, 204, 204);">';
        var dateFormat = '<tr class="groupHeader dateHeader" height=20><td colspan="6" width="30" colspan="2" style="padding-left:10px;"><b>{0}</b></td></tr>';
        var dateFormat2 = '<tr class="groupHeader dateHeader" height=20><td width="30" colspan="2" style="padding-left:10px;"><b>{0}</b></td><td colspan="22"></td></tr>';


        var rowFormat = '<tr class="groupHeader dateHeader"><td width="120"><b>{4} &nbsp; {1}</b></td>'; //Saat
        rowFormat = rowFormat + '<td width="40"><a href="javascript:popComparison({2})"><b>{3}</b></a></td>';
        rowFormat = rowFormat + '<td width="40">&nbsp;<a href="javascript:popLeague({27})">{25}</a></td>'//altGrupAd10

        rowFormat = rowFormat + '<td align="left" width="220"><a style="font-size: 11px;" href="javascript:popTeam({7})">{8}</a> - <a style="font-size: 11px;" href="javascript:popTeam({11})">{12}</a> </td>';

        rowFormat = rowFormat + '{14}'; //iy
        rowFormat = rowFormat + '{15}'; //ms
        rowFormat = rowFormat + '<tr><td colspan=6  bgcolor=FFFFFF><table id=resultsList cellpadding=0 cellspacing=0 border=0 width=100%>'
        rowFormat = rowFormat + '<tr><td width="20">&nbsp;&nbsp;</td><td width="30"><b>1/1</b></td>';
        rowFormat = rowFormat + '{16}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/1</b></td>';
        rowFormat = rowFormat + '{17}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/1</b></td>';
        rowFormat = rowFormat + '{18}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr>';
        rowFormat = rowFormat + '<tr><td width="20">&nbsp;&nbsp;</td><td width="30"><b>1/X</b></td>';
        rowFormat = rowFormat + '{19}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/X</b></td>';
        rowFormat = rowFormat + '{20}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/X</b></td>';
        rowFormat = rowFormat + '{21}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr>';


        rowFormat = rowFormat + '<tr><td width="20">&nbsp;&nbsp;</td><td width="30"><b>1/2</b></td>';
        rowFormat = rowFormat + '{22}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>X/2</b></td>';
        rowFormat = rowFormat + '{23}<td width="20"></td>';
        rowFormat = rowFormat + '<td width="30"><b>2/2</b></td>';
        rowFormat = rowFormat + '{24}<td width="20"></td>';
        rowFormat = rowFormat + '<td></td></tr></table><br/></td><tr>';


        var sbScores = new StringBuilder();
        sbScores.append(header);

        var data = livedata.m;
        for (var i = 0; i < data.length; i++) {
            var groupData = data[i];
            if (!groupData.g) {
                continue;
            }

            if (groupData.g.length == 0) {
                sbScores.append('<tr><td bgcolor=#CED7D2></td><td colspan=23 bgcolor=#CED7D2><b>Bu kriterlere uygun maç bulunamadi.</b></td></tr>');
                break;
            }

            groupFormat = '<tr height=20 class="groupHeader competition"><td colspan=25 align="left" style="padding-left:2px;">';
            groupFormat = groupFormat + '<img src="{0}" /><b><a href="javascript:popLeague({2})"> {1} </a></b></td></tr>';

            sbScores.appendFormat(groupFormat, GROUP_FLAG_PATH + groupData.g[0] + ".gif", groupData.g[1], groupData.g[2], groupData.g[3]);

            var weekStatus = true;
            if (Mackolik.Program.week != Mackolik.Program.currentWeek) {
                weekStatus = false;
            }


            for (var j = 0; j < groupData.r.length; j++) {
                var dateData = groupData.r[j];
                var arrMatches = [];

                for (var k = 0; k < dateData.m.length; k++) {
                    var matchData = dateData.m[k];
                    var score = '';
                    var match_status = '';
                    var stadium_status = '&nbsp;';
                    var classname = (k % 2) == 1 ? "row1" : "row2";
                    var saat = matchData[6];
                    var tarih = matchData[7];
                    var match_id = matchData[0];
                    var iddaId = matchData[10];

                    var flag1 = "&nbsp;"
                    var flag2 = "&nbsp;"

                    var macSonuc1 = matchData[8];
                    var macSonuc2 = matchData[9];
                    var IYSonuc1 = matchData[11];
                    var IYSonuc2 = matchData[12];
                    var macDurum = matchData[5];
                    var takim1 = matchData[1];
                    var takim1Id = matchData[2];
                    var takim2 = matchData[3];
                    var takim2Id = matchData[4];

                    var bold1 = (macSonuc1 > macSonuc2) && macDurum >= 4 ? "<b>" : "";
                    var bold2 = (macSonuc1 > macSonuc2) && macDurum >= 4 ? "</b>" : "";

                    var bold3 = (macSonuc1 < macSonuc2) && macDurum >= 4 ? "<b>" : "";
                    var bold4 = (macSonuc1 < macSonuc2) && macDurum >= 4 ? "</b>" : "";

                    if (macDurum == 9) {
                        htsonuc = 'ERT';
                    } else if (macDurum == 11) {
                        htsonuc = 'Yrdk.';
                    } else {
                        htsonuc = macDurum >= 2 ? IYSonuc1 + ' - ' + IYSonuc2 : '&nbsp;';
                    }
                    var ms;

                    if (macDurum < 4) {
                        ms = '<a href=\"javascript:popMatch(' + match_id + ')\">v</a>';
                    } else {
                        if (macDurum == 9) {
                            ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">ERT.</a></b>';
                        } else if (macDurum == 11) {
                            ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">Yrdk.</a></b>';
                        } else {
                            ms = '<b><a href=\"javascript:popMatch(' + match_id + ')\">' + macSonuc1 + ' - ' + macSonuc2 + '</a></b>';
                        }
                    }

                    var imo_iy_ms11 = matchData[13];
                    var imo_iy_ms01 = matchData[14];
                    var imo_iy_ms21 = matchData[15];
                    var imo_iy_ms10 = matchData[16];
                    var imo_iy_ms00 = matchData[17];
                    var imo_iy_ms20 = matchData[18];
                    var imo_iy_ms12 = matchData[19];
                    var imo_iy_ms02 = matchData[20];
                    var imo_iy_ms22 = matchData[21];
                    var mbs = matchData[25];
                    mbs = mbs * 1;
                    if (mbs < 3 && mbs > 0) {
                        mbs = 1;
                    } else {
                        mbs = 2;
                    }


                    var imo_iy11background = (IYSonuc1 > IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms11_td = '<td width=40 style="color:#16387C;' + imo_iy11background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms11, 'IM', '1/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy01background = (IYSonuc1 == IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms01_td = '<td width=40 style="color:#16387C;' + imo_iy01background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms01, 'IM', 'X/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy21background = (IYSonuc1 < IYSonuc2) && (macSonuc1 > macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms21_td = '<td width=40 style="color:#16387C;' + imo_iy21background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms21, 'IM', '2/1', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                    var imo_iy10background = (IYSonuc1 > IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms10_td = '<td width=40 style="color:#16387C;' + imo_iy10background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms10, 'IM', '1/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy00background = (IYSonuc1 == IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms00_td = '<td width=40 style="color:#16387C;' + imo_iy00background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms00, 'IM', 'X/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy20background = (IYSonuc1 < IYSonuc2) && (macSonuc1 == macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms20_td = '<td width=40 style="color:#16387C;' + imo_iy20background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms20, 'IM', '2/X', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                    var imo_iy12background = (IYSonuc1 > IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms12_td = '<td width=40 style="color:#16387C;' + imo_iy12background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms12, 'IM', '1/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy02background = (IYSonuc1 == IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms02_td = '<td width=40 style="color:#16387C;' + imo_iy02background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms02, 'IM', 'X/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';
                    var imo_iy22background = (IYSonuc1 < IYSonuc2) && (macSonuc1 < macSonuc2) && macDurum >= 4 ? "background-color:#99FF99" : "";
                    var iyms22_td = '<td width=40 style="color:#16387C;' + imo_iy22background + ';text-align:right">' + Mackolik.Coupon.prepareAddCouponLink(iddaId, imo_iy_ms22, 'IM', '2/2', takim1, takim2, match_id, takim1Id, takim2Id, mbs, '', '', weekStatus ? macDurum : -1) + '</td>';

                    iy_td = macDurum >= 2 ? '<td width="80"><a href="javascript:popMatch(' + match_id + ')"> IY:' + IYSonuc1 + ' - ' + IYSonuc2 + '</a></td>' : '<td width="80">&nbsp</td>'
                    ms_td = macDurum >= 4 ? '<td width="280"><a href="javascript:popMatch(' + match_id + ')"> MS:' + macSonuc1 + ' - ' + macSonuc2 + '</a></td>' : '<td width="80">&nbsp</td>'

                    var altGrupAd10 = matchData[22];
                    var grupId = matchData[23];
                    var altGrId = matchData[24];


                    //                                   0        1      2         3      4     5      6     7        8     9     10      11       12     13      14     15      16        17        18        19        20         21       22        23       24         25         26     27
                    sbScores.appendFormat(rowFormat, classname, saat, match_id, iddaId, tarih, flag1, bold1, takim1Id, takim1, bold2, bold3, takim2Id, takim2, bold4, iy_td, ms_td, iyms11_td, iyms01_td, iyms21_td, iyms10_td, iyms00_td, iyms20_td, iyms12_td, iyms02_td, iyms22_td, altGrupAd10, grupId, altGrId);

                }


            }
        }
        document.getElementById('dvIYMS').innerHTML = sbScores;

    }
}