﻿// JScript File
var NumberOfTodayKupons=null;
var NumberOfAllKupons=null;
var pageIndex=1;
var NumberOfPages;
var mods= {TodaysKupons:0, AllKupons:1};
var currentmod = null;
var tarih1;
var tarih2;
var raptarih1;
var raptarih2;

function GetNumberOfTodayKupons()
{
    MyAjaxClass.GetNumberOfTodayKupons(GetNumberOfTodayKupons_callback,null,null,null,onTimeoutGetNumberOfTodayKupons,null);
}
function onTimeoutGetNumberOfTodayKupons()
{
    return true;    
}
function GetNumberOfTodayKupons_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    NumberOfTodayKupons=res;
    if (NumberOfTodayKupons==0)
    {
        obj("span_numbahis").innerHTML=""
        obj("div_history_header").innerHTML=msg50;
        obj("tbl_historicbets").style.visibility="hidden";
    }
    else
    {
        obj("div_history_header").innerHTML=msg51;
        obj("span_numbahis").innerHTML=formatinteger(NumberOfTodayKupons)+"&nbsp;"+msg52;
        obj("tbl_historicbets").style.visibility="";
    }
    NumberOfPages=Math.ceil(NumberOfTodayKupons/15);
    if (NumberOfPages>1) 
        obj("td_next").style.visibility="";
    else
        obj("td_next").style.visibility="hidden";
        
    obj("td_prev").style.visibility="hidden";
    
}
function GetNumberOfAllKupons()
{
    MyAjaxClass.GetNumberOfAllKupons(raptarih1, raptarih2, GetNumberOfAllKupons_callback, null, null, null, onTimeoutGetNumberOfAllKupons, null);
}


function onTimeoutGetNumberOfAllKupons()
{
    return true;
}
function GetNumberOfAllKupons_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    NumberOfAllKupons=res;
    if (NumberOfAllKupons==0)
    {
        obj("span_numbahis").innerHTML="";
        obj("div_history_header").innerHTML=msg53;
        obj("tbl_historicbets").style.visibility="hidden";
    }
    else
    {
        obj("tbl_historicbets").style.visibility="";
        obj("div_history_header").innerHTML=msg54;
        obj("span_numbahis").innerHTML=formatinteger(NumberOfAllKupons)+"&nbsp;"+msg52;
    }
    NumberOfPages=Math.ceil(NumberOfAllKupons/15);
    
    if (NumberOfPages>1) 
        obj("td_next").style.visibility="";
    else
        obj("td_next").style.visibility="hidden";
        
    obj("td_prev").style.visibility="hidden";
}
function GetTodayKupons()
{
    MyAjaxClass.GetTodayKupons(pageIndex,GetTodayKupons_callback,null,null,null,onTimeoutGetTodayKupons,null);
}
function onTimeoutGetTodayKupons()
{
    return true;
}
function GetTodayKupons_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    fillhistorickupontable(res.Kupons);
}


function GetAllKupons()
{
    MyAjaxClass.GetAllKupons(raptarih1, raptarih2, pageIndex, GetAllKupons_callback, null, null, null, onTimeoutGetAllKupons, null);
}


function onTimeoutGetAllKupons()
{
    return true;
}
function GetAllKupons_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    fillhistorickupontable(res.Kupons);
}

function fillhistorickupontable(res)
{
    var oTable=$("tbody_historicbets");
    for (;oTable.rows.length>0;)
           oTable.deleteRow(0);
    if (!res) return;
    var oRow ;
    var oCell;
    var textcolor;
    var sayi= res.length;
    for (var i=0;i<res.length;i++)
    {
        //res.length
        switch (res[i].SONUC.substr(0, 3)) {
            case "-":
                textcolor = "#2d61d7";
                break;
            case "KAY":
                textcolor = "#cb0c05";
                break;
            case "KAZ":
                textcolor = "#106404";
                break;
            default:
                textcolor = "#000000";
        }
        
        
        oRow = oTable.insertRow(-1);
        oRow.id="tr_bet_"+res[i].BAHIS_ID;
        oRow.setAttribute("bahisID",res[i].BAHIS_ID);
        document.getElementById(oRow.id).onclick=function(){getBetDetail(this);obj("div_betdetail").style.left=docjslib_getRealLeft(this)+100+"px";obj("div_betdetail").style.top=docjslib_getRealTop(this)+this.offsetHeight+"px";};
        
        oCell = oRow.insertCell(-1);
        oCell.align = "right";
        oCell.style.color = textcolor;
        oCell.innerHTML=res[i].RN;
        
        oCell = oRow.insertCell(-1);
        oCell.align = "right";
        oCell.style.color = textcolor;
        oCell.innerHTML=res[i].BAHIS_ID;

        oCell = oRow.insertCell(-1);
        oCell.style.color = textcolor;
        oCell.innerHTML=res[i].TARIH_SAAT;
        oCell.align="center";
        
        oCell = oRow.insertCell(-1);
        oCell.align = "right";
        oCell.style.color = textcolor;
        oCell.innerHTML=myfixed(res[i].TUTAR);
        
        oCell = oRow.insertCell(-1);
        oCell.align="center";
        
        switch (res[i].SONUC.substr(0,3))
        {
            case "-":
                oRow.className = "unknown";
                oCell.style.color = "#2d61d7";
                oCell.innerHTML=msg32;
                break;
            case "KAY":
                oRow.className = "lose";
                oCell.style.color = "#cb0c05";
                oCell.innerHTML=msg33;
                break;
            case "KAZ":
                oRow.className = "win";
                oCell.style.color = "#106404";
                oCell.innerHTML=msg34;
                break;
            default:
                oCell.innerHTML=res[i].SONUC;
        }
    }
}

function changemod()
{
    pageIndex=1;
    obj('div_betdetail').style.display='none';
    obj("div__oncekibahisler").style.display="none";
    obj("div_bahisler").style.display="block";
    
    if (currentmod==mods.TodaysKupons) currentmod=mods.AllKupons; else currentmod=mods.TodaysKupons;
    
    if (currentmod==mods.TodaysKupons)
    {
        obj("a_changemod").innerHTML = msg49;
        obj("div_oncekibahisler_tarih").style.display = "none";
        GetNumberOfTodayKupons()
        GetTodayKupons(); 
    }
    else 
    {
        obj("a_changemod").innerHTML = msg48;
        obj("div_oncekibahisler_tarih").style.display = "block";
        
    }
}

function oncekibahis_hepsi() {


    pageIndex = 1;
    raptarih1 = obj("tarih3").value;
    raptarih2 = obj("tarih4").value;
    tarih1 = getFieldDate(raptarih1);
    tarih2 = getFieldDate(raptarih2);

    d1 = new Date(tarih1);
    d2 = new Date(tarih2);
    d1.setDate(d1.getDate());
    d2.setDate(d2.getDate());

    if (raptarih1.length < 10) { alert("Başlangıç Tarihi Seçiniz !"); return false; }
    if (raptarih2.length < 10) { alert("Bitiş Tarihi Seçiniz !"); return false; }

    d1gun = "00" + d1.getDate();
    d1ay = "00" + (d1.getMonth() + 1);
    d1gun = d1gun.substring(d1gun.length - 2);
    d1ay = d1ay.substring(d1ay.length - 2);
    d1yil = d1.getYear();

    d2gun = "00" + d2.getDate();
    d2ay = "00" + (d2.getMonth() + 1);
    d2gun = d2gun.substring(d2gun.length - 2);
    d2ay = d2ay.substring(d2ay.length - 2);
    d2yil = d2.getYear();

    if (d1 > d2) {
        alert("Başlangıç tarihi bitiş tarihinden büyük olamaz !");
        return false;
    }

    var guncount = (d2gun - d1gun);
    if (guncount > 7) {
        alert("Rapor tarih aralığı 7 günden büyük olamaz !");
        return false; 
    }
    GetNumberOfAllKupons();
    GetAllKupons();
}


function prevpage()
{
    obj('div_betdetail').style.display='none';
    --pageIndex;
    if (currentmod==mods.TodaysKupons) GetTodayKupons(); else GetAllKupons();
    if (pageIndex==1) obj("td_prev").style.visibility="hidden";
    obj("td_next").style.visibility="";
}
function nextpage()
{
    obj('div_betdetail').style.display='none';
    ++pageIndex;
    if (currentmod==mods.TodaysKupons) GetTodayKupons(); else GetAllKupons();
    obj("td_prev").style.visibility="";
    if (pageIndex==NumberOfPages) obj("td_next").style.visibility="hidden";
}
function getHistoricalKupons()
{
    GetAllKupons();   
}
function getBetDetail(r)
{
   MyAjaxClass.GetBetDetails(r.getAttribute("bahisID")+"",GetBetDetails_callback,null,null,null,onTimeoutGetBetDetails,null);
}

function onTimeoutGetBetDetails()
{
    return true;
}
function GetBetDetails_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    obj("div_betdetail").innerHTML="";
    var res =r.value; 
    if (!res.isLoggedIn) 
    {
        loggedOff();
        alert(msg27);
        return;
    }
    
    var bahis_detailTable=res.DsBetDetail.Tables[1];
    var bahis_masterTable=res.DsBetDetail.Tables[0];
    if (bahis_masterTable.Rows.length==0 || bahis_detailTable.Rows.length==0) 
    {
        alert(msg47);
        return;
    }
    var masterRow=bahis_masterTable.Rows[0];
    
    var oRow ;
    var oCell;
        
    var oTablePrint=document.createElement("table");
    oTablePrint.style.marginBottom = "5px";
    oRow = oTablePrint.insertRow(-1);
    oCell = oRow.insertCell(-1);    
    oCell.innerHTML="&nbsp;"
    
    oCell = oRow.insertCell(-1);    
    oCell.id="td_betdetail_print"
    oCell.style.textAlign = "center";
    oCell.style.fontWeight = "bold";
    oCell.style.color = "white";
    oCell.style.width="80px";
    oCell.style.cursor="pointer";
    oCell.setAttribute("BAHIS_ID",masterRow.BAHIS_ID);
    oCell.innerHTML=msg8;
    
    oCell = oRow.insertCell(-1);    
    oCell.id="td_betdetail_close"
    oCell.style.cursor="pointer";
    oCell.style.textAlign = "center";
    oCell.style.fontWeight = "bold";
    oCell.style.color = "white";
    oCell.style.width="80px";
    oCell.innerHTML=msg9;
    
    
        
    var oTableHead=document.createElement("table");
    oRow = oTableHead.insertRow(-1);
    oCell = oRow.insertCell(-1);
    oCell.style.textAlign = "center";
    oCell.style.fontWeight = "bold";
    oCell.style.color = "white";
    oCell.innerHTML=msg56+masterRow.TARIH_SAAT+" "+msg57+masterRow.BAHIS_ID;
       
    if (res.Bayi>1 && masterRow.SONUC.substr(0,3)=="KAZ" &&  !masterRow.ODEME_TARIHI)
    {
        oRow = oTableHead.insertRow(-1);
        oCell = oRow.insertCell(-1);    
        oCell.setAttribute("BAHIS_ID",masterRow.BAHIS_ID);
        oCell.style.textAlign="center";
        oCell.id="td_betdetail_kuponode";
        oCell.innerHTML="Kuponu ödemek için tıklayınız";
    }
    if ((res.isLocal ||  res.Bayi>1) &&  masterRow.SONUC=="-"  &&  masterRow.DAKIKA<=15)
    {
        oRow = oTableHead.insertRow(-1);
        oCell = oRow.insertCell(-1);    
        oCell.setAttribute("BAHIS_ID",masterRow.BAHIS_ID);
        oCell.style.textAlign="center";
        oCell.id="td_betdetail_kuponsil";
        oCell.innerHTML=msg55;
    }
    var oTable1=document.createElement("table");
    oTable1.cellPadding="3";
    oTable1.cellSpacing="1";
    
    oRow = oTable1.insertRow(-1);
    oRow.style.backgroundColor = "#dddddd";
    oCell = oRow.insertCell(-1);    
    oCell.style.width="75px";
    oCell.style.textAlign="center";
    oCell.innerHTML=res.System;
    
    oCell = oRow.insertCell(-1);    
    oCell.innerHTML="&nbsp;"+msg46+" :"+myfixed(masterRow.TUTAR);
    oCell.style.textAlign="left";
    
    
    
    oRow = oTable1.insertRow(-1);
    oRow.style.backgroundColor = "#dddddd";
    oCell = oRow.insertCell(-1);    
    oCell.innerHTML="";
    oCell = oRow.insertCell(-1);    
    
    
    switch (masterRow.SONUC.substr(0,3))
    {
        case "-":
            oTable1.style.color = "#2d61d7";
            oTableHead.style.color = "#2d61d7";
            oCell.style.textAlign = "left";
            oCell.style.color = "#2d61d7";
            oCell.innerHTML="&nbsp;"+msg32;
            break;
        case "KAY":
            oTable1.style.color = "#cb0c05";
            oTableHead.style.color = "#cb0c05";
            oCell.style.textAlign = "left";
            oCell.style.color = "#cb0c05";
            oCell.innerHTML="&nbsp;"+msg33;
            break;
        case "KAZ":
            oTable1.style.color = "#106404";
            oTableHead.style.color = "#106404";
            oCell.style.textAlign = "left";
            oCell.style.color = "#106404";
            
            var gun = masterRow.TARIH_SAAT.substr(0,2);
            var ay = masterRow.TARIH_SAAT.substr(3,2);
            var yil = masterRow.TARIH_SAAT.substr(6,4);
            var mrTarih = ay + "-" + gun + "-" + yil
            var dateString = mrTarih;  // MM-dd-yyyy
            var dateString_ = "02-11-2011";  // MM-dd-yyyy
            
            var kuponDate = new Date(dateString);
            var bonusDate = new Date(dateString_);
            
            if (kuponDate > bonusDate){
                oCell.innerHTML="&nbsp;"+msg45+" :"+myfixed(masterRow.KAZANDIGI_TUTAR + masterRow.BONUS);
            }
            else {
                oCell.innerHTML="&nbsp;"+msg45+" :"+myfixed(masterRow.KAZANDIGI_TUTAR);
            }
 
            
            
            break;
        default:
            oCell.innerHTML=res.Rows[i].SONUC;
    }
    
    if (bahis_detailTable.Rows[0].BAHIS_TIPI==5 || bahis_detailTable.Rows[0].BAHIS_TIPI==4) //LOTO ise
    {
        var lotoTable=res.DsBetDetail.Tables[2];
        oRow = oTable1.insertRow(-1);
        oRow.style.backgroundColor = "#dddddd";
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML="";
        oCell = oRow.insertCell(-1);
        oCell.style.textAlign = "left";
        oCell.innerHTML = "&nbsp;" + lotoTable.Rows[0].CEKILIS_TARIHI + msg58; ;
        
        if (lotoTable.Rows[0].KAZANAN_NO1 && lotoTable.Rows[0].KAZANAN_NO1>0)
        {
            oRow = oTable1.insertRow(-1);
            oRow.style.backgroundColor = "#dddddd";
            oCell = oRow.insertCell(-1);    
            oCell.innerHTML="";
            oCell = oRow.insertCell(-1);    
            oCell.style.textAlign="left";
            oCell.innerHTML = "&nbsp;" + msg44 + " : " + lotoTable.Rows[0].KAZANAN_NO1 + "," + lotoTable.Rows[0].KAZANAN_NO2 + "," + lotoTable.Rows[0].KAZANAN_NO3 + "," + lotoTable.Rows[0].KAZANAN_NO4 + "," + lotoTable.Rows[0].KAZANAN_NO5 + "," + lotoTable.Rows[0].KAZANAN_NO6
        }
    }
    
    var oTable=document.createElement("table");
    oTable.style.marginBottom="10px";
    oTable.cellPadding="2";
    oTable.cellSpacing="2";
    oTable.style.color=oTable1.style.color;
    oTable.style.textAlign="center";
    oTable.style.width="310px";
    oTable.border="1";
    oTable.borderColor = "#cccccc";
    
    oTable.style.borderWidth="1px";
    oTable.style.borderStyle="solid";
    oTable.style.borderColor = "#cccccc";
    
    if (bahis_detailTable.Rows[0].BAHIS_TIPI==5 || bahis_detailTable.Rows[0].BAHIS_TIPI==4) 
    {
        oRow = oTable.insertRow(-1);
        oRow.style.backgroundColor = "#cccccc";
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg39;
        oCell = oRow.insertCell(-1);
        oCell.innerHTML = msg43;
        var control = 0;
        var bgcolor;
        var textcolor;
        for (var i=0;i<bahis_detailTable.Rows.length;i++)
        {
            if (control % 2) { bgcolor = "#cccccc"; }
            else { bgcolor = "#dddddd"; }

            switch (bahis_detailTable.Rows[i].SONUC.substr(0, 3)) {
                case "-":
                    textcolor = "#2d61d7";
                    break;
                case "KAY":
                    textcolor = "#cb0c05";
                    break;
                case "KAZ":
                    textcolor = "#106404";
                    break;
                default:
                    textcolor = "#000000";
            }
            
            
            oRow = oTable.insertRow(-1);
            oRow.style.backgroundColor = bgcolor;
            
            oCell = oRow.insertCell(-1);
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = textcolor;
            oCell.innerHTML=bahis_detailTable.Rows[i].TAHMIN;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            switch (bahis_detailTable.Rows[i].SONUC.substr(0,3))
            {
                case "-":
                    oCell.style.color = "#2d61d7";
                    oCell.innerHTML=msg32;
                    break;
                case "KAY":
                    oCell.style.color = "#cb0c05";
                    oCell.innerHTML=msg33;
                    break;
                case "KAZ":
                    oCell.style.color = "#106404";
                    oCell.innerHTML=msg34;
                    break;
                default:
                    oCell.innerHTML=res.Rows[i].SONUC;
            }
        }
    }
    else
    {
        oRow = oTable.insertRow(-1);
        oRow.style.backgroundColor = "#cccccc";
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg35;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg36;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg37;
        oCell.style.whiteSpace="nowrap";
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg38;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg39;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg40;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg41;
        oCell = oRow.insertCell(-1);    
        oCell.innerHTML=msg42;
        oCell = oRow.insertCell(-1);
        oCell.innerHTML = msg43;


        var kontrol = 0;
        var renk;
        var yazirenk;
        var aciklamaTDtext;
        var tahmin;    
        for (var i=0;i<bahis_detailTable.Rows.length;i++)
        {


            if (kontrol % 2) {renk = "#cccccc"; }
            else { renk = "#dddddd"; }


            switch (bahis_detailTable.Rows[i].SONUC.substr(0, 3)) {
                case "-":
                    yazirenk = "#2d61d7";
                    break;
                case "KAY":
                    yazirenk = "#cb0c05";
                    break;
                case "KAZ":
                    yazirenk = "#106404";
                    break;
                default:
                    yazirenk = "#000000";
            }
            
            oRow = oTable.insertRow(-1);
            oRow.style.backgroundColor = renk;
            oCell = oRow.insertCell(-1);
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            if (bahis_detailTable.Rows[i].BAHISOR_ID>0) 
                oCell.innerHTML="or "+bahis_detailTable.Rows[i].MAC_KODU;
            else
                oCell.innerHTML=bahis_detailTable.Rows[i].MAC_KODU;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=bahis_detailTable.Rows[i].TARIH;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=bahis_detailTable.Rows[i].T1;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=bahis_detailTable.Rows[i].T2;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            
            
                        
            
            
            switch (bahis_detailTable.Rows[i].ACIKLAMA_ID) {
                        case 0: //Mac Sonucu
                            aciklamaTDtext = bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 1: //Away Handikap
                            aciklamaTDtext = 'HND:'+bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 2: //Home - Draw Handikap
                            aciklamaTDtext = 'HND:'+bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 3: //ALT ÜST
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "ALT";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "ÜST";
                            aciklamaTDtext = bahis_detailTable.Rows[i].ACIKLAMA1 + bahis_detailTable.Rows[i].ACIKLAMA2 + ":" + tahmin;
                            break;
                        case 4: //İLK YARI
                            aciklamaTDtext = 'İlk Yarı:' + bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 5: //İLK GOL
                            aciklamaTDtext = 'İlk Gol:' + bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 6: //GOL SAYISI
                            aciklamaTDtext = "Tek/Çift Gol:" + bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 7: //TENİS MAÇ SONUCU 
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "2:1";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "1:2";
                            aciklamaTDtext = 'Set:' + tahmin;
                            break;
                        case 8: //TENİS MAÇ SONUCU 
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "2:1";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "1:2";
                            aciklamaTDtext = 'Set:' + tahmin;
                            break;
                        case 9: //ÇİFTE ŞANS
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "1/0";
                            if (bahis_detailTable.Rows[i].TAHMIN == 0) tahmin = "0/2";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "1/2";
                            aciklamaTDtext = 'ÇifteŞans:' + tahmin;
                            break;
                        case 10: //ASIAN
                            aciklamaTDtext = "ASIAN:" + bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 11: //KORNER ALTI/USTU
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "ALTI";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "USTU";
                            aciklamaTDtext = bahis_detailTable.Rows[i].ACIKLAMA1 + "Korner:" + tahmin;
                            break;
                        case 12: //EN FAZLA GOL
                            if (bahis_detailTable.Rows[i].TAHMIN == 1) tahmin = "İlkYarı";
                            if (bahis_detailTable.Rows[i].TAHMIN == 2) tahmin = "İkinciYarı";
                            aciklamaTDtext = "EnFazlaGol:" + tahmin;
                            break;
                        case 13: //TUR ATLAR
                            aciklamaTDtext = "TurAtlar:" + bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 14: //ILK SET
                            aciklamaTDtext = 'İlk Set:'+bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 15: //GOL ARALIĞI
                            aciklamaTDtext = 'Gol Aralığı:'+bahis_detailTable.Rows[i].TAHMIN;
                            break;
                        case 16: //GOL ATAR/ATAMAZ
                            aciklamaTDtext = 'İki Takım Gol Atar/Atamaz:'+bahis_detailTable.Rows[i].TAHMIN;
                            break;
                    }
            
            
            
            oCell.innerHTML=aciklamaTDtext;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=bahis_detailTable.Rows[i].ILK_YARI_SONUCU;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=bahis_detailTable.Rows[i].IKINCI_YARI_SONUCU;
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace = "nowrap";
            oCell.style.color = yazirenk;
            oCell.innerHTML=myfixed(bahis_detailTable.Rows[i].ORAN);
            oCell = oRow.insertCell(-1);    
            oCell.style.borderLeft="none";
            oCell.style.borderRight="none";
            oCell.style.whiteSpace="nowrap";
            switch (bahis_detailTable.Rows[i].SONUC.substr(0,3)) {
                case "-":
                    oCell.style.color = "#2d61d7";
                    oCell.innerHTML = msg32;
                    break;
                case "KAY":
                    oCell.style.color = "#cb0c05";
                    oCell.innerHTML = msg33;
                    break;
                case "KAZ":
                    oCell.style.color = "#106404";
                    oCell.innerHTML = msg34;
                    break;
                case "LAT":
                    oCell.style.color = "#000000";
                    oCell.innerHTML = msg102;
                    break;
                //default:
                    //oCell.innerHTML = res.Rows[i].SONUC;
            }
            kontrol += 1;
        }
    }
    var oTableFooter=document.createElement("table");
    oTableFooter.style.marginBottom="10px";
    oTableFooter.cellPadding="2";
    oTableFooter.cellSpacing="2";
    oRow = oTableFooter.insertRow(-1);
    oCell = oRow.insertCell(-1);
    oCell.style.textAlign="center";
    oCell.style.color = "#FFFFFF";
    oCell.innerHTML=msg31;
    
    obj("div_betdetail").appendChild(oTablePrint);
    obj("div_betdetail").appendChild(oTableHead);
    obj("div_betdetail").appendChild(oTable1);
    obj("div_betdetail").appendChild(oTable);
    obj("div_betdetail").appendChild(oTableFooter);
    obj('div_betdetail').style.display='block';
    obj("div_betdetail").firstChild.style.width=oTable.offsetWidth+"px";
    obj("div_betdetail").childNodes[1].style.width=oTable.offsetWidth+"px";
    obj("div_betdetail").childNodes[2].style.width=oTable.offsetWidth+"px";
    obj("div_betdetail").lastChild.style.width=oTable.offsetWidth+"px";

    document.getElementById("td_betdetail_close").onmouseover = function() { this.style.backgroundColor = '#FFFFFF'; this.style.color = '#cb0c05'; };
    document.getElementById("td_betdetail_close").onmouseout = function() { this.style.backgroundColor = '#272f34'; ; this.style.color = '#FFFFFF'; };
    document.getElementById("td_betdetail_close").onclick=function(){obj('div_betdetail').style.display='none';};
    document.getElementById("td_betdetail_print").onmouseover = function() { this.style.backgroundColor = '#FFFFFF'; this.style.color = '#cb0c05'; };
    document.getElementById("td_betdetail_print").onmouseout = function() { this.style.backgroundColor = '#272f34'; ; this.style.color = '#FFFFFF'; };
    document.getElementById("td_betdetail_print").onclick=function(){printbet(this.getAttribute('BAHIS_ID'));};
    if (document.getElementById("td_betdetail_kuponode"))
    {
        document.getElementById("td_betdetail_kuponode").onmouseover = function() { this.style.backgroundColor = '#FFFFFF'; this.style.color = '#cb0c05'; };
        document.getElementById("td_betdetail_kuponode").onmouseout = function() { this.style.backgroundColor = '#272f34'; this.style.color = '#FFFFFF'; };
        document.getElementById("td_betdetail_kuponode").onclick=function(){paybet(this.getAttribute('BAHIS_ID'));};
        document.getElementById("td_betdetail_kuponode").style.cursor="pointer";
    }
    if (document.getElementById("td_betdetail_kuponsil"))
    {
        document.getElementById("td_betdetail_kuponsil").onmouseover = function() { this.style.backgroundColor = '#FFFFFF'; this.style.color = '#cb0c05'; };
        document.getElementById("td_betdetail_kuponsil").onmouseout = function() { this.style.backgroundColor = '#272f34'; this.style.color = '#FFFFFF'; };
        document.getElementById("td_betdetail_kuponsil").onclick=function(){erasebet(this.getAttribute('BAHIS_ID'));};
        document.getElementById("td_betdetail_kuponsil").style.cursor="pointer";
    }
    
    
}
function printbet(BAHIS_ID)
{
    var tFrame = document.getElementById("iframe_print");
    var doc= tFrame.contentDocument;
    if (!doc)//doc== undefined || doc== null
        doc = tFrame.contentWindow.document;
    
    doc.open();
    doc.clear();
    doc.write("Galaxy Betting(www.galaxybetting.com)");
    doc.write(obj('div_betdetail').innerHTML);
    doc.body.removeChild(doc.body.childNodes[1]);
    doc.body.removeChild(doc.body.childNodes[doc.body.childNodes.length-1]);
    doc.close();
    
    tFrame.contentWindow.focus();
    tFrame.contentWindow.print();
    
}
function erasebet(BAHIS_ID)
{
    if (confirm(BAHIS_ID +msg25))
    {
        MyAjaxClass.KuponIptal(BAHIS_ID,KuponIptal_callback,null,null,null,onTimeoutKuponIptal,null);
    }
}
function onTimeoutKuponIptal()
{
    alert(msg26);    
    return true;
}
function KuponIptal_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    if (!res.isLoggedIn)
    {
        loggedOff();
        alert(msg27);
    }
    else
    {
        if (res.Sonuc)
        {
            obj('div_betdetail').style.display='none';
            if ($("div_bakiye"))
                $("div_bakiye").innerHTML=msg11+" : "+myfixed(res.OynanabilirBakiye)+" YTL";
            currentmod=null;
            changemod();
            alert(res.Mesaj);
        }
        else
        {   
            alert(res.Mesaj);
        }
    }
}

function paybet(BAHIS_ID)
{
    if (confirm(BAHIS_ID +msg28))
    {
        MyAjaxClass.KuponOde(BAHIS_ID,KuponOde_callback,null,null,null,onTimeoutKuponOde,null);
    }
}


function onTimeoutKuponOde()
{
    alert(msg26);    
    return false;
}
function KuponOde_callback(r)
{
    if (r==null) return;
    if (r.error != null) 
    {
        alert(r.error.Message);
        return;
    }
    var res =r.value; 
    if (!res.isLoggedIn)
    {
        loggedOff();
        alert(msg27);
    }
    else
    {
        if (res.Result)
        {
            obj('div_betdetail').style.display='none';
            alert(res.BahisID+msg29);
        }
        else
        {   
            alert(res.BahisID+msg30);
        }
    }
}
function KuponBul()
{
    MyAjaxClass.GetBetDetails(obj("Txt_KuponBul").value,GetBetDetails_callback,null,null,null,onTimeoutGetBetDetails,null);
}
function KuponSorgula_ForCustomer()
{
    MyAjaxClass.GetBetDetails_ForCustomer(obj("Txt_BayiID").value,GetBetDetails_callback,null,null,null,onTimeoutGetBetDetails,null);
}


