﻿var formObj = document.liveForm;
var chkboxes;
var chkboxes0;
var chkboxes1;
var chkboxes2;
var chkboxes2;
var chkboxesU;
var chkboxesO;
var chkboxesO;

function initVariables(){
	chkboxes = getElementsById("input","chkboxes");
	chkboxes0 = getElementsById("input","chkboxes0");
	chkboxes1 = getElementsById("input","chkboxes1");
	chkboxes2 = getElementsById("input","chkboxes2");
	chkboxesU = getElementsById("input","chkboxesU");
	chkboxesO = getElementsById("input","chkboxesO");
}

//Sayfa load olduğunda(refresh vs halinde) cookie deki durumuna göre
//seçililer, hepsi butonunun durumunu ayarlar
if (getCookie("CHOICED") && (cookieVariables.lc && cookieVariables.lc == 's')) {
	$("spnsecili").style.display = 'none';
	$("spnhepsi").style.display = 'inline';
}else{
	$("spnsecili").style.display = 'inline';
	$("spnhepsi").style.display = 'none';
}
if (cookieVariables.gs) {
	for(var i=0;i<document.liveForm.ddlGoalSound.options.length;i++){
	    if (formObj.ddlGoalSound.options[i].value == cookieVariables.gs) {
			formObj.ddlGoalSound.options[i].selected = true;
		}
	}
}

if (cookieVariables.st && $('imgFootball')) {
    if (cookieVariables.st == 0)
        {
            $('imgFootball').src = variables.imagePath +'futbol-over.gif';
            $('imgFootball').title = 'Futbol maçlarını gösterme';
            $('imgBasketball').src= variables.imagePath+'basketbol-over.gif';
            $('imgBasketball').title = 'Basketbol maçlarını gösterme';
        }
        else if (cookieVariables.st == 1)
        {
            $('imgFootball').src= variables.imagePath+'futbol-over.gif';
            $('imgFootball').title = 'Futbol maçlarını gösterme';
            $('imgBasketball').src= variables.imagePath+'basketbol.gif';
            $('imgBasketball').title = 'Basketbol maçlarını da göster';
        }
        else if (cookieVariables.st == 2)
        {
            $('imgFootball').src= variables.imagePath+'futbol.gif';
            $('imgFootball').title = 'Futbol maçlarını da göster';
            $('imgBasketball').src= variables.imagePath+'basketbol-over.gif';
            $('imgBasketball').title = 'Basketbol maçlarını gösterme';
        }
        else
        {
            $('imgFootball').src= variables.imagePath+'futbol-over.gif';
            $('imgFootball').title = 'Futbol maçlarını gösterme';
            $('imgBasketball').src= variables.imagePath+'basketbol.gif';
            $('imgBasketball').title = 'Basketbol maçlarını da göster';
        }
}
else if($('imgFootball'))
{
    $('imgFootball').src= variables.imagePath+'futbol-over.gif';
    $('imgFootball').title = 'Futbol maçlarını gösterme';
    $('imgBasketball').src= variables.imagePath+'basketbol.gif';
    $('imgBasketball').title = 'Basketbol maçlarını da göster';
}


//Sayfa load olduğunda(refresh vs halinde) cookie deki durumuna göre
//ses kapalı/açık butonunun durumunu + hidden değişkenin değerini ayarlar
if ((cookieVariables.se && cookieVariables.se == 'OFF')) {
		$("spnSoundOff").style.display = 'none';
		$("spnSoundOn").style.display = 'inline';
		$("hdnSoundStatus").value="OFF";
}else{
		$("spnSoundOff").style.display = 'inline';
		$("spnSoundOn").style.display = 'none';
		$("hdnSoundStatus").value="ON";
}

if ("false" == cookieVariables.le) {
    setTimeout("hideLatestEvents()",3000);
}


/**SWAP FUNCTIONS***/

//Tercihlerimi göster/gizle butonuna tıklandığında bu function çalışır.
//Tercihlerin bulunduğu td lerin style i ile oynayarak gizleyip gösterir
function tercihGG(p) {
    if (p == 's') {
        $("spntercihgoster").style.display = 'none';
        $("spntercihgizle").style.display = 'inline';
        var chkTdObjs = getElementsById("td", "chkbtd")
        if (chkTdObjs) {
            for (var i = 0; i < chkTdObjs.length; i++) {
                chkTdObjs[i].style.display = document.all ? 'inline' : 'table-cell';
            }
        }
    } else {
        $("spntercihgoster").style.display = 'inline';
        $("spntercihgizle").style.display = 'none';
        var chkTdObjs = getElementsById("td", "chkbtd")
        if (chkTdObjs) {
            for (var i = 0; i < chkTdObjs.length; i++) {
                chkTdObjs[i].style.display = 'none'
            }
        }

    }
}

//Listele, canli, iddaa , hepsi ve secili butonlarina tiklandiğinda calisir
function allMatchesGG(p) {
    cookieVariables.setValue("lc", p);

    if (p == 's') { //seçili butonu tıklanınca
        var matches = getChoicedMatches();
        if (matches == "") {
            cookieVariables.setValue("lc", 'h');
            return false;
        }
        var expiration = new Date();
        expiration.setTime(expiration.getTime() + (120 * 60 * 1000)); //90 dakika
        setCookie("CHOICED", matches, expiration);
        $("spnsecili").style.display = 'none';
        $("spnhepsi").style.display = 'inline';

        showHideMatches();
    } else if (p == 'h') {//hepsi tıklanınca
        $("spnsecili").style.display = 'inline';
        $("spnhepsi").style.display = 'none';
        showAllMatches();
        relocateBanners();
    } 
}

function soundOnOff(p) {
    if (p == 'f') {
        $("spnSoundOff").style.display = 'none';
        $("spnSoundOn").style.display = 'inline';
        $("hdnSoundStatus").value = "OFF";
        cookieVariables.setValue("se", "OFF");
    } else {
        $("spnSoundOff").style.display = 'inline';
        $("spnSoundOn").style.display = 'none';
        $("hdnSoundStatus").value = "ON";
        cookieVariables.setValue("se", "ON");
    }
}

function swapSportFilter(obj)
{
    if(obj.src.indexOf('over')>-1)
    {
        obj.src = obj.src.substr(0,obj.src.indexOf('-'))+'.gif';
        if(obj.src.indexOf('basket')>-1){
            obj.title = 'Basketbol maçlarını da göster';
        }
        else
        {
            obj.title = 'Futbol maçlarını da göster';
        }
    }
    else
    {
        obj.src = obj.src.substr(0,obj.src.lastIndexOf('.'))+'-over.gif';
        if(obj.src.indexOf('basket')>-1){
            obj.title = 'Basketbol maçlarını gösterme';
        }
        else
        {
            obj.title = 'Futbol maçlarını gösterme';
        }
        
    }
    filterMatches();
}

function swapIddaaFilter(obj) {
    seqVal = -1;
    if (obj.src.indexOf('over') > -1) {
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('_')) + '.gif';
        obj.title = 'Sadece iddaa maçlarını göster';
        sIddaa = 0;
    }
    else {
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('.')) + '_over.gif';
        obj.title = 'Tüm maçları göster';        
        sIddaa = 1;
    }
    sAllIddaa = 0;
    $('programButton').src = variables.imagePath + 'canli_program.gif';
    getMatches();
}

function swapProgramFilter(obj) {
    if (1 == sAllIddaa) {
        seqVal = -1;
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('_')) + '.gif';
        sAllIddaa = 0;
        getMatches();        
    }
    else if (0 == sAllIddaa) {
        seqVal = -1;
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('.')) + '_over.gif';
        
        $('iddaaButton').src = variables.imagePath + 'idda_canli.gif';
        $('iddaaButton').title = 'Sadece iddaa maçlarını göster';
        sIddaa = 0;

        $('liveButton').src = variables.imagePath + 'canli_tab.gif';
        $('liveButton').title = 'Sadece devam eden maçları göster';
        sCanli = 0;
                
        sAllIddaa = 1;
        getMatches();
    }
}
function swapCanliFilter(obj) {
    seqVal = -1;
    if (obj.src.indexOf('over') > -1) {
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('_')) + '.gif';
        obj.title = 'Sadece devam eden maçlarını göster';
        sCanli = 0;
    }
    else {
        obj.src = obj.src.substr(0, obj.src.lastIndexOf('.')) + '_over.gif';
        obj.title = 'Tüm maçları göster';
        sCanli = 1;

    }
    sAllIddaa = 0;
    if ($('programButton'))    $('programButton').src = variables.imagePath + 'canli_program.gif';
    getMatches();
}    
function filterMatches(){
    seqVal = -1;
    if($('imgFootball').src.indexOf('over') != -1 && $('imgBasketball').src.indexOf('over') != -1)
 
    {
         sportType = 0;
    }
    else if($('imgFootball').src.indexOf('over') == -1 && $('imgBasketball').src.indexOf('over') != -1)
    {
        sportType = 2;
    }
    else if($('imgFootball').src.indexOf('over') != -1 && $('imgBasketball').src.indexOf('over') == -1)
    {
        sportType = 1;
    }
    else
    {
        $('imgFootball').src= variables.imagePath+'futbol-over.gif';
        $('imgFootball').title = 'Futbol maçlarını gösterme';
        sportType = 1;
    }
    //sAllIddaa = 0;
    
    setUserSportsChoice(sportType)
    getMatches();
}


function submitGroup(obj) {
    seqVal = -1;
    $('programButton').src = variables.imagePath + 'canli_program.gif';
    sAllIddaa = 0;
    sDdlGrup = obj.value;
	getMatches();			
}


//Sayfadaki tarih textinin onchange eventinde çalışır
formObj.txtDate.onchange = function() {
    if (formObj.txtDate.value.length == 0) {
        $('imgToday').style.display = 'none';
        return;
    }
    if (isDate(formObj.txtDate.value)) {
        seqVal = -1;
        $('imgToday').style.display = 'inline';
        sTxtDate = formObj.txtDate.value;
        getMatches();
    } else {
        alert("Lütfen geçerli bir tarih giriniz!\nÖrn: 18-5-2005,18/5/2005,18.5.2005")
    }
}

document.onkeydown = function(){
	if(document.all &&  event.keyCode == 13){
		formObj.txtDate.onchange();
	}
}


//Hepsini sec, gizle checkbox ina tiklandiginda calisir
function checkUnCheckAll(){
	var boolChecked = $("chkall").checked;
	if(chkboxes){
		for(var i=0;i<chkboxes.length;i++){
			chkboxes[i].checked = boolChecked;
		}
	}	
}
function showToday() {
    $('imgToday').style.display = 'none';
    $('txtDate').value = '';
    sTxtDate = '';
    seqVal = -1;
    getMatches();			
}
//Secim gozetmeksizin tum maclari listeler
function showAllMatches(){
	var buff = 0;
	if(chkboxes){
		for(var i=0;i<chkboxes.length;i++){
			var obj = chkboxes[i].parentNode.parentNode;
			obj.style.display = document.all ? 'inline' : 'table-row';
			if((document.all && obj.style.backgroundColor !="#bdf899")||(!document.all && rgb2Hex(obj.style.backgroundColor) !="#bdf899" )){ //Macta yeni gol olmussa acik yesil olan satir bg sini bozma!
				if(buff % 2 == 0)
					obj.style.backgroundColor ='#ffffff';	
				else
					obj.style.backgroundColor ='#f0f0f4';	
			}
			buff++;
		}
	}			

}
//Kullanicin tercihlerine gore dakika bilgisini, o anda tahmini tutuyorsa yesil, tutmuyorsa kirmizi yapar.
function tuneMinutecolor(macId,skor1,skor2,idx, tip,h1,h2,au){
    
	var isWin = true;
	
	if(1 == tip){
	    if(chkboxesU[idx].checked || chkboxesO[idx].checked)
	    {
		    if((parseInt(skor1)+parseInt(skor2) >= 3 && chkboxesU[idx].checked) || (parseInt(skor1)+parseInt(skor2) < 3 && chkboxesO[idx].checked))
		    {
			    isWin = false;
		    }
	    }
	    else if(chkboxes1[idx].checked || chkboxes0[idx].checked ||chkboxes2[idx].checked)
	    {

            skor1 = parseInt(skor1)+parseInt(h1);
            skor2 = parseInt(skor2)+parseInt(h2);
            
		    if((chkboxes1[idx].checked && chkboxes2[idx].checked && parseInt(skor1)==parseInt(skor2)) 
		    || (parseInt(skor1)>parseInt(skor2) && !chkboxes1[idx].checked) 
		    || (parseInt(skor1)==parseInt(skor2) && !chkboxes0[idx].checked )
		    || (parseInt(skor1)<parseInt(skor2) && !chkboxes2[idx].checked)){
			    isWin = false;
		    }
	    }
	}
	else
	{
	    if(chkboxesU[idx].checked || chkboxesO[idx].checked)
	    {
		    if((parseInt(skor1)+parseInt(skor2) >= parseFloat(au.replace(',','.')) && chkboxesU[idx].checked) || (parseInt(skor1)+parseInt(skor2) < parseFloat(au.replace(',','.')) && chkboxesO[idx].checked))
		    {
			    isWin = false;
		    }
	    }
	    else if(chkboxes1[idx].checked || chkboxes2[idx].checked)
	    {
            if(h1){
		        if((chkboxes1[idx].checked && parseInt(skor1)+parseFloat(h1.replace(',','.'))<parseInt(skor2)) || (chkboxes2[idx].checked && parseInt(skor1)+parseFloat(h1.replace(',','.'))>parseInt(skor2)) ){
			        isWin = false;
		        }
		    }else if(h2){
		       if((chkboxes1[idx].checked && parseInt(skor1)<parseInt(skor2)+parseFloat(h2.replace(',','.'))) || (chkboxes2[idx].checked && parseInt(skor1)>parseInt(skor2)+parseFloat(h2.replace(',','.'))) ){
			        isWin = false;
		        }
		    }
	    }
	}
	if( !isWin)
	{
		$("D"+macId).className = "red";
	}
	else
	{
		$("D"+macId).className = "green";
	}
}

//secilileri gizleyip gosteren function
function showHideMatches() {
    
	var matches = getCookie("CHOICED");
	var sonTik = cookieVariables.lc;
	var bets = getCookie("BETS");
	if(bets && chkboxes){
		//cookiedeki kullanici tercihlerine gore checkbox larin defaultlarini set ediyoruz
		for(var i=0;i<chkboxes.length;i++){
			if( bets.indexOf( chkboxes1[i].value ) != -1){
				chkboxes1[i].checked = true;
				chkboxes[i].checked = true;
			}
			if( bets.indexOf( chkboxes0[i].value ) != -1){
				chkboxes0[i].checked = true;
				chkboxes[i].checked = true;
			}
			if( bets.indexOf( chkboxes2[i].value ) != -1){
				chkboxes2[i].checked = true;
				chkboxes[i].checked = true;
			}
			if( bets.indexOf( chkboxesU[i].value ) != -1){
				chkboxesU[i].checked = true;
				chkboxes[i].checked = true;
			}
			if( bets.indexOf( chkboxesO[i].value ) != -1){
				chkboxesO[i].checked = true;
				chkboxes[i].checked = true;
			}
			
						
			var macID = chkboxes[i].value;
			if($("S"+macID)){
				var skor=$("S"+macID).innerHTML;
				//tip,h1,h2,au
				if(chkboxes0[i]){
				    tuneMinutecolor(macID,skor.split('-')[0],skor.split('-')[1],i,1, chkboxes1[i].attributes.getNamedItem("hnd").nodeValue,chkboxes2[i].attributes.getNamedItem("hnd").nodeValue);
				}else
				{
				    tuneMinutecolor(macID,skor.split('-')[0],skor.split('-')[1],i,2,chkboxes1[i].title,chkboxes2[i].title,chkboxesU[i].title);
				}
			}
		}
	}	
	
	if(!matches)
		matches = "";
var buff = 0;

	if(chkboxes){
		for(var i=0;i<chkboxes.length;i++){
			var obj = chkboxes[i].parentNode.parentNode;
			if (sonTik && sonTik == 's') {//en son secili butonu tiklandiysa
			    hideAllBannerItems();
				if( matches.indexOf( chkboxes[i].value ) != -1){
					chkboxes[i].checked = true;
					obj.style.display = document.all ? 'inline' : 'table-row';//checksizleri gizliyoruz)
					
					if((document.all && obj.style.backgroundColor !="#bdf899")||(!document.all && rgb2Hex(obj.style.backgroundColor) !="#bdf899" )){
						if(buff % 2 == 0)
							obj.style.backgroundColor ='#ffffff';	
						else
							obj.style.backgroundColor ='#f0f0f4';
					}	
					buff++;
				}else{
					obj.style.display = 'none';
				}
			}else{
			    relocateBanners();
				if((document.all && obj.style.backgroundColor !="#bdf899")||(!document.all && rgb2Hex(obj.style.backgroundColor) !="#bdf899" )){
					if(i % 2 == 0)
						obj.style.backgroundColor ='#ffffff';	
					else
						obj.style.backgroundColor ='#f0f0f4';
				}				
				//Hepsini gosteriyor olsak da kullanicinin tercihlerini yine de check li getiriyoruz(ama checksizleri gizlemiyoruz)
				if( matches.indexOf( chkboxes[i].value ) != -1){
					chkboxes[i].checked = true;
				}
			}
		}

		if (sonTik && sonTik == 's' && buff == 0) {
		    showAllMatches();
		    relocateBanners();
		    cookieVariables.setValue("lc", 'h');
		}
	}			

}

//secili olan maclari cookiye atacagimiz hale donusturur
function getChoicedMatches(){
	var retStr = "";
	if(chkboxes){
		for(var i=0;i<chkboxes.length;i++){
			if(chkboxes[i].checked){
				if(retStr != "")
					retStr += "|";
				retStr += chkboxes[i].value;
			}
		}
	}

	return retStr;

}
//tercihlerdeki checkboxlarin clicklerinde calisir
function MMCheckBox(obj,idx, tip){

	var s = "";
	var macID = obj.value.substr(0,obj.value.length-2);

	if( (obj.name=='chkboxesU' || obj.name=='chkboxesO') && obj.checked){
		
		if(obj.name=='chkboxesU' && obj.checked)
		{
			if(chkboxesO[idx].checked){
				chkboxesU[idx].checked=false;
			}
		}
		else if(obj.name=='chkboxesO' && obj.checked)
		{
			if(chkboxesU[idx].checked){
				chkboxesO[idx].checked=false;
			}
		}
		
		chkboxes1[idx].checked=false;
		chkboxes0[idx].checked=false;
		chkboxes2[idx].checked=false;
		
	}else if( (obj.name=='chkboxes1' || obj.name=='chkboxes0'|| obj.name=='chkboxes2') && obj.checked ){
	
	  if(tip==1)
	  {
		    if(obj.name=='chkboxes1' && obj.checked)
		    {
			    if(chkboxes0[idx].checked && chkboxes2[idx].checked){
				    chkboxes1[idx].checked=false;
			    }
		    }
		    else if(obj.name=='chkboxes2' && obj.checked)
		    {
			    if(chkboxes0[idx].checked && chkboxes1[idx].checked){
				    chkboxes2[idx].checked=false;
			    }
		    }
		    else if(obj.name=='chkboxes0' && obj.checked)
		    {
			    if(chkboxes1[idx].checked && chkboxes2[idx].checked){
				    chkboxes0[idx].checked=false;
			    }
		    }		
		    chkboxesU[idx].checked =false;
		    chkboxesO[idx].checked=false;
	    }
	    else if (tip == 2){
            if(obj.name=='chkboxes1' && obj.checked)
		    {
			    if(chkboxes2[idx].checked){
				    chkboxes1[idx].checked=false;
			    }
		    }
		    else if(obj.name=='chkboxes2' && obj.checked)
		    {
			    if(chkboxes1[idx].checked){
				    chkboxes2[idx].checked=false;
			    }
		    }
		    chkboxesU[idx].checked =false;
		    chkboxesO[idx].checked=false;	    
	    }
	}
	
	
	if($("S"+macID)){
		var skor=$("S"+macID).innerHTML;
		if(chkboxes0[idx]){
		    tuneMinutecolor(macID,skor.split('-')[0],skor.split('-')[1],idx,1,chkboxes1[idx].attributes.getNamedItem("hnd").nodeValue,chkboxes2[idx].attributes.getNamedItem("hnd").nodeValue);
		}else
		{
            tuneMinutecolor(macID,skor.split('-')[0],skor.split('-')[1],idx,2,chkboxes1[idx].title,chkboxes2[idx].title,chkboxesU[idx].title);
		}
		
	}
	
	if( chkboxes1[idx].checked || chkboxes0[idx].checked || chkboxes2[idx].checked  || chkboxesU[idx].checked || chkboxesO[idx].checked)
		chkboxes[idx].checked=true;
	else
		chkboxes[idx].checked=false;

	if(chkboxes1){
		for(var i=0;i<chkboxes1.length;i++){
			if(chkboxes1[i].checked){
				if(s != "")
					s += "|";
				s += chkboxes1[i].value;
			}
		}
	}	
	if(chkboxes0){
		for(var i=0;i<chkboxes0.length;i++){
			if(chkboxes0[i].checked){
				if(s != "")
					s += "|";
				s += chkboxes0[i].value;
			}
		}
	}	
	if(chkboxes2){
		for(var i=0;i<chkboxes2.length;i++){
			if(chkboxes2[i].checked){
				if(s != "")
					s += "|";
				s += chkboxes2[i].value;
			}
		}
	}	
	if(chkboxesU){
		for(var i=0;i<chkboxesU.length;i++){
			if(chkboxesU[i].checked){
				if(s != "")
					s += "|";
				s += chkboxesU[i].value;
			}
		}
	}	
	if(chkboxesO){
		for(var i=0;i<chkboxesO.length;i++){
			if(chkboxesO[i].checked){
				if(s != "")
					s += "|";
				s += chkboxesO[i].value;
			}
		}
	}
	//her seferinde kullanicinin tercihleri string haline getirilip coookie ye atiliyor.
	var expiration = new Date();
	expiration.setTime(expiration.getTime() + (24 * 60 * 60 * 1000)); //1 gün
	setCookie("BETS", s, expiration);
	setChoicedMatches();
}




function playSound(soundName) {
    var sStr = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' WIDTH='1' HEIGHT='1'>";
    sStr += "<param name='movie' value='" + soundName + "'>";
    sStr += "<param name='quality' value='high'><param name='wmode' value='transparent'><param name='width' value='1'><param name='height' value='1'>";
    sStr += "<embed src='" + soundName + "'";
    sStr += "quality='best' wmode='transparent' width='1' height='1'/>";
    sStr += "</object>";
    $("SOUND_HOLDER").innerHTML = sStr;
}

function playGoalSound(newGoals){

	if(newGoals == ''){
		return;
	}
	var isPlaySound = false;
	var playedGoals = getCookie("PLAYEDGOALS");
	var colArray = newGoals.split('|');

	try{	
       for(var i=0;i<colArray.length-1;i++){
           var newGoalToken = colArray[i];
           var arrGoalToken = newGoalToken.split('_');
           var macID = arrGoalToken[0] + "_" + arrGoalToken[1];
           parentTR = $("S" + macID).parentNode.parentNode.parentNode.parentNode;
           if( ( !isPlaySound && (!playedGoals || playedGoals.indexOf(newGoalToken)==-1) && parentTR.style.display != 'none' && document.liveForm.hdnSoundStatus.value == 'ON')){                                                                      
               isPlaySound = true;                                                                                      
           }
       }              
	}catch(e){
	}
	
	var expiration = new Date();
	expiration.setTime(expiration.getTime() + (120 * 60 * 1000)); //90 dakika
	setCookie("PLAYEDGOALS",newGoals,expiration);						

	if(isPlaySound){
			playSound(variables.imagePath +"sounds/"+document.liveForm.ddlGoalSound.value);
	}
}
function setUserGoalSound(soundName){
    playSound(variables.imagePath + 'sounds/' + soundName)
    cookieVariables.setValue("gs", soundName);
}

function setUserSportsChoice(userOption) {
    cookieVariables.setValue("st", userOption);
}

function refreshScoresInterval(intervalInSeconds){

	window.clearInterval(intInterval);
	
	intInterval = window.setInterval('getMatches()',intervalInSeconds * 1000);
}


function showLatestEvents() {
    hideAllBannerItems();
    $('sonolay-kapali').style.display = 'none';
    $('sonolay-acik').style.display = 'block';

    cookieVariables.setValue("le", true);
   
    var oAnim = new YAHOO.util.Anim($("sonolay-acik"), { height: { to: 150} }, 1, YAHOO.util.Easing.easeBoth);
    oAnim.onComplete.subscribe(function() {
        relocateBanners(); 
    });
    
    oAnim.animate();
    
}

function hideLatestEvents() {
    hideAllBannerItems();
    cookieVariables.setValue("le", false);
    
    
    var oAnim = new YAHOO.util.Anim($("sonolay-acik"), { height: { to: 24} }, 1, YAHOO.util.Easing.easeBoth);

    oAnim.onComplete.subscribe(function() {
        $('sonolay-kapali').style.display = 'block';
        $('sonolay-acik').style.display = 'none';
        relocateBanners();
    });
    oAnim.animate();
     
}


function relocateBanners() {
    relocateBanner('textBanner1Row', 'bannerContainer1');
    relocateBanner('textBanner2Row', 'bannerContainer2');        
}

function hideAllBannerItems() {
    if ($('bannerContainer1')) $('bannerContainer1').style.display = 'none';
    if ($('bannerContainer2')) $('bannerContainer2').style.display = 'none';
    if ($('textBanner1Row')) $('textBanner1Row').style.display = 'none';
    if ($('textBanner2Row')) $('textBanner2Row').style.display = 'none';    
}


function setChoicedMatches() {
    var expiration = new Date();
    expiration.setTime(expiration.getTime() + (120 * 60 * 1000)); //90 dakika
    setCookie("CHOICED", getChoicedMatches(), expiration);
}