//EN İyilier İçin
function jsToas(){
	try{
		document.getElementById("goal").playFnc();
	}catch(ex){}
}


function getHOF(type, stype, anasayfa) {
    var div;
	if (!anasayfa) {
		var table = document.getElementById("buttonsTable");
		var buttons = table.getElementsByTagName("img");
		for (i = 0; i < buttons.length; i++) {
			if (buttons[i].src.lastIndexOf("2") > -1) {
				buttons[i].src = buttons[i].src.replace("2", "");
			}
		}
		var imgsrc = document.getElementById("hofbutton" + type + "" + stype).src;

		var newimgsrccc = imgsrc.substring(0, imgsrc.lastIndexOf(".")) + "2.gif";
		document.getElementById("hofbutton" + type + "" + stype).src = newimgsrccc;
        div=divhof;
	}else {
        div=eval("divhof"+type);        
    }

    function handleSuccessHOF(o) {
	if (o.responseText !== undefined) {
        div.innerHTML = o.responseText;
        }
    }
    function handleFailureHOF(o) {
        if (o.responseText !== undefined) {
            div.innerHTML = "";
        }
    }

	var url = "/iddaa/iddaa-en-iyiler?type=" + type;
	if (stype)
		url += "&stype=" + stype;
	if (anasayfa && anasayfa == 'y')
		url += "&anasayfa=y";
	var request = YAHOO.util.Connect.asyncRequest('POST', url, {
		timeout :25000,
		success :handleSuccessHOF,
		failure :handleFailureHOF
	}, "dumpar=dumpar");
}
//-----------------------------------------------------------------------------------------------------
//Not defterim İçin

function deleteCoupon2(couponid) {
	document.deleteCoupon.coupon_id.value = couponid;
	document.deleteCoupon.submit();
}

function showCouponDetails(couponid) {
	var url = 'kupon-kaydet?action=showCoupon&coupon_id=' + couponid;
	Lightview.show( {
		href :url,
		rel :'ajax',
		options : {
			topclose :true,
			autosize :true,
			keyboard :false,
			overlayClose :false,
			width :780,
			height :400
		}
	});

}
function playCoupon2(couponstring,misli,sistem) {
	if (parent.document.playCoupon) {
		parent.document.playCoupon.sonuc.value = couponstring;
		parent.document.playCoupon.sistem.value = sistem;
		parent.document.playCoupon.misli.value = misli;
		parent.document.playCoupon.submit();
		return false;
	} else {
		document.playCoupon.sonuc.value = couponstring;
        parent.document.playCoupon.sistem.value = sistem;
		parent.document.playCoupon.misli.value = misli;
		document.playCoupon.submit();
		return false;
	}
}

//-------------------------------------------------------------------------------------------------Kuopn Kaydet İçin 
var handleSuccessSaveCoupon = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById('saveCouponDiv').innerHTML = o.responseText;
		document.getElementById('saveCouponDiv').setAttribute("class","fntBold coRed");
	}
}
var handleFailureSaveCoupon = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById('saveCouponDiv').innerHTML = "";
	}
}
var callbackSaveCoupon = {
	timeout :25000,
	success :handleSuccessSaveCoupon,
	failure :handleFailureSaveCoupon
};

function SaveCoupon(sonuc, misli, sistem, kazanc, kolon) {
	var kuponname = document.getElementById("coupon_name").value;
	if (kuponname.length >= 20)
		kuponname = kuponname.substring(0, 20);
	var surl = "kupon-kaydet?";
	var query = "action=saveCoupon&sonuc=" + encodeURIComponent(sonuc) + "&misli=" + misli + "&sistem=" + sistem + "&kazanc=" + kazanc
			+ "&name=" + encodeURIComponent(kuponname) + "&kolon=" + kolon;
	var request = YAHOO.util.Connect.asyncRequest('POST', surl, callbackSaveCoupon, query);
	return false;
}

//------------------------------------------------------------------------------------------------------
//Bahis Yap Sayafalrındaki Formu Degistirmek için (Lige Gore Tarihe Gore sıralama olayları için )
function changeOptions (eventType,leages,dates){
  var sortType=document.getElementById("sortType").value;
  var optionsSelect=document.getElementById("options");
  optionsSelect.options;

 for(i=optionsSelect.options.length;i>=0;i--){
     optionsSelect.remove(0);
 }   

    var tumuoption = document.createElement('option');
	tumuoption.text = ' Tümü  ';
	tumuoption.value = '-1';

    try {
        document.getElementById("options").add(tumuoption,
        document.getElementById("options").options[0]); // standards compliant; doesn't work in IE
    } catch (ex) {
        document.getElementById("options").add(tumuoption, 0); // IE only
    }

    //changeOptions('{UAL=UEFA Avrupa Ligi, SE1=İsveç Birinci Ligi}','[Thu Sep 17 00:00:00 EEST 2009]')
 var optionsArray=new Array();
  if (sortType =='matchDate'){
      leages=dates.replace("{","").replace("}","");
      optionsArray=leages.split(",");
      var datesArray=new Array();
      for (i=0;i<optionsArray.length;i++){
          var lig=optionsArray[i].split("=");
            datesArray[lig[0]]=lig[1];
          }
     optionsArray=datesArray;
  }else if (sortType =='matchLeage'){
      leages=leages.replace("{","").replace("}","");
      optionsArray=leages.split(",");
      var datesArray=new Array();
      for (i=0;i<optionsArray.length;i++){
          var lig=optionsArray[i].split("=");
            datesArray[lig[0]]=lig[1];
          }
     optionsArray=datesArray;
  }
    var counter =1;
  for ( var Optvalue in optionsArray ){
      if (typeof(optionsArray[Optvalue])!="function"){
               var tempoption = document.createElement('option');
                tempoption.text = optionsArray[Optvalue];
                tempoption.value = Optvalue.replace(" ","");
               try {
                document.getElementById("options").add(tempoption,
                document.getElementById("options").options[counter]); // standards compliant; doesn't work in IE
            } catch (ex) {
                document.getElementById("options").add(tempoption, counter); // IE only
            }
              counter++;
      }
  }
 getBets (eventType,1);   
}

function getBets(eventType, id) {
//	var lig = document.getElementById("matchLeage").value;
//	var date = document.getElementById("matchDate").value;
  var sortType=document.getElementById("sortType").value;
  var option= document.getElementById("options").value; 

	var gametype = "";
	if (document.getElementById("otherBets"))
		gametype = document.getElementById("otherBets").value;

	var selectoption = document.createElement('option');
	selectoption.text = ' Seçiniz  ';
	selectoption.value = '-2';

	if (gametype == '-2') {
		gametype = "";
	}
	if (gametype == 'SE' || gametype == 'UV') {
		document.getElementById("sortType").style.display = "none";
		document.getElementById("options").style.display = "none";
	} else {
		document.getElementById("sortType").style.display = "block";
		document.getElementById("options").style.display = "block";
	}

	var url = "/iddaa/iddaa-liste?eventType=" + eventType + "&gameType=" + gametype + "&";

    if (sortType =="matchDate" &&option==-1)
            url += "sortType=matchDate";
        else if (sortType =="matchDate" &&option!=-1) {
            url += "date=" + option;
        }else if (sortType =="matchLeage" &&option==-1)
            url += "sortType=matchLeage";
        else if (sortType =="matchLeage" &&option!=-1) {
            url += "leage=" + option;
        }
    
    if (id == 3) {//Diger bahisleri acıyoz.
		if (document.getElementById("TumTable")) {
			document.getElementById("TumTable").style.display = 'none';
			document.getElementById("TumTable").style.visibility = 'visible';
		}
		if (document.getElementById("HandikapTable")) {
			document.getElementById("HandikapTable").style.display = 'none';
			document.getElementById("HandikapTable").style.visibility = 'visible';
		}
		if (document.getElementById("IymsTable")) {
			document.getElementById("IymsTable").style.display = 'none';
			document.getElementById("IymsTable").style.visibility = 'visible';
		}
		if (document.getElementById("GsTable")) {
			document.getElementById("GsTable").style.display = 'none';
			document.getElementById("GsTable").style.visibility = 'visible';
		}
		if (document.getElementById("ScTable")) {
			document.getElementById("ScTable").style.display = 'none';
			document.getElementById("ScTable").style.visibility = 'visible';
		}
		if (gametype == '') {
			document.getElementById("TumTable").style.display = 'block';
			document.getElementById("TumTable").style.visibility = 'visible';
		} else if (gametype == 'H') {
			document.getElementById("HandikapTable").style.display = 'block';
			document.getElementById("HandikapTable").style.visibility = 'visible';
		} else if (gametype == 'SF') {
			document.getElementById("IymsTable").style.display = 'block';
			document.getElementById("IymsTable").style.visibility = 'visible';
		} else if (gametype == 'GS') {
			document.getElementById("GsTable").style.display = 'block';
			document.getElementById("GsTable").style.visibility = 'visible';
		} else if (gametype == 'SC') {
			document.getElementById("ScTable").style.display = 'block';
			document.getElementById("ScTable").style.visibility = 'visible';
		}

	}
	document.getElementById("maclistesi").src = url;
}

/**
 * Match oranlarına gore sıralama Yapar.
 * @param sortType
 */
function sortByOdds(eventType, sortOddType) {
    var sortType=parent.document.getElementById("sortType").value;
    var option= parent.document.getElementById("options").value;

	var gametype = parent.document.getElementById("otherBets").value;
	if (gametype == '-2') {
		gametype = "";
	}

	var url = "/iddaa/iddaa-liste?eventType=" + eventType + "&gameType=" + gametype + "&";

         if (sortType =="matchDate" &&option==-1)
            url += "sortType=matchDate";
        else if (sortType =="matchDate" &&option!=-1) {
            url += "date=" + option;
        }else if (sortType =="matchLeage" &&option==-1)
            url += "sortType=matchLeage";
        else if (sortType =="matchLeage" &&option!=-1) {
            url += "leage=" + option;
        }

	url += "&sortOddtype=" + sortOddType;

	parent.document.getElementById("maclistesi").src = url;
}
//---------------------------------------------------------------ANA TABLARI DEGISTIRMEK ICIN
var handleSuccessBahisYap = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById("MaclistesiDiv").innerHTML = o.responseText;
		ReColorSelectedMatches('genis');
	}
}
var handleFailureBahisYap = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById("MaclistesiDiv").innerHTML = "";
	}
}
var callbackBahisYap = {
	timeout :25000,
	success :handleSuccessBahisYap,
	failure :handleFailureBahisYap
};
//Ana ve Baba Tablr için yapildi.
function changeMainTabs(eventType,subTab,baseUrl) {

	for (i = 1; i < 20; i++) {
		var tabDiv = document.getElementById("bahisYapTab" + i);
        if (tabDiv){
            try{
                var img = tabDiv.getElementsByTagName("a")[0];
                var imgother=tabDiv.getElementsByTagName("a")[1];
                if (i == eventType) {
                    img.style.visibility="hidden";
                    img.style.display="none";
                    imgother.style.visibility="visible";
                    imgother.style.display="block";
                }
                if (i != eventType) {
                    img.style.visibility="visible";
                    img.style.display="block";
                    imgother.style.visibility="hidden";
                    imgother.style.display="none";
                }
            }catch(ex){alert (ex)}
        }
	}

	var url = "/iddaa/bahis-yap";
    if (baseUrl){
        url=baseUrl+url;
    }

	var req ="";

    req="eventType="+eventType;
    if (subTab ){
        req+="&gameType="+subTab;
    }
    var request = YAHOO.util.Connect.asyncRequest('POST', url, callbackBahisYap,req);

	return false;
}

//---------------------------------------------------------------------------------------------------------------------------
//Ana ve Baba Tablr için yapildi.Canli SOnucların Tablari için
function handleSuccessCanliSonuclar(o){				
	if (o.responseText !== undefined) {
		document.getElementById("MaclistesiDiv").innerHTML = o.responseText;
		swfobject.embedSWF("/iddaa/flashes/goal.swf", "goal", "290", "35", "9.0.0",
				"/iddaa/flashes/expressInstall.swf", flashvars, params, attributes);
		
		try{
			getCanliSonuclar(o.argument.toString(),true);
		}catch(sss){}				
		
	}
}

function handleFailureCanliSonuclar(o){
	if(o.responseText !== undefined){	
		document.getElementById("MaclistesiDiv").innerHTML = "";			
	}
}

function changeLivesMainTabs(tabid) {
	setInterval("refreshLiveScoresAuto()",60000);
	
	for (i = 1; i < 5; i++) {
		var tabDiv = document.getElementById("mainTab" + i);
		try{
			var img = tabDiv.getElementsByTagName("img")[0];
			if (i == tabid) {
				var imgSrc = img.getAttribute("src");
				imgSrc = imgSrc.substring(0, imgSrc.length - 4) + "2.png";
				img.src = imgSrc;
				var aElement = document.getElementsByTagName("a")[0];
				tabDiv.innerHTML = "";
				tabDiv.appendChild(img);
			}
			if (i != tabid) {
				var aElement = tabDiv.getElementsByTagName("a");
				if (aElement.length == 0) {
					aElement = document.createElement("a");
				} else {
					aElement = aElement[0];
				}
				tabDiv.appendChild(aElement);
				aElement.setAttribute("href", "javascript:;");
				eval("aElement.onclick = function(tabiddd) { changeLivesMainTabs('" + i + "');}");
				img.setAttribute("src", img.src.replace("2", ""));
				aElement.appendChild(img);
			}
		}catch(ess){}
	}

	var tabEventType = 1;
	var url = "/iddaa/canli-sonuclar-template?eventType=1";
	if (tabid == 1) {
		url = "/iddaa/canli-sonuclar-template?eventType=1";
		tabEventType = 1;
		status = footballSelected;
	} else if (tabid == 2) {
		url = "/iddaa/canli-sonuclar-template?eventType=2";
		tabEventType = 2;
		status = basketballSelected;
	} else if (tabid == 3) {
		url = "/iddaa/canli-sonuclar-template?eventType=6";
		tabEventType =  6;
		status = volleyballSelected;
	} else if (tabid == 4) {
		url = "/iddaa/canli-sonuclar-template?eventType=4";
		tabEventType = 4;
	} else if (tabid == 5) {
		url = "/iddaa/canli-sonuclar-template?eventType=8";
		tabEventType =  8;
	} else if (tabid == 6) {
		url = "/iddaa/canli-sonuclar-template?eventType=3";
		tabEventType =  3;
	}

	
	var request = YAHOO.util.Connect.asyncRequest('POST', url, {
		timeout :25000,
		success :handleSuccessCanliSonuclar,
		failure :handleFailureCanliSonuclar,
		argument : [ tabEventType ]
	});

	setTimeout("resfreshIframe();",500);
	
	return false;
}

var handleSuccessCanliSonuclarMaclistesi = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById("contentCell").innerHTML = o.responseText;
		swfobject.embedSWF("/iddaa/flashes/goal.swf", "goal", "290", "35", "9.0.0",
				"/iddaa/flashes/expressInstall.swf", flashvars, params, attributes);
	
	
		if(o.responseText.indexOf("/iddaa/images/ball.gif")>-1){
			setTimeout("jsToas()",5500); 		
		}
	}
}
var handleFailureCanliSonuclarMaclistesi = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById("contentCell").innerHTML = "";
	}
}
var callbackCanliSonuclarMaclistesi = {
	timeout :25000,
	success :handleSuccessCanliSonuclarMaclistesi,
	failure :handleFailureCanliSonuclarMaclistesi
};

function getCanliSonuclar(eventType, countriesFlag) {
	var url = "canli-sonuc-liste?eventType=" + eventType;
	var allLeages = document.getElementsByName("leages");
	var tempLig = "";
	if (allLeages.length > 0) {
		for (i = 0; i < allLeages.length; i++) {
			if (allLeages[i].checked)
				tempLig += allLeages[i].value + ",";
		}
	}

	leage = tempLig;

	var lig = leage;
	var st = status;
	var sty = sortType;

	url += "&leage=" + lig + "&status=" + st + "&sortType=" + sty;
	
	
	try{
		if(countriesFlag){
			getCanliSonuclarUlkeler(eventType);
		}
	}catch(ed){}

	var request = YAHOO.util.Connect.asyncRequest('POST', url, callbackCanliSonuclarMaclistesi, null);
	if(!countriesFlag){
		setTimeout("resfreshIframe();",500);
	}
}

function resfreshIframe(){	
	setTimeout("window.parent.frames['frame1'].location.reload(true);",1000);
}

function getCanliSonuclarbySortType(eventType, sortty) {
	var url = "canli-sonuc-liste?eventType=" + eventType;
	var lig = leage;
	var st = status;
	sortType = sortty;

	url += "&leage=" + lig + "&status=" + st + "&sortType=" + sortty;

	var request = YAHOO.util.Connect.asyncRequest('POST', url, callbackCanliSonuclarMaclistesi, null);
	setTimeout("resfreshIframe();",500);
}
function getCanliSonuclarbyStatus(eventType, st) {
	var url = "canli-sonuc-liste?eventType=" + eventType;
	var lig = leage;
	status = st;
	var sortty = sortType;

	url += "&leage=" + lig + "&status=" + st + "&sortType=" + sortty;

	var request = YAHOO.util.Connect.asyncRequest('POST', url, callbackCanliSonuclarMaclistesi, null);
	setTimeout("resfreshIframe();",500);
}

var handleSuccessLiveScoreCountries = function(o) {
	if (o.responseText !== undefined) {
		try{
			document.getElementById('liveScoreCountries').innerHTML = o.responseText;
		}catch(exx){			
		}
	}
}
var handleFailureLiveScoreCountries = function(o) {
	if (o.responseText !== undefined) {
		document.getElementById('liveScoreCountries').innerHTML = "";
	}
}

function getCanliSonuclarUlkeler(eventType) {
	posted = "eventType=" + eventType;
	var request = YAHOO.util.Connect.asyncRequest('POST', "canli-sonuclar-ulkeler", {
		timeout :25000,
		success :handleSuccessLiveScoreCountries,
		failure :handleFailureLiveScoreCountries
	}, posted);
}

//----------------------------------------------------------------------------------------------------------------------

function changeOzelEtkinlik(eventType) {
	var eventCode = document.getElementById("eventCode").value;
	var url = "iddaa-liste?eventType=" + eventType + "&eventCode=" + eventCode;
	document.getElementById("maclistesi").src = url;
}

//Kupona maç ekler
function addMatchToCoupon(el,eventType, mackodu, macadi, oran, MBS, tercih, gametype) {
	parent.addRowToTable(eventType,'genis', el, mackodu, macadi, oran, gametype, MBS, tercih, 0)
}

//Kupona ozel etkinlik maçları ekler.
function addSpecialGames(el,eventType, mackodu, macadi, oran, gameType, MBS, tercih, eventCode, eventdesc) {
	parent.addRowToTable(eventType,'genis', el, mackodu, macadi, oran, gameType, MBS, tercih, 0, eventCode, eventdesc)
}

function addMatchToCouponAllBets(el,eventType, mackodu, macadi, oran, MBS, tercih, gametype) {
	parent.insertDigerBahis(eventType,el, mackodu, macadi, oran, MBS, tercih, gametype);
}

function showAllBets(matchid) {
	var url = "iddaa-liste?matchid=" + matchid
	sH = Math.round((screen.height / 2) - ((370 / 2)));
	parent.detaywindow = window.open(url, "diger", 'width=800,height=450,left=0,top=' + sH);
}

//Ana sayfa icin Kuponu arkadasına gonderır.
function sendCouponToFriend(refreshBackGroundonClose) {
	if (errorCheck()) {
		var sistem = sistemiHazirla();
		var sonuc = kuponuOnayaHazirla();
		var misli = document.myForm.multiplier.value;

		var oran = document.getElementById("totalOdds").value;
		var atc = oran;
		var kolon = document.getElementById("kolonCount").value;
		var url = 'kupon-gonder?source=1&action=sendCouponToFriend&sonuc=' + encodeURIComponent(sonuc) + "&misli=" + misli
				+ "&sistem=" + sistem + "&oran=" + atc + "&kolon=" + kolon;
		if (refreshBackGroundonClose) {
			url += "&refreshBackGroundonClose=true";
		}
		Lightview.show( {
			href :url,
			rel :'iframe',
			options : {
				topclose :true,
				autosize :true,
				keyboard :false,
				overlayClose :false,
				width :759,
				height :260
			}
		});

	}
}


function showMatchComments(matchid){
   var url="/iddaa/mac-yorum?matchid="+matchid; 
    	window.parent.Lightview.show( {
			href :url,
			rel :'iframe',
			options : {
				topclose :true,
				autosize :true,
				keyboard :false,
				overlayClose :false,
				width :890,
				height :490
			}
		});

}

function sendSavedCouponToFriend(coupon_id) {
	var url = "kupon-gonder?action=sendCouponToFriend&";
	url += "scoupon_id=" + coupon_id;

	Lightview.show( {
		href :url,
		rel :'iframe',
		options : {
			topclose :true,
			autosize :true,
			keyboard :false,
			overlayClose :false,
			width :759,
			height :260
		}
	});

}

function showMatchDetails(matchid) {
    //window.parent.Lightview.show({href:'', rel:'iframe', options:{topclose:true, width:739, height:397}});
	var url = "/iddaa/iddaa-liste?matchid="+matchid;

	window.parent.Lightview.show( {
		href :url,
		rel :'iframe',
		options:{
            topclose:true,
            width:739,
            height:397}
	});

}

/**
 * Recolors the selected matches
 * @param genismi
 * @param gameType
 */

function ReColorSelectedMatches(genismi) {

	var myColor = '#aadf68';

	var framexz = document.getElementById("maclistesi");
	if (!framexz)
		framexz = window.parent.document.getElementById("maclistesi");

    if (!framexz)
        return;
	var maclistesi;

	maclistesi = getMaclistesi();
	if (maclistesi != null && maclistesi.length) {
		for (ki = 0; ki < maclistesi.length; ki++) {
			var match = maclistesi[ki];
			var guessss = match.guess;
			var idddd;
			var oyuntipi = match.gameType;
			if (oyuntipi.indexOf('SE')>-1 || oyuntipi.indexOf('UV')>-1) {
				guessss = guessss.substr(0, guessss.indexOf("::"));
				idddd = "" + getMatchIdFromMATCHID(match.matchid) + "_" + match.eventCode + "_" + match.gameType + "_"
						+ guessss;
			} else {
				idddd = "" +getMatchIdFromMATCHID (match.matchid) + "_" + match.gameType + "_" + guessss;
			}
			var tercihtd;

                var doc = null;
                if(framexz.contentDocument)
                   // Firefox, Opera
                   doc = framexz.contentDocument;
                else if(framexz.contentWindow)
                   // Internet Explorer
                   doc = framexz.contentWindow.document;
                else if(framexz.document)
                   // Others?
                   doc = framexz.document;

                tercihtd = doc.getElementById(idddd);
              
			if (tercihtd) {
				tercihtd.setAttribute("bgColor", myColor);
			}
			if (!tercihtd || tercihtd==null) { //Butun row un backgroundunu boyuyoz.
                var trx=doc.getElementById("tr_row"+getMatchIdFromMATCHID(match.matchid));
				var tr_table =doc.getElementById("tr_table"+getMatchIdFromMATCHID(match.matchid));

                var myframeName=framexz.src;
                var currentEventType=1;
                var currentgameType="";
                if (myframeName.indexOf("eventType")>-1){
                    currentEventType=myframeName.substring(myframeName.indexOf("eventType")+10,myframeName.indexOf("eventType")+11);
                }
                if (myframeName.indexOf("gameType")>-1){
                    var newsrc=myframeName.substring(myframeName.indexOf("gameType")+9,myframeName.length);
                    currentgameType=newsrc.substring(0,newsrc.indexOf("&"));
                }

                if (trx)
                    {
                        var cells =trx.cells;
                          var starttd=0;
                            var endtd=cells.length;
                            if (currentEventType==1 && currentgameType=='SF'){
                                starttd=6;
                                endtd=cells.length-1;
                            }else if (currentEventType==1 && currentgameType==''){
                                starttd=6;
                                endtd=cells.length-1;
                            }else if (currentEventType==1 && currentgameType=='GS'){
                                starttd=6;
                                endtd=cells.length-1;                                
                            }else if (currentEventType==2 && currentgameType=='SF'){
                                starttd=10;
                            }else if (currentEventType==2 && currentgameType==''){
                                starttd=6;
                            }
                        for (var kl=starttd;kl<endtd;kl++){
                            var trcellll=cells[kl];
                            trcellll.setAttribute("bgColor",myColor);
                        }
                    }
                else if  (tr_table)
				       {
				           tr_table.setAttribute("bgColor",myColor);
				           for (i=0;i<tr_table.rows.length;i++){
				                        var trxxx=tr_table.rows[i];
				                        trxxx.setAttribute("bgColor",myColor)
				                        for (k=0;k<trxxx.cells.length;k++)
				                              trxxx.cells[k].setAttribute("bgColor",myColor)
				                    }
				       }
				}

		}
	}//Maclistesi defind
}

//------------------------------------------------------------------------------
//İddaaOnay-iddaaPlay    sayfaları icin yapildi.
function onayGeriDon() {

  if (document.forms['onayGeriForm'].ai.value!=''){
        self.close();
  }else {
  	document.forms['onayGeriForm'].submit();
  }
}
function onayCoupon() {
	document.forms['onayForm'].submit();
}
function onayBilyonPara() {
        document.forms['onayForm'].bilyonpara.value = "true";
        document.forms['onayForm'].submit();    
}

//----------------------------------------------------------------------------------
//Kuponu Gonder sayfalarında kullanılan javascriptler

function submitForm() {
	//  document.myForm.sonucxxrow.value=document.myForm.innerHTML;

	document.myForm.send.value = "true";
	var Myform = document.myForm;
	var trtable = document.getElementById("emailArea");
	var rows = trtable.getElementsByTagName("input");
	var counter = 0;
	for (i = 0; i < rows.length; i += 2) {
		var x = rows[i];
		if (trim12(x.value) == '' && rows.length == 1) {
			alert("Lütfen göndermek istediğiniz e-posta adresini giriniz.");
			return false;
		}
		if (trim12(x.value) != '') {
			if (validateEmail(x)) {
				var tdx2 = document.createElement("input");
				tdx2.setAttribute("type", "hidden");
				tdx2.setAttribute("name", "email");
				tdx2.setAttribute("id", x.value);
				tdx2.setAttribute("value", x.value);
				Myform.appendChild(tdx2);
				counter++;
			}
		}
	}
	if (counter > 0) {

		document.myForm.submit();
		return true;
	}
	return false;
}

//-------------------------------------------------end of kupon gonder skriptler
function showLoginMessage(message) {
	alert(message);
}


function showLiveBrodcastMessage(el,channel){
	//el.title="Bu maç -"+channel+"- kanalında canlı olarak gösterilecektir!";
	//el.alt="Bu maç -"+channel+"- kanalında canlı olarak gösterilecektir!";
	el.title=channel.toUpperCase();
	el.alt=channel.toUpperCase();	
}

function clearAll(type){
	var lgs=80;
	for(i=0; i<lgs+1; i++){
		try{
			document.getElementById("chb"+i).checked=false;
		}catch(ee){
			break;
		}
	}
	getCanliSonuclar(type,false);
}

function refreshLiveScoresAuto() {

	var refresh = false;
	var sporttype = '1';
	try{					
		sporttype = document.getElementById("typeOfMySport").getAttribute("value");
		refresh = true;
	}catch(ee){}
	
	if(refresh){
		getCanliSonuclar(sporttype,false);
	}
						       		
}
//// istatistikler ///
function handleCheckStats(o){			
	if(o.responseText !== undefined){		
		if(o.responseText.indexOf("TRUE")>-1){		
			if(!isLogined()){
				if(window.opener){
					window.parent.location = window.parent.location;
				}else{
					window.location.reload();
				}
			}
			window.open(o.argument.toString(),'Istatistikler','height=700,width=1000,status=yes,toolbar=no,menubar=no,resizable=yes,location=no,left=25,top=20');
			return true;
		}else if(o.responseText.indexOf("FALSE")>-1){
			alert("Lütfen üye girişi yapınız.");
			
		}		
	}
}

function handleFailureStats(o){
	if(o.responseText !== undefined){	
		window.open(o.argument.toString(),'Istatistikler','height=700,width=1000,status=yes,toolbar=no,menubar=no,resizable=yes,location=no,left=25,top=20');
		return true;					
	}
}

function checkStats(wurl){		
		var urlstr = "/iddaa/iddaa-istatistikler";

       var request = YAHOO.util.Connect.asyncRequest('POST', urlstr, 
    		   {timeout: 25000,success:handleCheckStats,failure:handleFailureStats,argument:[wurl]},"control=true");
}

function getMatchStatistics(matchid,leage){
	var wurl = "/iddaa/iddaa-istatistikler?m="+matchid;	
	if (leage&& leage>0){
	    wurl+="&l=1";
	}
	checkStats(wurl);
}



//Affiliate İçin Yapildi.

function changeHazirKuponTab(id){
for (var i=1;i<=11; i++){
    if (id!=i){
            document.getElementById("mainTab"+i).style.visibility='hidden';
            document.getElementById("mainTab"+i).style.display="none";
        }else{
            document.getElementById("mainTab"+id).style.visibility="visible";
            document.getElementById("mainTab"+id).style.display="block";
        }
    }



var alink=document.getElementById("mainTab"+id).getElementsByTagName("a")[0];

getHazirKupon(alink);

if (id%2==1){
    if (document.getElementById("mainTab"+(id+1))){
        document.getElementById("mainTab"+(id+1)).style.visibility="visible";
        document.getElementById("mainTab"+(id+1)).style.display="block";
         var  aalink=document.getElementById("mainTab"+(id+1)).getElementsByTagName("a")[0];
        getHazirKupon(aalink);
    }
}else {
    if (document.getElementById("mainTab"+(id-1))){
        document.getElementById("mainTab"+(id-1)).style.visibility="visible";
        document.getElementById("mainTab"+(id-1)).style.display="block";
       var  aalink=document.getElementById("mainTab"+(id-1)).getElementsByTagName("a")[0];
            getHazirKupon(aalink);
    }
}




}

function getHazirKupon(el){
    var urlx=el.getAttribute("href");

   var  divx=el.parentNode.parentNode.parentNode;
    if (divx){
         var allHrefs=divx.getElementsByTagName("a");
        for (k=0;k<allHrefs.length;k++){
            allHrefs[k].setAttribute("class","iddaaTabsTab");
            allHrefs[k].style.visibility="visible";
            allHrefs[k].style.display="block";
        }
        divx=divx.getElementsByTagName("div")[0];
    }


    var request = YAHOO.util.Connect.asyncRequest('POST', urlx, {
        timeout: 25000,
        success:gethandleSuccessHazirKupon(divx),
        failure:gethandleFailureHazirKupon(divx)
    });
     el.setAttribute("class","selected");
            el.style.visibility="visible";
            el.style.display="block";
}


  function  gethandleSuccessHazirKupon (divx){
      return function(o) {
  	if (o.responseText !== undefined) {
		divx.innerHTML = o.responseText;
   	}
}
  }
function  gethandleFailureHazirKupon (divx) {
    return function(o) {
	if (o.responseText !== undefined) {
		divx.innerHTML = "";
	}
}
}

   function insertDigerBahis(eventType,el, mackodu, macadi,oran,MBS,tercih,gametype)  {
        addRowToTable(eventType,'detay',el, mackodu, macadi,oran,gametype,MBS,tercih,0);
    }