function confirmCancel(id,text) {
    var answer = confirm(text);
    if (answer){
        window.location = "/mp-abonelik-iptal?id="+id;
    }
}
function goback(gameid){
    document.dummyhesabim.game.value=gameid;
    document.dummyhesabim.submit();
}
function getIddaaCoupons() {
    var statusObj = document.getElementById("iddaastatus");
    var statusValue = "";
    var selIndex = statusObj.selectedIndex;
    statusValue = statusObj.options[selIndex].value;
    var baslangicTarihi = document.getElementById("iddaaBaslangicTarihi").value;
    var bitisTarihi = document.getElementById("iddaaBitisTarihi").value;

    var posted = "listele=1&status=" + statusValue + "&baslangicTarihi=" + baslangicTarihi + "&bitisTarihi=" + bitisTarihi;

    var request = YAHOO.util.Connect.asyncRequest('POST', "hesabim-iddaa", {
        timeout: 25000,
        success:handleSuccessIddaaCoupons,
        failure:handleFailureIddaaCoupons
    }, posted);

}

function handleSuccessIddaaCoupons(o) {

    dividdaacoupons = document.getElementById("hesabimiddaa");
    if (o.responseText !== undefined) {
        dividdaacoupons.innerHTML = o.responseText;
    }
}

function handleFailureIddaaCoupons(o) {
    dividdaacoupons = document.getElementById("hesabimiddaa");
    if (o.responseText !== undefined) {
//dividdaacoupons.innerHTML = "";
}
}
function getCanTongoCouponsForPlatin() {
    var posted = "instantType=can";
    var request = YAHOO.util.Connect.asyncRequest('POST', "/iddaa/iddaageneric", {
        timeout: 25000,
        success:handleSuccessCanTongoCoupons,
        failure:handleFailureCanTongoCoupons
    }, posted);

}

function handleSuccessCanTongoCoupons(o) {
    var hazirKuponDIV = document.getElementById("hazirKuponDIV");
    if (o.responseText !== undefined) {
        hazirKuponDIV.innerHTML = o.responseText;
    }
}

function handleFailureCanTongoCoupons(o) {
    var hazirKuponDIV = document.getElementById("hazirKuponDIV");
    if (o.responseText !== undefined) {
        hazirKuponDIV.innerHTML = "kupon yok...";
    }
}

function getHesabimTJKTickets() {
    if(!dokumanionayla("tjkBaslangicTarihi","tjkBitisTarihi")){
        return false;
    }
    var statusObj = document.getElementById("tjkstatus");
    var statusValue = "";
    var selIndex = statusObj.selectedIndex;
    statusValue = statusObj.options[selIndex].value;
    var baslangicTarihi = document.getElementById("tjkBaslangicTarihi").value;
    var bitisTarihi = document.getElementById("tjkBitisTarihi").value;
    var posted = "status=" + statusValue + "&baslangicTarihiTJK=" + baslangicTarihi + "&bitisTarihiTJK=" + bitisTarihi + "&listele=listele";
    var request = YAHOO.util.Connect.asyncRequest('POST', "hesabim-tjk", {
        timeout: 25000,
        success:handleSuccessTJKTickets,
        failure:handleFailureTJKTickets
    }, posted);
}

function handleSuccessTJKTickets(o) {
    divtjktickets = document.getElementById("tjkHesabimListele");
    if (o.responseText !== undefined) {
        divtjktickets.innerHTML =  o.responseText;
    }
}

function handleFailureTJKTickets(o) {
    divtjktickets = document.getElementById("tjkHesabimListele");
    if (o.responseText !== undefined) {
//divtjktickets.innerHTML =   + "";
}
}

function getHesabimDiger() {
    if(!dokumanionayla("digerBaslangicTarihi","digerBitisTarihi")){
        return false;
    }
    var statusObj = document.getElementById("digerstatus");
    var statusValue = "";
    var selIndex = statusObj.selectedIndex;
    statusValue = statusObj.options[selIndex].value;
    var baslangicTarihi = document.getElementById("digerBaslangicTarihi").value;
    var bitisTarihi = document.getElementById("digerBitisTarihi").value;
    var posted = "status=" + statusValue + "&baslangicTarihiDiger=" + baslangicTarihi + "&bitisTarihiDiger=" + bitisTarihi + "&listele=listele";
    var request = YAHOO.util.Connect.asyncRequest('POST', "hesabim-diger", {
        timeout: 25000,
        success:handleSuccessDiger,
        failure:handleFailureDiger
    }, posted);
}

function handleSuccessDiger(o) {
    divdiger = document.getElementById("digerHesabimListele");
    if (o.responseText !== undefined) {
        divdiger.innerHTML =  o.responseText;
    }
}

function handleFailureDiger(o) {
    divdiger= document.getElementById("digerHesabimListele");
    if (o.responseText !== undefined) {
//divdiger.innerHTML =   + "";
}
}


function getHesabimMPTickets(type) {
    var statusObj = document.getElementById("mpstatus");
    var statusValue = "";
    var selIndex = statusObj.selectedIndex;
    statusValue = statusObj.options[selIndex].value;
    var draw = document.getElementById("draw").value;


    if(type == "true"){
        statusValue = 99;
    }

    var posted ="";
    var id=document.getElementById("mpstatus").value;
   if (id==99){
       var baslangicTarihi = document.getElementById("mpBaslangicTarihi").value;
       var bitisTarihi = document.getElementById("mpBitisTarihi").value;
       posted = "status=" + statusValue + "&baslangicTarihiMP=" + baslangicTarihi + "&bitisTarihiMP=" + bitisTarihi + "&listele=listele&active="+type;
   } else {
        posted="status=" + statusValue + "&draw=" + draw + "&listele=listele&active="+type;
   }


    var request = YAHOO.util.Connect.asyncRequest('POST', "hesabim-mp", {
        timeout: 25000,
        success:handleSuccessMPTickets,
        failure:handleFailureMPTickets
    }, posted);
}

function handleSuccessMPTickets(o) {
    divmptickets = document.getElementById("mpHesabimListele");
    if (o.responseText !== undefined) {
        divmptickets.innerHTML =  o.responseText;
    }
}

function handleFailureMPTickets(o) {
    divmptickets = document.getElementById("mpHesabimListele");
    if (o.responseText !== undefined) {
//divmptickets.innerHTML =   + "";
}
}




function getSTOCoupons() {
    var statusObj = document.getElementById("stostatus");
    var statusValue = "";
    var selIndex = statusObj.selectedIndex;
    statusValue = statusObj.options[selIndex].value;
    var baslangicTarihi = document.getElementById("stbaslangicTarihi").value;
    var bitisTarihi = document.getElementById("stbitisTarihi").value;
    var posted = "listele=1&status=" + statusValue + "&baslangicTarihi=" + baslangicTarihi + "&bitisTarihi=" + bitisTarihi;
    var request = YAHOO.util.Connect.asyncRequest('POST', "hesabim-sto", {
        timeout: 25000,
        success:handleSuccessSTOCoupons,
        failure:handleFailureSTOCoupons
    }, posted);
}

function handleSuccessSTOCoupons(o) {
    dividdaacoupons = document.getElementById("stHesabimListele");
    if (o.responseText !== undefined) {
        dividdaacoupons.innerHTML = o.responseText;
    }
}

function handleFailureSTOCoupons(o) {
    dividdaacoupons = document.getElementById("stHesabimListele");
    if (o.responseText !== undefined) {
//dividdaacoupons.innerHTML = "";
}
}




function bankaTransferOnay() {
    var mymoney = document.getElementById("hesabimdakipara").innerHTML;
    var accountmoney = mymoney.toString().replace(".","").replace(",",".");

    var miktar = document.getElementById("miktar").value;
    var kr = document.getElementById("kr").value;
    var onayli= document.getElementById("IamSureCheckbox").checked;
    var txId= document.getElementById("txId").value;

    if(kr==null || kr==""){
        kr = "0";
    }

    if (!onayli){
        alert ("Lütfen banka bilgilerinizin doğruluğunu onaylayınız.");
        return false;
    }

    if (! emptyValidationControl("miktar", "Lütfen, yatırılacak miktarı giriniz!")) {
        document.getElementById("miktar").focus();
        return false;
    }

    if (!parseFloat(miktar+"."+kr)){
        alert ("Yatırılacak miktar bir sayı olmalıdır.");
        document.getElementById("miktar").value="";
        document.getElementById("kr").value="";
        document.getElementById("miktar").focus();
        return false;
    }

    if (parseFloat(miktar+"."+kr)>parseFloat(accountmoney)){
        alert ("Lütfen hesabınızdaki paradan daha fazla bir miktarı girmeyiniz.");
        document.getElementById("miktar").focus();
        return false;
    }

    if (parseFloat(miktar+"."+kr)<parseFloat("10.0")){
        alert ("Minimum 10 TL için talep verebilirsiniz..");
        document.getElementById("miktar").focus();
        return false;
    }

    var posted = "action=onay&txId="+txId+"&amount=" + miktar+ "&kr="+kr ;
    var request = YAHOO.util.Connect.asyncRequest('POST', "banka-islemleri", {
        timeout: 25000,
        success:handleSuccessOnay,
        failure:handleFailureOnay
    }, posted);
}

function handleSuccessOnay(o) {
    var resp="";
    dividdaacoupons = document.getElementById("BankaTransferDiv");
    var eksilen = document.getElementById("hesaptanEksilen");
    var amount = document.getElementById("hesabimdakipara");
    if (o.responseText !== undefined) {
        resp=o.responseText;
        min=resp.indexOf("<END>");
        max=resp.indexOf("</END>");
        if (max!=-1 && min!=-1) {
            dividdaacoupons.innerHTML = o.responseText.substring(max+6);
            resp=resp.substring(min+5,max);
            min=resp.indexOf(":");
            max=resp.indexOf("|",min+1);
            //alert("**"+resp.substring(min+1,max)+"**");
            amount.innerHTML = document.getElementById("hesabim").innerHTML = resp.substring(min+1,max);
            min=resp.indexOf(":",max+1);
            //alert("**"+resp.substring(min+1)+"**");
            document.getElementById("bilyonerparam").innerHTML=document.getElementById("hesabimdakibilyonpara").innerHTML=resp.substring(min+1);
        }else {
            dividdaacoupons.innerHTML = o.responseText;
        }


    /*
        if (amount && eksilen && document.getElementById("hesabim")) {
            var newAmount = amount.innerHTML.replace('.','').replace(',','.') - eksilen.name.replace(',','.');
            newAmount = new Number(newAmount).toFixed(2);
            amount.innerHTML = document.getElementById("hesabim").innerHTML = (""+newAmount).replace('.',',');
        }*/
    }
}

function handleFailureOnay(o) {
    dividdaacoupons = document.getElementById("BankaTransferDiv");
    if (o.responseText !== undefined) {
//dividdaacoupons.innerHTML = "";
}
}

function handleSuccessWithdrawCancel(o) {
    if (o.responseText !== undefined) {
        var newAmount = new Number(o.responseText).toFixed(2);
        document.getElementById("hesabimdakipara").innerHTML =
        document.getElementById("hesabim").innerHTML = (""+newAmount).replace('.',',');

        getBankaTransferleri(0);
    }
}

function handleFailureWithdrawCancel(o) {
    if (o.responseText !== undefined) {
}
}

function bankaTransfer() {
    var posted = "action=bankabilgileri";
    var request = YAHOO.util.Connect.asyncRequest('POST', "banka-islemleri", {
        timeout: 25000,
        success:handleSuccessOnay,
        failure:handleFailureOnay
    }, posted);
}

function cancelWithdraw(wid, txid) {
    var posted = "action=iptal&txId="+txid+"&withDrawId="+wid;
    var request = YAHOO.util.Connect.asyncRequest('POST', "banka-islemleri", {
        timeout: 25000,
        success:handleSuccessWithdrawCancel,
        failure:handleFailureWithdrawCancel
    }, posted);
}

function getBankaTransferleri(id) {
    if (!id){
        var statusObj = document.getElementById("status");
        var statusValue = "";
        var selIndex = statusObj.selectedIndex;
        statusValue = statusObj.options[selIndex].value;
    }
    else {
        statusValue=id;
    }
    var baslangicTarihi = document.getElementById("baslangicTarihiBank").value;
    var bitisTarihi = document.getElementById("bitisTarihiBank").value;
    var posted = "action=listele&status=" + statusValue + "&baslangicTarihi=" + baslangicTarihi + "&bitisTarihi=" + bitisTarihi;
    var request = YAHOO.util.Connect.asyncRequest('POST', "banka-islemleri", {
        timeout: 25000,
        success:handleSuccessBankaTransferleri,
        failure:handleFailureBankaTrasnferleri
    }, posted);
}

function handleSuccessBankaTransferleri(o) {
    dividdaacoupons = document.getElementById("transferlistDiv");
    if (o.responseText !== undefined) {
        dividdaacoupons.innerHTML = o.responseText;
    }
}

function handleFailureBankaTrasnferleri(o) {
    dividdaacoupons = document.getElementById("transferlistDiv");
    if (o.responseText !== undefined) {
//dividdaacoupons.innerHTML = "";
}
}

function kuponDetay(id){
    obj = document.getElementById(id);
    if (obj.style.display == "block") {
        obj.style.display = "none";
    } else {
        obj.style.display = "block";
    }
}



function dokumanionayla(startdate,enddate){
    var baslangicentry = document.getElementById(startdate).value.split('/'); // splits input value;
    y = baslangicentry[2]*1;
    m = baslangicentry[1]*1-1; // ayı set eder Ocak = 0; Şubat = 1; diye baslar.
    d = baslangicentry[0]*1;
    var basDate = new Date(y,m,d); // yeni tarihi set ediyor

    var bitisentry = document.getElementById(enddate).value.split('/'); // splits input value;

    y = bitisentry[2]*1;
    m = bitisentry[1]*1-1; // ayı set eder Ocak = 0; Şubat = 1; diye baslar.
    d = bitisentry[0]*1;
    var bitDate = new Date(y,m,d); // yeni tarihi set ediyor

    dif = basDate-bitDate; // milliseconds cinsinden farki
    dif = Math.ceil(dif/1000/60/60/24); // gun olarak farki

    if (dif>0) {
        alert('Başlangıç Tarihi, Bitiş Tarihinden büyük olamaz!');
        return false;
    }
    if (dif <-180) {
        alert('Sayın Üyemiz, "Başlangıç Tarihi" ile "Bitiş Tarihi" arasındaki fark 180 günü geçmemelidir! Lütfen tarih aralığını bunu dikkate alarak belirleyiniz.');
        return false;
    }

    return true;

}

function epostatjk(frm,couponID){
    frm.couponId.value=couponID;
    frm.submit();
    return false;
}

function canceltjk(frm,couponID,CBScouponID,txId){
    var domform = document.getElementById(frm);
    domform.couponID.value=couponID;
    domform.CBScouponID.value=CBScouponID;
    domform.txId.value=txId;
    domform.submit();
}

function checkNumaraSec(isLogin){
    if(isLogin){
        document.getElementById('numarasec').submit();
        return true;
    }else{
        alert("Üye Girişi Yapmalısınız.");
        return false;
    }

}

function validateEmail(element) {
    var testresults = false;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (!filter.test(element.value)) {
        alert("Lütfen geçerli bir e-posta adresi girin." + element.value + " geçerli bir email adresi deðil.");
        return false;
    }
    return true;
}

function submitSendToFrientFrm() {
    if (validateEmail(document.getElementById('emailAddress'))){
        document.getElementById('sendToFriendFrm').submit();
    }
}

function checkNotEvaluatedCoupons(isCancelAction, cancelGameType,money){
	if(isCancelAction!=null && isCancelAction){
		var numofnotevalued = 1;
		try{
			if(cancelGameType=="iddaa"){
				numofnotevalued = document.getElementsByName("IddaaIptalChecker").length;
			}else if(cancelGameType=="sto"){
				numofnotevalued = document.getElementsByName("StoIptalChecker").length;
			}else if(cancelGameType=="tjk"){
				numofnotevalued = document.getElementsByName("TjkIptalChecker").length;
			}
		}catch(ee){
			numofnotevalued = 0;
		}

		try{
			if(numofnotevalued==0){
				if(cancelGameType=="iddaa"){
					document.getElementById('notevalutedcouponsiddaa').style.display='none';
					document.getElementById("IddaaMessagesDivExtra").innerHTML = 'Değerlendirilmemiş kuponunuz bulunmamaktadır!';
					document.getElementById('IddaaMessagesDivExtra').style.display='block';
				}else if(cancelGameType=="sto"){
					document.getElementById('notevalutedcouponssto').style.display='none';
					document.getElementById("StoMessagesDivExtra").innerHTML = 'Değerlendirilmemiş kuponunuz bulunmamaktadır!';
					document.getElementById('StoMessagesDivExtra').style.display='block';
				}else if(cancelGameType=="tjk"){
					document.getElementById('notevalutedcouponstjk').style.display='none';
					document.getElementById("TJKMessagesDivExtra").innerHTML = 'Değerlendirilmemiş kuponunuz bulunmamaktadır!';
					document.getElementById('TJKMessagesDivExtra').style.display='block';
				}
			}else{
				var totalValue = 0;

				if(cancelGameType=="iddaa"){
					try{
						var totalIddaa = document.getElementById("iddaaTotalMoney").innerHTML.toString().replace(".","").replace(",",".");
						totalValue = parseFloat(totalIddaa);
						totalValue = totalValue - money;
						var nf = new NumberFormat();
						nf.setSeparators(true, nf.PERIOD);
			            nf.setCurrency(true);
			            nf.setCurrencyPrefix('');
			            nf.setPlaces(2);
			            nf.setNumber(totalValue);
			            document.getElementById("iddaaTotalMoney").innerHTML = nf.toFormatted();
					}catch(es){}
				}else if(cancelGameType=="sto"){
					try{
						var totalSto = document.getElementById("stoTotalMoney").innerHTML.toString().replace(".","").replace(",",".");
						totalValue = parseFloat(totalSto);
						totalValue = totalValue - money;
						var nf = new NumberFormat();
						nf.setSeparators(true, nf.PERIOD);
		                nf.setCurrency(true);
		                nf.setCurrencyPrefix('');
		                nf.setPlaces(2);
		                nf.setNumber(totalValue);
		                document.getElementById("stoTotalMoney").innerHTML = nf.toFormatted();
					}catch(ee){}
				}else if(cancelGameType=="tjk"){
					try{
						var totalTjk = document.getElementById("tjkTotalMoney").innerHTML.toString().replace(".","").replace(",",".");
						totalValue = parseFloat(totalTjk);
						totalValue = totalValue - money;
						var nf = new NumberFormat();
						nf.setSeparators(true, nf.PERIOD);
		                nf.setCurrency(true);
		                nf.setCurrencyPrefix('');
		                nf.setPlaces(2);
		                nf.setNumber(totalValue);
		                document.getElementById("tjkTotalMoney").innerHTML = nf.toFormatted();
					}catch(es){}
				}
			}
		}catch(ee){}
	}
}

//Heasbim sayfalari Javascriptleri.

function getMessageFunction (div,type,el,iptal,td,ticketid, cancelFlag, cancelGameType,money){
    var minamount="";
    var minbilyonerfonu="";
    var val_amount="";
    var val_bilyonerfonu="";
    var resp="";
    var tokenme="";
    var messageDiv = document.getElementById(div);

    var cancelActionTriggered = false;
    var money_var = 0;

    if(money!=null){
    	money_var = money;
    }
    if(cancelFlag!=null){
    	cancelActionTriggered = cancelFlag;
    }

    if (type=='success'){
        return   function handleSuccessMesajliIslemler(o) {
            if (o.responseText !== undefined) {
                var resp=o.responseText;
                 messageDiv.innerHTML = resp;
                  if ($("fcLogOutForm")){

                        var frm =$("fcLogOutForm");
                        frm.submit();
                        return;
                    }
                tokenme=resp.indexOf("|");
                minamount=resp.indexOf("amount:");
                minbilyonerfonu=resp.indexOf("bilyonerfonu:");
                /*
                 *alert(tokenme);
                alert(minamount);
                alert(minbilyonerfonu);
                 */
                if (minamount!=-1 && minbilyonerfonu!=-1 && tokenme!=-1){
                    resp=o.responseText.substring(0,minamount);
                    val_amount=o.responseText.substring(minamount+7,tokenme);
                    val_bilyonerfonu=o.responseText.substring(minbilyonerfonu+13);

                    if (document.getElementById("hesabim")) {
                        document.getElementById("hesabim").innerHTML=val_amount;
                        document.getElementById("bilyonerparam").innerHTML=val_bilyonerfonu;
                    }
                }
               messageDiv.innerHTML = resp;
                setTimeout("document.getElementById('"+div+"').innerHTML ='';document.getElementById('"+div+"').style.display='none';",5000);
                messageDiv.style.display="block";
                if (iptal&&td){
                    if (resp.indexOf("iptal")!=-1 && resp.indexOf("başarı")!=-1)
                    {
                    	setTimeout("checkNotEvaluatedCoupons('"+cancelActionTriggered+"','"+cancelGameType+"','"+money_var+"');",1000);

                        var tr=document.getElementById("couponTr"+ticketid);
                        var trtable=tr.parentNode;
                        if (tr )
                            trtable.removeChild(tr);
                        var tr=document.getElementById("detayTr"+ticketid);
                        if (tr )
                            trtable.removeChild(tr);
                        tr=document.getElementById("couponTrBos"+ticketid);
                        if (tr )
                            trtable.removeChild(tr);
                        tr=document.getElementById("couponTrDiv"+ticketid);
                        if (tr )
                            trtable.removeChild(tr);

                    }
                    else {
                        td.innerHTML="";
                        try{
                            td.appendChild(el)
                        }catch(e){
                            alert(e);
                        }
                    }
                }
            }
        };
    }
    else if (type=='failure'){
        return   function handleFailureMesajliIslemler(o) {
            if (o.responseText !== undefined) {
                messageDiv.innerHTML = "";
            }
        };
    }

}


function STOArkadasinaGonder(cbsticketid){
    var url="/st/arkadasa-gonder?cbsTicketId="+cbsticketid;
    Lightview.show({
        href:url,
        rel:'iframe',
        options:{
            topclose:true,
            autosize:true,
            width: 759,
            height: 260
        }
    });
}
function STOEpostaGonder(el,cbsticketid){
    var td=el.parentNode;
    var saveInnerHTML=td.innerHTML;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";

    var url="/st/EpostamaGonder?cbsTicketId="+cbsticketid;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("StoMessagesDiv","success",el),
        failure:getMessageFunction("StoMessagesDiv","failure")
    });
    td.innerHTML=saveInnerHTML;
}

function STOIptal(el,couponId,cbsticketid,money){
    var url="/kuponIptal-sto?couponID="+couponId + "&CBScouponID="+cbsticketid;
    var element=el;
    var td=el.parentNode;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";


    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("StoMessagesDiv","success",el,true,td,couponId,true,"sto",money),
        failure:getMessageFunction("StoMessagesDiv","failure")
    });

}

function MPEpostaGonder(el,mpsonuc){
    var td=el.parentNode;
    var saveInnerHTML=td.innerHTML;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";

    var url="/mp/epostamaGonder?mpsonuc="+mpsonuc;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("MpMessagesDiv","success",el),
        failure:getMessageFunction("MpMessagesDiv","failure")
    });
    td.innerHTML=saveInnerHTML;
}

function MPShowSubscriptionDetails(schedule_id){
    var url="mp-abonelik-detayi?id="+schedule_id;
    Lightview.show({
        href:url,
        rel:'ajax',
        options:{
            topclose:true,
            autosize:true,
            width: 800,
            height: 300
        }
    });
}


function STODetayGoster(cbsticketid, flagnotevaluated){
    var url;
    if(flagnotevaluated){
        url="/kuponDetay-sto?cbsTicketId="+cbsticketid+"&flagnotevaluated="+flagnotevaluated;
    }else{
        url="/kuponDetay-sto?cbsTicketId="+cbsticketid;
    }
    Lightview.show({
        href:url,
        rel:'ajax',
        options:{
            topclose:true,
            autosize:true,
            width: 759,
            height: 400
        }
    });
}



function IddaaIptal(el,couponId,cbsticketid,txId,money){
    var element=el;
    var td=el.parentNode;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";

    var url="/kuponIptal-iddaa?couponId="+couponId + "&CBScouponID="+cbsticketid+"&txId="+txId;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("IddaaMessagesDiv","success",el,true,td,couponId,true,"iddaa",money),
        failure:getMessageFunction("IddaaMessagesDiv","failure")
    });

    return false;
}
function IddaaDetayGoster(el,couponId,CBScouponID,status){
    var url="/kuponDetay-iddaa?couponId="+couponId+"&status="+status+"&CBScouponID="+CBScouponID;
      //sonra yenisini ekliyoruz.
    var trx=el.parentNode.parentNode;
    var trtable=trx.parentNode;
    var currTrIndex=trx.rowIndex;
    //Once eskisini  kaldırıyoruz.
    var contentDiv=document.getElementById("detayDiv");
    if (contentDiv){
            var currTdTrx=contentDiv.parentNode.parentNode;
            var DetayTrIndex=-1;
            var allrows=trtable.getElementsByTagName("tr");
            for (i=0;i<allrows.length;i++){
                  if (allrows[i]==currTdTrx){
                    trtable.removeChild(currTdTrx);//trx in iceriğini kaldırdık.
                      DetayTrIndex=i;
                  }
                  if (allrows[i]==trx){
                      currTrIndex=i;
                  }

            }
            if (currTrIndex==DetayTrIndex-1){
                return;
            }
        }
    trx=trtable.insertRow(trx.rowIndex+1);
    trx.setAttribute("id","detayTr"+couponId);

    var td=trx.insertCell(0);
    td.setAttribute("colSpan","15");

    contentDiv =document.createElement("div");
    contentDiv.setAttribute("id","detayDiv");
    td.appendChild(contentDiv);

    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getDetayAjaxFunctions(contentDiv,"success"),
        failure:getDetayAjaxFunctions(contentDiv,"failure")
    });
}

function printIddaaCoupon (){
   var contentDiv=document.getElementById("detayDiv");
    var printElement=document.getElementById("printDiv");
   printElement.parentNode.removeChild(printElement);


    if (contentDiv){
        var WindowObject=window.open("print");
        var doc = WindowObject.document;
        doc.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html><head></head><body></body></html><link href='/styles/bilyoner.css' rel='stylesheet' type='text/css' /><link href='/styles/portal.css' rel='stylesheet' type='text/css' />	<link href='/iddaa/styles/bilyoner.css' rel='stylesheet' type='text/css' /><link href='/iddaa/styles/iddaa.css' rel='stylesheet' type='text/css' />");
        doc.close();
        if (doc.body.appendChild)
        {
            doc.write(contentDiv.innerHTML);
        }
        var printetc=doc.getElementById("printDiv");
            if (printetc)
                        printetc.setAttribute("style","visibility:hidden;display:none;");
        WindowObject.document.close();
        WindowObject.focus();
        WindowObject.print();
        WindowObject.close();
    }
   document.getElementById("printTd").appendChild(printElement);
}

function getDetayAjaxFunctions (contentDiv,type){
 if (type=="failure"){
    return function failureDetay(o){
           if (o.responseText != undefined) {
                contentDiv.innerHTML = "";
            }
    }
 }else if (type=="success"){
        return function successDetay(o){
                 if ( o.responseText != '') {
                    contentDiv.innerHTML =o.responseText;
                }
            }
        }
}

function IddaaSistemDetayGoster(couponId,CBScouponID,status){
    var url="/kuponDetay-iddaa?system=s&couponId="+couponId+"&status="+status+"&CBScouponID="+CBScouponID;
    Lightview.show({
        href:url,
        rel:'ajax',
        options:{
            topclose:true,
            autosize:true,
            width: 810,
            height: 490
        }
    });
}

function IddaaEpostaGonder(el,couponId,cbsTicketId,status){
    var td=el.parentNode;
    var saveInnerHTML=td.innerHTML;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";
    var url="/iddaa/iddaa-eposta?couponId="+couponId+"&status="+status+"&cbsTicketId="+cbsTicketId;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("IddaaMessagesDiv","success",el),
        failure:getMessageFunction("IddaaMessagesDiv","failure")
    });
    td.innerHTML=saveInnerHTML;
}
function IddaaSendCouponToFriend(couponId,status,cbsTicketId){
    var url="/iddaa/kupon-gonder?source=2&action=sendCouponToFriend&couponId="+couponId+"&status="+status+"&cbsTicketId="+cbsTicketId;
    Lightview.show({
        href:url,
        rel:'iframe',
        options:{
            topclose:true,
            autosize:true,
            width: 759,
            height: 260
        }
    });
}

function TJKEpostaGonder(el,couponId){
    var td=el.parentNode;
    var saveInnerHTML=td.innerHTML;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";

    var url="/tjk/epostamagonder?couponId="+couponId;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("TJKMessagesDiv","success",el),
        failure:getMessageFunction("TJKMessagesDiv","failure")
    });
    td.innerHTML=saveInnerHTML;
}

function TJKSendCouponToFriend(couponId){
    var url="/tjk/arkadasagonder?couponId="+couponId;
    Lightview.show({
        href:url,
        rel:'iframe',
        options:{
            topclose:true,
            autosize:true,
            width: 759,
            height: 260
        }
    });
}

function TJKCouponCancel(el,couponId,CBScouponID,txId,money){
    var element=el;
    var td=el.parentNode;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";
    var url="tjk-kupon-iptal?couponID="+couponId+"&CBScouponID="+CBScouponID+"&status=-1&txId="+txId;
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("TJKMessagesDiv","success",el,true,td,couponId,true,"tjk",money),
        failure:getMessageFunction("TJKMessagesDiv","failure")
    });
}

function TJKReservationCancel(el,couponId,CBScouponID,txId){
    var url="tjk-rezerve-iptal?couponID="+couponId+"&CBScouponID="+CBScouponID+"&status=-1&txId="+txId;
    var element=el;
    var td=el.parentNode;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("TJKMessagesDiv","success",el,true,td,couponId,true,"tjk"),
        failure:getMessageFunction("TJKMessagesDiv","failure")
    });

}

function TJKDetayGoster(divid){
    Lightview.show(divid);
}


function MPAbonelikIptal(el,id,text){
    var answer = confirm(text);
    if(!answer){
    	return false;
    }
    var url="/mp-abonelik-iptal?id="+id;
    var element=el;
    var td=el.parentNode;
    td.innerHTML="<img src='/images/icons/reloading.gif'>";
    var request = YAHOO.util.Connect.asyncRequest('POST', url, {
        timeout: 25000,
        success:getMessageFunction("MpMessagesDiv","success",el,true,td,id,true,"mp"),
        failure:getMessageFunction("MpMessagesDiv","failure")
    });
}

//-------------------------LightView Login Olaylarının javascriptleri
function showLoginOnly(application,method,errorcheckMethod){
    if (!isLogined()){
        var url="/loginLV.jspx?app="+application+"&doPost=false";
        if (method){
            url+="&method="+method;
        }
        if (eval(errorcheckMethod))
            window.parent.Lightview.show({
                href:url,
                rel:'ajax',
                options:{
                    topclose:true,
                    autosize:true,
                    width: 800,
                    height: 400
                }
            });
    }
}

function showLoginFormWithFunction(application,method,errorcheckMethod){
    if (!isLogined()){
        var url="/loginLV.jspx?app="+application;
        if (method){
            url+="&method="+method;
        }
        if (eval(errorcheckMethod))
            window.parent.Lightview.show({
                href:url,
                rel:'ajax',
                options:{
                    topclose:true,
                    autosize:true,
                    width: 800,
                    height: 400
                }
            });
    }else {
        eval (""+method);
    }
}

function showLoginFormNameli (application,formName){
    if (!isLogined()){
        var url="/loginLV.jspx?app="+application;
        if (formName){
            url+="&formName="+formName;
        }
        Lightview.show({
            href:url,
            rel:'ajax',
            options:{
                topclose:true,
                autosize:true,
                width: 800,
                height: 400
            }
        });
    }else {
        document.forms[formName].submit();
    }
}

function showLogin (application,page,noSubscriptionPage){
    if (!isLogined()){
        var url="/loginLV.jspx?app="+application;
        if (page){
            url+="&page="+escape(page);
        }
        if (noSubscriptionPage){
            url+="&noSubscriptionPage="+escape(noSubscriptionPage);
        }
        Lightview.show({
            href:url,
            rel:'ajax',
            options:{
                topclose:true,
                autosize:true,
                width: 800,
                height: 400
            }
        });
    }else {
        window.location.href=page;
    }

}
function showLoginWithMethod (application,method,errorcheckMethod){
    if (!isLogined()){
        var url="/loginLV.jspx?app="+application;
        if (method){
            url+="&method="+method;
        }
        if (eval(errorcheckMethod))
            Lightview.show({
                href:url,
                rel:'ajax',
                options:{
                    topclose:true,
                    autosize:true,
                    width: 800,
                    height: 400
                }
            });
    }else {
        eval (""+method);
    }
}

var handleSuccessLVLogin = function(o){
    var resultText=o.responseText;
    if(resultText != undefined){
        if (resultText==''){//Login Oldu sayfayı refresh etmeden sonraki sayfaya gitcez.
            if (document.loginLVForm.page)
            {
                var page=document.loginLVForm.page.value;
                window.location.href=page;
                window.Lightview.hide();
            }
            if (document.loginLVForm.formName)
            {
                var formName=document.loginLVForm.formName.value;
                document.forms[formName].submit();
            }
            if (document.loginLVForm.method)
            {
                eval (""+document.loginLVForm.method.value+"");
            }

        }
        else {
            var resultTd=document.getElementById("loginTd");
            resultTd.innerHTML=resultText;
            resultTd.style.display="block";
            resultTd.style.visibility="visible";
        }
    }
}
var handleFailureLVLogin = function(o){
    if(o.responseText !== undefined){

}
}
var callbackLVLogin =
{
    timeout: 25000,
    success:handleSuccessLVLogin,
    failure:handleFailureLVLogin
};


//show only

var handleSuccessLVLoginShowOnly = function(o){
    var resultText=o.responseText;
    if(resultText != undefined){
        if (resultText==''){//Login Oldu sayfayı refresh etmeden sonraki sayfaya gitcez.
        	window.parent.Lightview.hide();
        	openWindow('/tjk/tjk-muhtemeller?page=tjkMuhtemeller&amp;Ref=0','_blank','1024','768','status=1,scrollbars=1,resizable=1,directories=0');
        }
        else {
            var resultTd=document.getElementById("loginTd");
            resultTd.innerHTML=resultText;
            resultTd.style.display="block";
            resultTd.style.visibility="visible";
        }
    }
}
var handleFailureLVLoginShowOnly = function(o){
    if(o.responseText !== undefined){

}
}
var callbackLVLoginShowOnly =
{
    timeout: 25000,
    success:handleSuccessLVLoginShowOnly,
    failure:handleFailureLVLoginShowOnly
};

//show only
function uyeNoSifreCheck()
{   //LightView İçin
    var uyeNo = document.loginLVForm.j_username;
    var uyeSifre = document.loginLVForm.j_password;
    if (uyeNo.value.length != 8 || uyeSifre.value.length != 6 || !IsNumeric(uyeNo.value) || !IsNumeric(uyeSifre.value))
    {
        alert("Üye No/Şifre bilgilerinizi kontrol ediniz!");
        uyeNo.focus();
        return false;
    }
    return true;
}
function loginLvForm(){
    var username=document.loginLVForm.j_username.value;
    var password=document.loginLVForm.j_password.value;
    var sesid=document.loginLVForm.sesid.value;
    var nextpage=document.loginLVForm.nextpage.value;
    var application=document.loginLVForm.application.value;

    if (!uyeNoSifreCheck()){
        return false;
    }
    var query="j_username="+username+"&j_password="+password+"&sesid="+sesid+"&nextpage="+nextpage;
    var surl="/login";
    if (application!=''){
        surl="/"+application+surl;
    }
    var request = YAHOO.util.Connect.asyncRequest('POST', surl, callbackLVLogin,query);
    return false;
}

function loginLvFormShowOnly(){
    var username=document.loginLVForm.j_username.value;
    var password=document.loginLVForm.j_password.value;
    var sesid=document.loginLVForm.sesid.value;
    var nextpage=document.loginLVForm.nextpage.value;
    var application=document.loginLVForm.application.value;

    if (!uyeNoSifreCheck()){
        return false;
    }
    var query="j_username="+username+"&j_password="+password+"&sesid="+sesid+"&nextpage="+nextpage;
    var surl="/login";
    if (application!=''){
        surl="/"+application+surl;
    }
    var request = YAHOO.util.Connect.asyncRequest('POST', surl, callbackLVLoginShowOnly,query);
    return false;
}

function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

function emptyValidationControl(entered, alertbox) {
    with (document.getElementById(entered))
    {
        if (value == null || value == "") {
            if (alertbox != "") {
                alert(alertbox);
            }
            return false;
        }
        else {
            return true;
        }
        }
}

function show(){
    document.getElementById("moneytodrawtxt").style.display = "block";
    document.getElementById("moneytodraw").style.display = "block";
}

function hide(){
    document.getElementById("moneytodrawtxt").style.display = "none";
    document.getElementById("moneytodraw").style.display = "none";
}
function findsta(){
    if (document.getElementById("IamSureCheckbox").checked){
        show();
    }else{
        hide();
    }
}
function digitFilter (input) {
    var s = input.value;
    var filteredValues = "1234567890";     // Characters stripped out
    var i;
    var returnString = "";
    if (s !=null){
        for (i = 0; i < s.length; i++) {
            // Search through string and append to unfiltered values to returnString.
            var c = s.charAt(i);
            if (filteredValues.indexOf(c) >=0) returnString += c;
        }
    }
    input.value = returnString;
}
//-------------------------------------------------------
function changeTicketSelection(){
    var id=document.getElementById("mpstatus").value;
    if (id==99){
        document.getElementById("abonelikDiv").style.visibility="visible";
        document.getElementById("abonelikDiv").style.display="block";
        document.getElementById("TicketDiv").style.visibility="hidden";
        document.getElementById("TicketDiv").style.display="none";
    }else{
        document.getElementById("abonelikDiv").style.visibility="hidden";
        document.getElementById("abonelikDiv").style.display="none";
        document.getElementById("TicketDiv").style.visibility="visible";
        document.getElementById("TicketDiv").style.display="block";
    }
}