﻿$(document).ready(function() {
    $('#DDLTracks').val(Beygir.possibleRatio.city);
    $('#DDLTracks').change(
        function () {
            Beygir.possibleRatio.redirectPage();
        }
    );
   
    if(Beygir.possibleRatio.activePage == 1)
        Beygir.possibleRatio.init1();
    if(Beygir.possibleRatio.activePage == 2)
        Beygir.possibleRatio.init2();
    if(Beygir.possibleRatio.activePage == 3)
        Beygir.possibleRatio.init3();         
});

Beygir.possibleRatio = {
    city:null,
    raceNo:null,
    date:null,
    activePage:1,
    interval1:0,
    interval2:0,
    interval3:0,
    init1 : function()
    {
         var obj = Beygir.possibleRatio;
         obj.activePage = 1;
         
         window.clearInterval(obj.interval1);
         window.clearInterval(obj.interval2);
         window.clearInterval(obj.interval3);
        
         $('#buttonDiv').block({  
                message: '',
                centerY: 0, 
                overlayCSS: { 
                    opacity:'0',
                    border:'none'
                    }   
            });  
                  
         $.getJSON(Beygir.appPath+'/PossibleRatios/PossibleRatioAjax.aspx?city='+ obj.city + '&raceNo=' + obj.raceNo + '&date=' + obj.date , function(data) {
         
            $('#muhtemel').empty();
            $('#buttonDiv').unblock();
            
            var item=data.Muhtemel;
            
            if(item.Refresh == 1)
                obj.interval1 = window.setInterval('Beygir.possibleRatio.init1()', 60  * 1000);
            
            var muhtemelHtml = new Array();
            muhtemelHtml.push('<div style = "float:left;margin-top:10px;margin-left:8px;">');
            muhtemelHtml.push(obj.getFirstRace(item.Ganyan,1));
            if(item.Cifte.length > 0)  
                muhtemelHtml.push(obj.getSecondRace(item.SonrakiKosu,1));
            muhtemelHtml.push('</div>');
            
            $('#muhtemel').append(muhtemelHtml.join(''));
            
            if(item.Ikili.length > 0)
                $('#muhtemel').append(obj.getTableIkili(item.Ikili));
            if(item.SIkili.length > 0)    
                $('#muhtemel').append(obj.getTableSIkili(item.SIkili));
            if(item.Cifte.length > 0)        
                $('#muhtemel').append(obj.getTableCifte(item.Cifte));   
              
         });  // end of getJSON
         
         
    },
    getTableIkili : function(arr)
    {
        var strArr = new Array();
        var linkIkiliStr = '';
        
       strArr.push(Beygir.possibleRatio.getTableHeader('İkili'));
        
        $.each(arr, function(index1,item1) {
            linkIkiliStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'I\'' + ',\'' + item1.Rows[1] +  '\')';
            strArr.push('<tr height="17" onmouseover="HLon(this)" onmouseout="HLoff(this)"'+ (index1 %2 == 0 ? 'bgcolor="#f6f6f6"' : '') + '>');
            strArr.push('<td width="50" colspan="1" align="center">'+item1.Rows[1]+'</td>');
            strArr.push('<td width="60" align="right" style="padding-right:15px;"><a href="' +linkIkiliStr + '">' +item1.Rows[2]+'</a></td>');
            strArr.push('<td width="30" align="center" class="right-border"><img width="7" height="8" src="' + Beygir.imgPath + (item1.Rows[3] == 1 ? 'up.gif' :item1.Rows[3] == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>');
            strArr.push('</tr>');
         });

         strArr.push('</table>');
         strArr.push('</div>');
         strArr.push('</div>');
                    
         return strArr.join("");                   
    },
    getTableSIkili : function(arr)
    {
        var strArr = new Array();
        var linkSIkiliStr = '';
        
        strArr.push(Beygir.possibleRatio.getTableHeader('S. İkili'));
        
        $.each(arr, function(index1,item1) {
            linkSIkiliStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'S\'' + ',\'' + item1.Rows[1] +  '\')';
            strArr.push('<tr height="17" onmouseover="HLon(this)" onmouseout="HLoff(this)"'+ (index1 %2 == 0 ? 'bgcolor="#f6f6f6"' : '')  +'>');
            strArr.push('<td width="50" align="center">'+item1.Rows[1]+'</td>');
            strArr.push('<td width="60" align="right" style="padding-right:15px;"><a href="' +linkSIkiliStr + '">' +item1.Rows[2]+'</a></td>');
            strArr.push('<td width="30" align="center" class="right-border"><img width="7" height="8" src="' + Beygir.imgPath + (item1.Rows[3] == 1 ? 'up.gif' :item1.Rows[3] == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>');
            strArr.push('</tr>');
         });
         
         strArr.push('</table>');
         strArr.push('</div>');
         strArr.push('</div>');
                    
         return strArr.join("");                   
    },
    getTableCifte : function(arr)
    {
        var strArr = new Array();
        var linkCifteStr = '';
        
        strArr.push(Beygir.possibleRatio.getTableHeader('Çifte'));
        
        $.each(arr, function(index1,item1) {
            linkCifteStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'C\'' + ',\'' + item1.Rows[1] +  '\')';
            strArr.push('<tr height="17" onmouseover="HLon(this)" onmouseout="HLoff(this)"'+ (index1 %2 == 0 ? 'bgcolor="#f6f6f6"' : '')  +'>');
            strArr.push('<td  width="50" align="center">'+item1.Rows[1]+'</td>');
            strArr.push('<td  width="60" align="right" style="padding-right:15px;"><a href="' +linkCifteStr + '">' +item1.Rows[2]+'</a></td>');
            strArr.push('<td  width="30" align="center" class="right-border"><img width="7" height="8" src="' + Beygir.imgPath + (item1.Rows[3] == 1 ? 'up.gif' :item1.Rows[3] == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>');
            strArr.push('</tr>');
         });
         
         strArr.push('</table>');
         strArr.push('</div>');
         strArr.push('</div>');
                    
         return strArr.join("");                   
    },
    getTableHeader : function(colName)
    {
        var strArr = new Array();
        strArr.push('<div style="margin-left:5px;margin-top:10px;width:155px;float:left;">');
        strArr.push('<div style="clear:both;">');
        strArr.push('<table width="140" bgcolor="#e0f3fa" cellspacing="0" cellpadding="0" border="0" class="yazilar">');
        strArr.push('<tr height="23px" class="bld">');
        strArr.push('<td width="50" align="center">'+colName+'</td>');
        strArr.push('<td width="60" align="center">Muhtemel</td>');
        strArr.push('<td width="30" align="center">&nbsp;</td>');
        strArr.push('</tr>');
        strArr.push('</table>');
        strArr.push('</div>');
        
        strArr.push('<div class="tableContainer">');
        strArr.push('<table width="140"  cellspacing="0" cellpadding="0" border="0"  class="table-1 yazilar">');
        
        return strArr.join('');
     } ,  
    // gosterim 2 
    init2 : function()
    {
         var obj = Beygir.possibleRatio;
         obj.activePage = 2;
         
         window.clearInterval(obj.interval1);
         window.clearInterval(obj.interval2);
         window.clearInterval(obj.interval3);
         
         
          $('#buttonDiv').block({  
                message: '',
                centerY: 0, 
                overlayCSS: { 
                    opacity:'0',
                    border:'none'
                    }   
            }); 
                  
         $.getJSON(Beygir.appPath+'/PossibleRatios/PossibleRatioAjax1.aspx?city='+ obj.city + '&raceNo=' + obj.raceNo + '&date=' + obj.date , function(data) {
            $('#muhtemel').empty();
            $('#buttonDiv').unblock();
            
            var item=data.Muhtemel;
            
            if(item.Refresh == 1)
                obj.interval2 = window.setInterval('Beygir.possibleRatio.init2()', 60  * 1000);
            
            var muhHtml =  new Array();
            var item=data.Muhtemel.Atlar;
            
            muhHtml.push('<div align="center" style="margin-top:10px;">');
            muhHtml.push('<table width="714"  cellspacing="0" cellpadding="0" border="0"  class="table-5 yazilar" >');
            muhHtml.push('<tr id="tr-1" style="background-image: url('+Beygir.imgPath+'tablo-ort-ust.gif);" class="bld">');
            muhHtml.push('<td width="7"><img width="7" height="23" src="'+Beygir.imgPath+'tablo-sl-ust.gif"/></td>');
            muhHtml.push('<td width="150" align="center">İsim</td>');
            muhHtml.push('<td width="100" align="center">Ganyan</td>');
            muhHtml.push('<td width="150" align="center">İkili</td>');
            muhHtml.push('<td width="150" align="center">Sıralı İkili</td>');
            muhHtml.push('<td width="150" align="center">Çifte</td>');
            muhHtml.push('<td width="7" align="right"><img width="7" height="23" src="'+Beygir.imgPath+'tablo-sg-ust.gif"/></td>');
            muhHtml.push('</tr>');
            
             $.each(item, function(index1,item1) {
                var Ganyan = item1.G;
                var Ikili = item1.I;
                var SIkili= item1.SI;
                var Cifte = item1.C;
                var linkGanyanStr = '';
                var linkIkiliStr = '';
                var linkSIkiliStr = '';
                var linkCifteStr = '';
                
                muhHtml.push('<tr>');
                muhHtml.push('<td colspan="2" align="center"><a class="yazilar" href="javascript:HORSE('+item1.AtRefId+');"><b>'+item1.AtNo+'- ' + item1.AtIsim+'</b></a></td>');
                
                if(Ganyan.length > 0)
                {
                    linkGanyanStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'G\'' + ',\'' + Ganyan[0].k +  '\')';
                    muhHtml.push('<td align="center">'+ (Ganyan.length > 0 ? '<a href="' + linkGanyanStr + '">' + Ganyan[0].v + '</a>' : '&nbsp;') +'<img  width="7" height="8" style="padding-left:2px;" src="' + Beygir.imgPath + (Ganyan[0].c == 1 ? 'up.gif' : Ganyan[0].c == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>'); 
                }       
                                
                //Ikili
                muhHtml.push('<td>');
                muhHtml.push('<table class="table-4" width="75%" cellspacing="0" align="center" cellpadding="0" border="0"><tbody>');
                
                
                if(Ikili.length > 0)
                $.each(Ikili, function(Iindex,Iitem) {
                
                     linkIkiliStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'I\'' + ',\'' + Iitem.k +  '\')';   
                     muhHtml.push('<tr onmouseover="HLon(this)" onmouseout="HLoff(this)">');
                     muhHtml.push('<td width="50%" align="center">' + Iitem.k +'</td>')
                     muhHtml.push('<td width="50%" align="right">' + '<a href="' + linkIkiliStr + '">' + Iitem.v + '</a>' +  '<img width="7" style="padding-left:2px;" height="8" src="' + Beygir.imgPath + (Iitem.c == 1 ? 'up.gif' : Iitem.c == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>')
                     muhHtml.push('</tr>');
                 
                });
                
                muhHtml.push('</tbody></table>');
                muhHtml.push('</td>');
                
                //Sıralı Ikili
                muhHtml.push('<td>');
                muhHtml.push('<table class="table-4" width="75%" cellspacing="0" align="center" cellpadding="0" border="0"><tbody>');
                
                if(SIkili.length > 0)
                $.each(SIkili, function(SIindex,SIitem) {
                    linkSIkiliStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'S\'' + ',\'' + SIitem.k +  '\')';   
                    muhHtml.push('<tr onmouseover="HLon(this)" onmouseout="HLoff(this)">');
                    muhHtml.push('<td width="50%" align="center">' + SIitem.k + '</td>')
                    muhHtml.push('<td width="50%" align="right">' + '<a href="' + linkSIkiliStr + '">' + SIitem.v + '</a>' +'<img width="7" style="padding-left:2px;" height="8" src="' + Beygir.imgPath + (SIitem.c == 1 ? 'up.gif' : SIitem.c == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>')
                    muhHtml.push('</tr>');
                });
                
                muhHtml.push('</tbody></table>');
                muhHtml.push('</td>');
                
                //Cifte
                muhHtml.push('<td colspan="2" class="right-border">');
                muhHtml.push('<table class="table-4" width="75%" cellspacing="0" align="center" cellpadding="0" border="0"><tbody>');
                
                if(Cifte.length > 0)
                $.each(Cifte, function(Cindex,Citem) {
                    linkCifteStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'C\'' + ',\'' + Citem.k +  '\')';   
                     muhHtml.push('<tr onmouseover="HLon(this)" onmouseout="HLoff(this)">');
                     muhHtml.push('<td width="50%" align="center">' + Citem.k + '</td>')
                     muhHtml.push('<td width="50%" align="right">' + '<a href="' + linkCifteStr + '">' + Citem.v + '</a>' +'<img width="7" style="padding-left:2px;" height="8" src="' + Beygir.imgPath + (Citem.c == 1 ? 'up.gif' : Citem.c == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>')
                     muhHtml.push('</tr>');
                });
                
                muhHtml.push('</tbody></table>');
                muhHtml.push('</td>');
                
                muhHtml.push('</tr>');
             });
             
            muhHtml.push('</table>');
            muhHtml.push('</div>');
                
            $('#muhtemel').append(muhHtml.join(""));     
            $('#muhtemel').append(Beygir.possibleRatio.getRaceFooter2());    
            
            
         });  // end of getJSON
    },
    getRaceFooter2 : function()
    {
        var strArr = new Array(); 
        strArr.push('<div align="center">');
        strArr.push('<table width="714" cellspacing="0" cellpadding="0" border="0" >');
        strArr.push('<tr style="background-image: url('+Beygir.imgPath+'tablo-ort-ust.gif);" class="yazilar bld rowWithoutBorder">');
        strArr.push('<td width="7"><img width="7" height="23" src="'+Beygir.imgPath+'tablo-sl-alt.gif"/></td>');
        strArr.push('<td width="700">&nbsp;</td>');
        strArr.push('<td width="7" align="right"><img  width="7" height="23" src="'+Beygir.imgPath+'tablo-sg-alt.gif"/></td>');
        strArr.push('</tr></table>');
        strArr.push('</div>');
        return strArr.join("");     
    },
    // gosterim 3
   init3 : function()
    {
         var obj = Beygir.possibleRatio;
         obj.activePage = 3;
         
         window.clearInterval(obj.interval1);
         window.clearInterval(obj.interval2);
         window.clearInterval(obj.interval3);
            
          $('#buttonDiv').block({  
                message: '',
                centerY: 0, 
                overlayCSS: { 
                    opacity:'0',
                    border:'none'
                    }   
            }); 
            
         $.getJSON(Beygir.appPath+'/PossibleRatios/PossibleRatioAjax2.aspx?city='+ obj.city + '&raceNo=' + obj.raceNo + '&date=' + obj.date , function(data) {
         
            $('#muhtemel').empty();
            $('#buttonDiv').unblock();
            
            var item=data.Muhtemel;
            
            if(item.Refresh == 1)
                obj.interval3 = window.setInterval('Beygir.possibleRatio.init3()', 60  * 1000);
             
             
            if(item.Ikili.length > 0)
            {
                $('#muhtemel').append(obj.getMatrixTitle('İkili'));
                $('#muhtemel').append(obj.getMatrixTable(item.Ganyan,'i'));
                $.each(item.Ikili, function(index,item) {
                     $('#ix'+item.Rows[1]+'y'+item.Rows[2]).html(item.Rows[3]);
                });
                for(i=1;i<=item.Ganyan.length;i++)
                    $('#ix'+i+'y'+i).html('<b>X</b>');
            }
            
            if(item.SIkili.length > 0)
            {
                $('#muhtemel').append(obj.getMatrixTitle('Sıralı İkili'));
                $('#muhtemel').append(obj.getMatrixTable(item.Ganyan,'si'));
                $.each(item.SIkili, function(index,item) {
                      $('#six'+item.Rows[1]+'y'+item.Rows[2]).html(item.Rows[3]);
                });
                for(i=1;i<=item.Ganyan.length;i++)
                    $('#six'+i+'y'+i).html('<b>X</b>');
            }
            
            if(item.Cifte.length > 0)
            {
                
                $('#muhtemel').append(obj.getMatrixTitle('Çifte'));    
                $('#muhtemel').append(obj.getMatrixTableForCifte(item.Ganyan,'c',item.SonrakiKosu.length));
                $.each(item.Cifte, function(index,item) {
                     $('#cx'+item.Rows[1]+'y'+item.Rows[2]).html(item.Rows[3]);
                });
            }
            
            var newHtml = new Array();             

            newHtml.push('<div style="clear:both;margin-top:5px;margin-left:10px;" >');
            
            newHtml.push(obj.getFirstRace(item.Ganyan,2));
           
            newHtml.push('<div style="float:left;">');
            
            if(item.Cifte.length > 0)  
                newHtml.push(obj.getSecondRace(item.SonrakiKosu,2));
            
            newHtml.push('</div>')
            newHtml.push('</div>')
             $('#muhtemel').append(newHtml.join(''));
             
         });  // end of getJSON     
            
     },
     getMatrixTableForCifte : function(arr,colId,nextRaceCount)
     {
        var i = 1;
        var j = 1;
        var matrixHtml = new Array();
        matrixHtml.push('<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" class="table-6 fnt-s10 site-font" style="border-left:1px solid #dedede;margin-top:10px;margin-bottom:10px;">');
        matrixHtml.push('<tr style="background-image: url('+Beygir.imgPath+'cifte-2kosu.gif);" class="yazilar bld" align="center">');
        
        matrixHtml.push('<td width="60" >İkinci At</td>');
        for(i=1;i<=22;i++)
            matrixHtml.push('<td  rowspan="2">'+i+'</td>');
        matrixHtml.push('</tr>');
        matrixHtml.push('<tr style="border-top:1px solid #d2d2d2;" class="yazilar bld" align="center"><td bgcolor="#b6dffb" width="45">Birinci At</td></tr>');    
        
        for(i=1;i<=arr.length;i++)
        {
            matrixHtml.push('<tr height="20px" align="center">');
            matrixHtml.push('<td  class="site-font fnt-size" bgcolor="#b6dffb" >'+i+'</td>');
            for(j=1;j<=22;j++)
            {
                matrixHtml.push('<td width="30px" onmouseover="Beygir.possibleRatio.HMovOn(\''+colId+'\','+i+','+j+')" onmouseout="Beygir.possibleRatio.HMovOut(\''+colId+'\','+i+','+j+')" id="'+colId+'x'+i+'y'+j+'" >&nbsp</td>');
            }
            
            matrixHtml.push('</tr>');
        }
        
        matrixHtml.push('</table>');
        
        return matrixHtml.join('');
        
    },
     getMatrixTable : function(arr,colId)
     {
        var i = 1;
        var j = 1;
        var linkGanyanStr = '';
        var matrixHtml = new Array();
        matrixHtml.push('<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" class="table-6 fnt-s10 site-font" style="border-left:1px solid #dedede;margin-top:10px;margin-bottom:10px;">');
        matrixHtml.push('<tr style="background-image: url('+Beygir.imgPath+'22-bg.gif);" class="yazilar bld" align="center">');
        matrixHtml.push('<td width="50" background="'+Beygir.imgPath+'mhtml-gny-bg.gif" style="border-top: 1px solid rgb(222, 222, 222);" rowspan="2">Ganyan</td>');
        matrixHtml.push('<td width="130">İkinci At</td>');
        for(i=1;i<=22;i++)
            matrixHtml.push('<td  rowspan="2">'+i+'</td>');
        matrixHtml.push('</tr>');
        matrixHtml.push('<tr style="background-color:#f3f3f3" class="yazilar bld"><td align="center">Birinci At</td></tr>');    
        
        for(i=1;i<=arr.length;i++)
        {
            linkGanyanStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'G\'' + ',\'' + arr[i-1].Rows[1] +  '\')';
            matrixHtml.push('<tr height="20px" align="center">');
            matrixHtml.push('<td class="yazilar"><a href="'+linkGanyanStr+'">'+arr[i-1].Rows[3]+'</td>');
            matrixHtml.push('<td  class="site-font fnt-size" style="background-color:#f3f3f3" align="left"><a class="yazilar" href="javascript:HORSE('+arr[i-1].Rows[5]+')">'+i+'- '+arr[i-1].Rows[2]+'</td>');
            for(j=1;j<=22;j++)
            {
                matrixHtml.push('<td width="25px" onmouseover="Beygir.possibleRatio.HMovOn(\''+colId+'\','+i+','+j+')" onmouseout="Beygir.possibleRatio.HMovOut(\''+colId+'\','+i+','+j+')" id="'+colId+'x'+i+'y'+j+'" >&nbsp</td>');
            }
            
            matrixHtml.push('</tr>');
        }
        
        matrixHtml.push('</table>');
        
        return matrixHtml.join('');
        
    },
    getMatrixTitle : function(title)
    {
        var strArr = new Array();
        
        strArr.push('<table class="haber-bslk bld kirmizi" width="100%" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid rgb(210, 210, 210);">');
        strArr.push('<tr>')
        strArr.push('<td  height="26" background="'+Beygir.imgPath+'basliklar-background.gif" style="padding-left: 5px;"><img width="7" height="7" src="'+Beygir.imgPath+'arrow-red.gif"/><span class="jockey-name"> '+title+' </span></td>')
        strArr.push('</tr></table>');
        
        return strArr.join('');
    },
    getFirstRace : function(arr,flag)
    {
        var strArr = new Array();
        
        strArr.push('<table width="'+(flag == 1 ? '250px' : '360px') + '" cellspacing="0" cellpadding="0" border="0" class="yazilar table-1" style="float:left" >');
        strArr.push('<tr>')
        strArr.push('<td height="23" colspan="4" align="center" class="right-border" style="background-image: url('+Beygir.imgPath+'cifte-ilk.gif);border-top:1px solid #dedede"><b>'+Beygir.possibleRatio.raceNo+'.Koşu</b></td>');
        strArr.push('</tr>')
        strArr.push('<tr>')
        strArr.push('<td width="10%" align="center"><b>NO</b></td>');
        strArr.push('<td width="58%" align="center"><b>AT İSMİ</b></td>');
        strArr.push('<td width="16%" align="center"><b>GANYAN</b></td>');
        strArr.push('<td width="16%" class="right-border">&nbsp;</td>');
        strArr.push('</tr>');
        
        $.each(arr, function(index1,item1) {
           linkGanyanStr = 'javascript:MUHTEMEL(\''+Beygir.possibleRatio.date + '\',' + Beygir.possibleRatio.city + ',' + Beygir.possibleRatio.raceNo + ',' + '\'G\'' + ',\'' + item1.Rows[1] +  '\')';
           strArr.push('<tr height="17" onmouseover="HLon(this)" onmouseout="HLoff(this)"'+  '>');
           strArr.push('<td align="right" style="padding-right:'+ (flag == 1 ? '5px' : '10px') +';">'+item1.Rows[1]+'</td>');
           strArr.push('<td style="padding-left:'+ (flag == 1 ? '4px' : '6px') +';"><a class="yazilar" href="javascript:HORSE('+item1.Rows[5]+');">'+item1.Rows[2]+'</a></td>');
           strArr.push('<td align="right" style="padding-right:'+ (flag == 1 ? '5px' : '10px') +';">'+ (item1.Rows[3] == '0,00' ? '<span class="kirmizi">Koşmaz</span>' : ('<a href="' +linkGanyanStr + '">' + item1.Rows[3]+'</a>') )+'</td>');
           strArr.push('<td align="center" class="right-border"><img width="7" height="8" src="' + Beygir.imgPath + (item1.Rows[4] == 1 ? 'up.gif' :item1.Rows[4] == 2 ? 'down.gif' :'sabit.gif' ) + '"/></td>');
           strArr.push('</tr>');
         });
         
        strArr.push('</table>');
        
        return strArr.join('');
    },
    getSecondRace : function(arrSR,flag)
    {
        var strArr = new Array();
        var secRaceNo = parseInt(Beygir.possibleRatio.raceNo)+1;
        
        strArr.push('<table cellspacing="0" cellpadding="0" border="0" class="yazilar table-1" width="'+(flag == 1 ? '250px" style="clear:both;margin-top:5px;' : '360px" style="float:left;margin-left:10px;' )+'">');
        strArr.push('<tr>')
        strArr.push('<td align="center" height="23" background="'+Beygir.imgPath+'cifte-2kosu.gif" class="menu2-style bld" colspan="4">'+secRaceNo+'.Koşu</td>');
        strArr.push('</tr>')
        strArr.push('<tr>')
        strArr.push('<td width="10%" align="center"><b>NO</b></td>');
        strArr.push('<td width="58%" align="center"><b>AT İSMİ</b></td>');
        strArr.push('<td width="16%" align="center"><b>BLT</b></td>');
        strArr.push('<td width="16%" align="center" class="right-border"><b>HND</b></td>');
        strArr.push('</tr>');
        
        $.each(arrSR, function(index1,item1) {
           strArr.push('<tr height="17" onmouseover="HLon(this)" onmouseout="HLoff(this)"' + '>');
           strArr.push('<td align="right" style="padding-right:'+ (flag == 1 ? '5px' : '10px') +';">'+item1.Rows[0]+'</td>');
           strArr.push('<td style="padding-left:'+ (flag == 1 ? '4px' : '6px') +';"><a class="yazilar" href="javascript:HORSE('+item1.Rows[4]+')">'+item1.Rows[1]+'</td>');
           strArr.push('<td align="right" style="padding-right:'+ (flag == 1 ? '8px' : '20px') +';">'+ item1.Rows[2]+'&nbsp;</td>');
           strArr.push('<td align="right" class="right-border" style="padding-right:'+ (flag == 1 ? '8px' : '20px') +';">'+item1.Rows[3]+'&nbsp;</td>');
           strArr.push('</tr>');
         });
         
        strArr.push('</table>');
        
        return strArr.join('');
    },
    redirectPage : function() 
	{  
		location.href=  Beygir.appPath+'/PossibleRatios/PossibleRatio.aspx?city=' + $('#DDLTracks').val()  ;	
	},
	redirectPageForRaceNo : function() 
	{  
		location.href=  Beygir.appPath+'/PossibleRatios/PossibleRatio.aspx?city=' + $('#DDLTracks').val() + '&raceNo=' + Beygir.possibleRatio.raceNo ;	
	},
	refreshPage : function() 
	{  
		location.href=  Beygir.appPath+'/PossibleRatios/PossibleRatio.aspx?p=' + Beygir.possibleRatio.activePage  ;	
	},
	HMovOn : function (tag,x,y)
	{
	    var i = 1;
	    var j = 1;
	    var colId = '';
	    
	    for(i=1;i<=x;i++)
	    {
	        colId = '#' + tag + 'x' + i + 'y' + y ;
	        $(colId).css({backgroundColor:'#e0f3fa'}); 
	    }
	    
	    for(j=1;j<=y;j++)
	    {
	        colId = '#' + tag + 'x' + x + 'y' + j ; 
	        $(colId).css({backgroundColor:'#f3f3f3'})
	    }   
	    
	    colId = '#' + tag + 'x' + x + 'y' + y ;  
	    $(colId).css({backgroundColor:'#b6dffd'})
	            
	},
	HMovOut : function (tag,x,y)
	{
	    var i = 1;
	    var j = 1;
	    var colId = '';
	    
	    for(i=1;i<x;i++)
	    {
	        colId = '#' + tag + 'x' + i + 'y' + y ;
	        $(colId).css({backgroundColor:'#ffffff'}); 
	    }
	    
	    for(j=1;j<y;j++)
	    {
	        colId = '#' + tag + 'x' + x + 'y' + j ; 
	        $(colId).css({backgroundColor:'#ffffff'})
	    }   
	   
	    colId = '#' + tag + 'x' + x + 'y' + y ;  
	    $(colId).css({backgroundColor:'#ffffff'})
	            
	}
   
}    