/***********************
* Adobe Edge Composition Actions
*
* Edit this file with caution, being careful to preserve 
* function signatures and comments starting with 'Edge' to maintain the 
* ability to interact with these actions from within Adobe Edge
*
***********************/
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes

   //Edge symbol: 'stage'
   (function(symbolName) {
      
      
      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         var headline;
         var sources;
         var latest;
         var table1;
         var table2;
         var table3;
         var table4;
         var table5;
         var table6;
         var table7;
         var table8;
         var table9;
         var table10;
         var team1;
         var team2;
         var score;
         var match;
         var cap1;
         var cap2;
         var cap3;
         var btn0txt = sym.$("btn0Txt").css("pointer-events","none");
         var btn1txt = sym.$("btn1Txt").css("pointer-events","none");
         var grp1txt;
         var grp2txt;
         var grp3txt;
         var grp4txt;
         var grp5txt;
         var grp6txt;
         var grp7txt;
         var grp8txt;
         var rnd2;
         var qf;
         var sf;
         var fnl;
         var dates1;
         var dates2;
         var dates3;
         
         var d=new Date();
         
         //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
         
         $.ajax({	
         	type: "GET",
         	url: "GN29739.xml",
         	dataType: "xml",
         	success: function(xml) {
         
         		headline = $(xml).find('headline').text();
         		sym.$("headlineTxt").html(headline);				
         		sources = $(xml).find('sources').text();
         		sym.$("sourcesTxt").html(sources);		
         
         		table1 = $(xml).find('table1').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table1Txt").html(table1);
         		table2 = $(xml).find('table2').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table2Txt").html(table2);
         		table3 = $(xml).find('table3').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table3Txt").html(table3);
         		table4 = $(xml).find('table4').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table4Txt").html(table4);
         		table5 = $(xml).find('table5').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table5Txt").html(table5);
         		table6 = $(xml).find('table6').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table6Txt").html(table6);
         		table7 = $(xml).find('table7').text();
         		sym.getSymbol("panel0").getSymbol("fulltable").$("table7Txt").html(table7);
         
         		table8 = $(xml).find('table8').text();
         		sym.getSymbol("panel0").$("matches").append(table8);
         		table9 = $(xml).find('table9').text();
         		sym.getSymbol("panel0").$("table9Txt").html(table9);
         		sym.getSymbol("panel0").$("table10Txt").html(table9);
         
         		grp1txt = $(xml).find('grp1').text();
         		sym.getSymbol("panel0").$("grp1Txt").html(grp1txt);
         		grp2txt = $(xml).find('grp2').text();
         		sym.getSymbol("panel0").$("grp2Txt").html(grp2txt);
         		grp3txt = $(xml).find('grp3').text();
         		sym.getSymbol("panel0").$("grp3Txt").html(grp3txt);
         		grp4txt = $(xml).find('grp4').text();
         		sym.getSymbol("panel0").$("grp4Txt").html(grp4txt);
         		grp5txt = $(xml).find('grp5').text();
         		sym.getSymbol("panel0").$("grp5Txt").html(grp5txt);
         		grp6txt = $(xml).find('grp6').text();
         		sym.getSymbol("panel0").$("grp6Txt").html(grp6txt);
         		grp7txt = $(xml).find('grp7').text();
         		sym.getSymbol("panel0").$("grp7Txt").html(grp7txt);
         		grp8txt = $(xml).find('grp8').text();
         		sym.getSymbol("panel0").$("grp8Txt").html(grp8txt);
         
         		cap1 = $(xml).find('cap1').text();
         		cap2 = $(xml).find('cap2').text();
         
         		btn0 = $(xml).find('btn0').text();
         		btn0txt.html(btn0);
         		btn1 = $(xml).find('btn1').text();
         		btn1txt.html(btn1);
         
         		rnd2 = $(xml).find('rnd2').text();
         		sym.getSymbol("panel1").$("rnd2Txt").html(rnd2);
         		qf = $(xml).find('qf').text();
         		sym.getSymbol("panel1").$("qfTxt").html(qf);
         		sf = $(xml).find('sf').text();
         		sym.getSymbol("panel1").$("sfTxt").html(sf);
         		fnl =  $(xml).find('fnl').text();
         		sym.getSymbol("panel1").$("fnlTxt").html(fnl);
         		dates1 =  $(xml).find('dates1').text();
         		dates2 =  $(xml).find('dates2').text();
         		dates3 =  $(xml).find('dates3').text();
         		sym.getSymbol("panel1").$("rnd2matches").html(dates1);
         		sym.getSymbol("panel1").$("qfmatches").html(dates2);
         		sym.getSymbol("panel1").$("sfmatches").html(dates3);
         
         		}
         	});
         
         sym.getSymbol("panel1").$("last16").css("pointer-events","none");
         sym.getSymbol("panel1").$("quarters").css("pointer-events","none");
         sym.getSymbol("panel1").$("semis").css("pointer-events","none");
         sym.getSymbol("panel1").$("in2").css("pointer-events","none");
         
         
         
         //LIVE DATA
         var dataURL = ('http:'==document.location.protocol?"http://www2.graphicnews.com/":"https://www.graphicnews.org/")+ "infostradasports/api.php";
          var fixtureData;   
         function getFixtures() { 
         
          $.ajax({ type: "GET", url: dataURL,
                         data: "gn=29739&editionID=19911",
                         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
                         async: true,
                         crossDomain: true,
                         success: function (data) {
                              fixtureData = data;
                             for (var i = 0; i < fixtureData.length; i++) {
                            		if (i==0){
         		sym.getSymbol("panel0").$("#gt1").empty();
         		sym.getSymbol("panel0").$("#gt2").empty();
         		sym.getSymbol("panel0").$("#gt3").empty();
         		sym.getSymbol("panel0").$("#gt4").empty();
         		sym.getSymbol("panel0").$("#gt5").empty();
         		sym.getSymbol("panel0").$("#gt6").empty();
         		sym.getSymbol("panel0").$("#gt7").empty();
         		sym.getSymbol("panel0").$("#gt8").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l161").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l162").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l163").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l164").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l165").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l166").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l167").empty();
         		sym.getSymbol("panel1").getSymbol("last16").$("l168").empty();
         		sym.getSymbol("panel1").getSymbol("quarters").$("qf1").empty();
         		sym.getSymbol("panel1").getSymbol("quarters").$("qf2").empty();
         		sym.getSymbol("panel1").getSymbol("quarters").$("qf3").empty();
         		sym.getSymbol("panel1").getSymbol("quarters").$("qf4").empty();
         		sym.getSymbol("panel1").getSymbol("semis").$("sf1").empty();
         		sym.getSymbol("panel1").getSymbol("semis").$("sf2").empty();		
         		sym.getSymbol("panel1").$("fn").empty();
         
         		}
         		var matchesRnd = parsedDate(fixtureData[i].d_Date);
         		var matchDay = fixtureData[i].n_PhaseID;
         		if ((matchDay>98255&&matchDay<98264)&&(((todayTime<startSeason)&&(i<8))||((todayTime>endGroupstage)&&(i>fixtureData.length-8))||((matchesRnd>todayTime-(oneDay*0.75))&&(matchesRnd<todayTime+(oneDay*14))))){
         		sym.getSymbol("panel0").$("matches").empty();
         
         		if (i%2 == 0){
                       var fixtureTxt = "<table width='100%' height='13px' style='font-size:12px;font-family:pragmatica-web, sans-serif; background:rgba(215,230,245,0.5);' id='match" + i + "'><tr><td width='45%' style='padding-left:3px' id='teamh" + i + "'></td><td width='10%' style='text-align:center' id='score" + i + "'></td><td width='45%' style='text-align:right' id ='teama" + i + "'></td></tr></table>";
         				}else{
                       var fixtureTxt = "<table width='100%' height='13px' style='font-size:12px;font-family:pragmatica-web, sans-serif;' id='match" + i + "'><tr><td width='45%' style='padding-left:3px' id='teamh" + i + "'></td><td width='10%' style='text-align:center' id='score" + i + "'></td><td width='45%' style='text-align:right' id ='teama" + i + "'></td></tr></table>";
         				}
         
         
         
         
         		} //closes if parsedate	
         
         
         
         		var tableTxt = "<table style='width:100%; font-size:12px;font-family:pragmatica-web, sans-serif; border-collapse:collapse; border-bottom:rgb(100,100,100); height:16px'><tr><td id='date" + i + "' style='width:20%; padding-left:5px'></td><td id='hometeam" + i + "' style='width:33%'></td><td style='width:10%'><span id ='groupscore" + i + "'></td><td id='awayteam" + i + "' style='width:33%; text-align:right;'></td><td id='result" + i + "' style='width:4%; text-align:right;'></td></tr></table>";
         		var stage16Txt = "<table style='width:190px; font-size:12px; font-family:pragmatica-web, sans-serif; border-bottom:thin; border-collapse:collapse;'><tr style='background-color:rgb(222,231,242)'><td style='width:24px' id='flagh"+ i +"'></td><td colspan='2' style='padding-left:5px' id='hometeam" + i + "'></td></tr><tr style='background-color:rgb(222,231,242)'><td style='width:24px' id='flaga"+ i +"'></td><td colspan='2' style='padding-left:5px' id='awayteam" + i + "'></td></tr></table>";   
         		var semiTxt = "<table style='width:390px; font-size:12px; font-family:pragmatica-web, sans-serif; border-bottom:thin; border-collapse:collapse;'><tr style='background-color:rgb(222,231,242)'><td style='width:24px' id='flagh"+ i +"'></td><td colspan='2' style='padding-left:5px; font-weight:bold' id='homeleg" + i + "'></td><td colspan='2' style='padding-right:5px; text-align:right; font-weight:bold' id='awayleg" + i + "'></td><td style='width:24px; text-align:right' id='flaga"+ i +"'></td></tr></table>";   
         		var stageTxt = "<table style='width:390px; font-size:12px; font-family:pragmatica-web, sans-serif; border-collapse:collapse;'><tr style='background-color:rgb(222,231,242)'><td colspan='4'><center id='date" + i + "'></td></tr><tr><td width='25%' rowspan='3' id='cresth"+ i +"' style-'text-align:left'></td><td colspan='2'><center id='hometeam" + i + "'></td><td  width='25%' rowspan='3' id='cresta"+ i +"' style-'text-align:right'></td></tr><tr><td colspan='2'><b><center id='score" + i + "'></b></td></tr><tr><td colspan='2'><center id='awayteam" + i + "'></td></tr><tr style='background-color:rgb(222,231,242)'><td colspan='2'><i><span id='stad" + i + "'></span</i></td><td colspan='2' style='text-align:right'><i><span id='ref" + i + "'></span></i></td></tr></table>";
         		var legTxt = "<table style='width:190px; font-size:11px; font-family:pragmatica-web, sans-serif; border-bottom:thin; border-collapse:collapse;' id='match"+i+"'><tr><td style='width:35%'><span id='date"+ i +"'></td><td style='width:15%'><span id='teamhshort" + i + "'></td><td style='width:30%'><center id='score" + i + "'></td><td style='width:15%'><span id='teamashort" + i + "'></td><td id='result" + i + "' style='width:5%; text-align:right;'></td></tr></table>";
                         switch (fixtureData[i].n_PhaseID) {
                             case 98256:
                                sym.getSymbol("panel0").$('#gt1').append(tableTxt);
                                 break;
                             case 98257:
                                 sym.getSymbol("panel0").$('#gt2').append(tableTxt);
                                 break;
                             case 98258:
                                 sym.getSymbol("panel0").$('#gt3').append(tableTxt);
                                 break;
                             case 98259:
                                 sym.getSymbol("panel0").$('#gt4').append(tableTxt);
                                 break;
                             case 98260:
                                 sym.getSymbol("panel0").$('#gt5').append(tableTxt);
                                 break;
                             case 98261:
                                 sym.getSymbol("panel0").$('#gt6').append(tableTxt);
                                 break;
                             case 98262:
                                 sym.getSymbol("panel0").$('#gt7').append(tableTxt);
                                 break;
                             case 98263:
                                 sym.getSymbol("panel0").$('#gt8').append(tableTxt);
                                 break;
         
                            case 98249:
         								if ((fixtureData[i].n_KnockoutPhaseID)==98296){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l161').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l161').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98301){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l162').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l162').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98300){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l163').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l163').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98298){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l164').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l164').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98297){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l165').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l165').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98302){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l166').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l166').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98295){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l167').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l167').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98299){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l168').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l168').append(legTxt);
         								}
         			//last16
         							break;
         
                            case 98250:
         								if ((fixtureData[i].n_KnockoutPhaseID)==98303){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("quarters").$('qf1').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("quarters").$('qf1').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98304){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("quarters").$('qf2').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("quarters").$('qf2').append(legTxt);
         
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98305){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("quarters").$('qf3').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("quarters").$('qf3').append(legTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98306){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("quarters").$('qf4').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("quarters").$('qf4').append(legTxt);
         								}
         			//quarters
         							break;
         
                          case 98251:
         								if ((fixtureData[i].n_KnockoutPhaseID)==98307){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("semis").$('sf1').append(semiTxt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("semis").$('sf1').append(tableTxt);
         								}
         								if ((fixtureData[i].n_KnockoutPhaseID)==98308){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("semis").$('sf2').append(semiTxt);										
         									}
         								sym.getSymbol("panel1").getSymbol("semis").$('sf2').append(tableTxt);
         								}
         			//semis
         							break;
         
         			case 98252:
         			//final
         			sym.getSymbol("panel1").$('fn').append(stageTxt);
         			break;
         
         		}
         
         
         					var pens;
         		sym.getSymbol("panel0").$("matches").append(fixtureTxt);                
                         $('#teamh' + i).text(fixtureData[i].c_HomeTeam);
                         $('#teama' + i).text(fixtureData[i].c_AwayTeam);
                         $('#teamhshort' + i).text(fixtureData[i].c_HomeTeamShort);
                         $('#teamashort' + i).text(fixtureData[i].c_AwayTeamShort);
                         if (fixtureData[i].n_HomeGoalsShootout!==null||undefined){
                         pens= '<i> (' + fixtureData[i].n_HomeGoalsShootout + '-' + fixtureData[i].n_AwayGoalsShootout + ')</i>';
                         }else{
                         pens='';
                         }
                         if (fixtureData[i].n_HomeGoals!==null||undefined){
                         $('#score' + i).html('<b>' + (fixtureData[i].n_HomeGoals)+ '-' +(fixtureData[i].n_AwayGoals) + '</b>' + pens);
                         }else{
                         $('#score' + i).html('');
                         }
         
         
         					 if (fixtureData[i].n_HomeGoals!==null||undefined){
         						$('#groupscore' + i).html('<b>' + (fixtureData[i].n_HomeGoals)+ '-' +(fixtureData[i].n_AwayGoals) + '</b>');
                         }else{
         						$('#groupscore' + i).html('');
                         }
                         $('#hometeam' + i).text(fixtureData[i].c_HomeTeam);
                         $('#awayteam' + i).text(fixtureData[i].c_AwayTeam);
                         $('#homeleg' + i).text(fixtureData[i].c_HomeTeam);
                         $('#awayleg' + i).text(fixtureData[i].c_AwayTeam);
                         $('#date' + i).text(getDDMMYY(fixtureData[i].d_Date));
         					 var stad;				
                         if ((fixtureData[i].c_Stadium)==null||undefined){
         						stad = "";
                         }else{
         						stad=(fixtureData[i].c_Stadium)+', '+(fixtureData[i].c_City);
                         }
                         $('#stad' + i).text(stad);
                         $('#city' + i).text(fixtureData[i].c_City);
                         $('#flagh' + i).html(imgH);
                         $('#flaga' + i).html(imgA);
                         if ((fixtureData[i].n_MatchStatusCode)>=128){
                         matchResult = '<img src="images/ball.png" height="13px" width="13px">';
                         }else{
                         matchResult = '';
                         }
                         $('#result'+i).html(matchResult);
         
                         if ((fixtureData[i].c_Referee)==null){
                         refName='';
                         }else{
                         refName=fixtureData[i].c_Referee+' '+(fixtureData[i].c_RefereeNatioShort);
                         }
                         $('#ref' + i).html(refName);
         
                         if ((fixtureData[i].n_HomeTeamID)<=0){
                         crestH='';
         
         					}else{
                         crestH='<img src="crests/'+(fixtureData[i].n_HomeTeamID) +'.png" height="55px" width="55px">';
                         }
                         $('#cresth' + i).html(crestH);
                         if ((fixtureData[i].n_AwayTeamID)<=0){
                         crestA='';
         					}else{
                         crestA='<img src="crests/'+(fixtureData[i].n_AwayTeamID) +'.png" height="55px" width="55px" align="right">';
                         }
                         $('#cresta' + i).html(crestA);
         
         
               var imgH = '<img src="flags/'+ fixtureData[i+1].c_HomeTeamNatioShort +'.png" height="12px" width="22px">';
         		var imgA = '<img src="flags/'+ fixtureData[i+1].c_AwayTeamNatioShort +'.png" height="12px" width="22px">';
         		var matchteam1=(fixtureData[i].c_HomeTeam);
         		var matchteam2=(fixtureData[i].c_AwayTeam);
         		var matchscore=(fixtureData[i].c_Score);
         		var matchID = fixtureData[i].n_MatchID; 
         
         
                             } //closes for                                   
                         } //closes success                                                    	           
                     }); //closes ajax
         }
         
         //DATE STUFF
         
                 function getDDMMYY(thisDateStr) {
                     var dateTxt = thisDateStr.substring(thisDateStr.indexOf('(') + 1, thisDateStr.indexOf(')'));
                     var thisDate = new Date(parseInt(dateTxt, 10));
                     var mm = thisDate.getMonth() + 1;
                     var dd = thisDate.getDate();
                     mm = ((mm < 10) ? '0' : "") + mm;
                     dd = ((dd < 10) ? '0' : "") + dd;
                     return dd + "/" + mm + "/" + (thisDate.getFullYear()).toString();
                 }
         
                  function parsedDate(thisDateStr){
         	var matchRndDate = thisDateStr.substring(thisDateStr.indexOf('(') + 1, thisDateStr.indexOf(')'));
         	var dDate = parseInt(matchRndDate,10);
         	return dDate;
         	}      
         
         	var startSeason= Date.parse("September 18, 2012");
         	var endGroupstage = Date.parse("December 5, 2012");
         	var endSeason = Date.parse("May 25, 2013");
         	var oneDay = 86400000;
         	var todayDate = new Date();
         	var todayTime = todayDate.getTime();
         
          //MORE LIVE DATA
                 var resultsData;
                 getGroupResults();
         	intervalId = setInterval(getGroupResults,600000);
         
                 function getDetails(groupIndex) {
                     var group = groupIndex - 1;
                     var id = 98256 + group;
         
                     $.ajax({ type: "GET", url: dataURL,
                         data: "gn=29739&phaseID=" + id,
                         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
                         async: true,
                         crossDomain: true,
                         error: function () {
                             alert("Error retrieving Group[" + groupIndex + "]");
                         },
                         success: function (groupDetails) {
                             loadDetails(groupDetails, group);
         //                    if (groupIndex == 8) {
         //                        loadGroupResults();
         //                    }
                         }
                     });
                 }
         
                 function loadDetails(groupDetails, group) {
                     var imgHTML;
         
                     for (var i = 0; i < 8; i++) {
                         $('#t' + group + 'n' + i).text(groupDetails[i].c_Team);
                         $('#t' + group + 'p' + i).text(groupDetails[i].n_Matches);
                         $('#t' + group + 'w' + i).text(groupDetails[i].n_MatchesWon);
                         $('#t' + group + 'd' + i).text(groupDetails[i].n_MatchesDrawn);
                         $('#t' + group + 'l' + i).text(groupDetails[i].n_MatchesLost);
                         $('#t' + group + 'f' + i).text(groupDetails[i].n_GoalsFor);
                         $('#t' + group + 'a' + i).text(groupDetails[i].n_GoalsAgainst);
                         $('#t' + group + 'pts' + i).text(groupDetails[i].n_Points);
                         imgHTML='<img src="flags/'+(groupDetails[i].c_TeamNatioShort) +'.png" height="12px" width="22px">';
                         $('#t' + group + 'flag' + i).html(imgHTML);
         
                         //teamLink='';
         
                     }
                 } 
         
                 function getGroupResults() {
                     $.ajax({ type: "GET", url: dataURL,
                         data: "gn=29739&editionID=19911",
                         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
                         async: true,
                         crossDomain: true,
                         success: function (data) {
                             resultsData = data;
         
                             for (var group = 1; group <= 8; group++) {
         		sym.getSymbol("panel0").$("grp"+group).empty();
         
         var tableTxt= "<div id='gt" + group + "' style='display:none; position:absolute; bottom:15px; width:100%'></div><table style='width:60%; position:absolute; right:0px; background-color:rgb(215,230,245); font-family:pragmatica-web, sans-serif; border:none; border-collapse:collapse; font-size:12px'><tr style='background-color:rgb(235,240,250);'><td width='13%'><center id='t" + (group - 1) + "p0'></center></td><td width='13%'><center id='t" + (group - 1) + "w0'></center></td><td width='13%'><center id='t" + (group - 1) + "d0'></center></td><td width='13%'><center id='t" + (group - 1) + "l0'></center></td><td width='14%'><center id='t" + (group - 1) + "f0'></center></td><td width='14%'><center id='t" + (group - 1) + "a0'></center></td><td width='20%'><center id='t" + (group - 1) + "pts0'></td></tr><tr style='background-color:rgb(235,240,250);'><td><center id='t" + (group - 1) + "p1'></center></td><td><center id='t" + (group - 1) + "w1'></center></td><td><center id='t" + (group - 1) + "d1'></center></td><td><center id='t" + (group - 1) + "l1'></center></td><td><center id='t" + (group - 1) + "f1'></center></td><td><center id='t" + (group - 1) + "a1'></center></td><td><center id='t" + (group - 1) + "pts1'></td></tr> <tr><td><center id='t" + (group - 1) + "p2'></center></td><td><center id='t" + (group - 1) + "w2'></center></td><td><center id='t" + (group - 1) + "d2'></center></td><td><center id='t" + (group - 1) + "l2'></center></td><td><center id='t" + (group - 1) + "f2'></center></td><td><center id='t" + (group - 1) + "a2'></center></td><td><center id='t" + (group - 1) + "pts2'></td></tr><tr><td><center id='t" + (group - 1) + "p3'></center></td><td><center id='t" + (group - 1) + "w3'></center></td><td><center id='t" + (group - 1) + "d3'></center></td><td><center id='t" + (group - 1) + "l3'></center></td><td><center id='t" + (group - 1) + "f3'></center></td><td><center id='t" + (group - 1) + "a3'></center></td><td><center id='t" + (group - 1) + "pts3'></td></tr></table><table style='position:absolute; top:0px; width:170px; background-color:rgb(215,230,245); border:none; border-collapse:collapse; font-family:pragmatica-web, sans-serif; font-size:12px'><tr style='background-color:rgb(235,240,250);'><td id='t" + (group - 1) + "flag0'></td><td><span id='t" + (group - 1) + "n0'></td></tr><tr style='background-color:rgb(235,240,250);'><td id='t" + (group - 1) + "flag1'></td><td><span id='t" + (group - 1) + "n1'></td></tr><tr><td id='t" + (group - 1) + "flag2'></td><td><span id='t" + (group - 1) + "n2'></td></tr><tr><td id='t" + (group - 1) + "flag3'></td><td style='width:150px'><span id='t" + (group - 1) + "n3'></td></tr></table>";  
         		    sym.getSymbol("panel0").$("grp"+group).append(tableTxt);
                                 getDetails(group);
                             } 
                        }
                     });
                 }
         
         getFixtures();
         intervalId = setInterval(getFixtures,60000);
         
         
         //BUTTONS
         
         var menu=0;
         	if (todayDate>endGroupstage){
         			sym.$("panel1").show();
         			sym.$("btn1Txt").css({'color':'rgb(0,156,178)','pointer-events':'none'});
         			sym.$("btn1").css('background-color', 'rgb(255,255,255)');
         			sym.$("panel0").hide();
         			sym.$("btn0Txt").css({'color':'rgb(255,255,255)','pointer-events':'none'});
         			sym.$("btn0").css('background-color', 'rgb(0,156,178)');
         	}
         for (var m=0; m<2; m++){
         sym.$("btn" + m).bind('click', doMenu);
         }
         function doMenu(){
         		var selected_id = $(this).attr("id");
         		for (var n=0; n<2; n++){
         			if (selected_id=="Stage_btn" + n){
         			sym.$("panel"+n).show();
         			sym.$("btn"+n+"Txt").css({'color':'rgb(0,156,178)','pointer-events':'none'});
         			sym.$("btn"+n).css('background-color', 'rgb(255,255,255)');
         			}else{	
         			sym.$("panel"+n).hide();
         			sym.$("btn"+n+"Txt").css({'color':'rgb(255,255,255)','pointer-events':'none'});
         			sym.$("btn" + n).css('background-color', 'rgb(0,156,178)');
         			}
         		}
         		if (menu==0){
         		menu=1;
         		}else{
         		menu=0;
         		}
         }
         
         
         var grpArray = ["grp1","grp2","grp3","grp4","grp5","grp6","grp7","grp8"];
         		for (var j=0; j<grpArray.length; j++){
         		sym.getSymbol("panel0").$(grpArray[j]).bind('click', doClick);
         		}
         		sym.getSymbol("panel0").$("fulltable").bind('click', doReset);
         		sym.getSymbol("panel1").$("zoomIn0").bind('click', function(){sym.getSymbol("panel1").play();});
         sym.getSymbol("panel1").$("back").bind('click', function(){sym.getSymbol("panel1").playReverse();});
         sym.getSymbol("panel1").$("forward").bind('click', function(){sym.getSymbol("panel1").play();});
         
         var moveLeft;
         var moveUp;		
         		function doClick() {
         			var selected_id = $(this).attr("id");
         			for (var i=0; i<8; i++){
         				if (i==2||i==3){
         				moveUp=-91;
         				}else if(i==4||i==5){
         				moveUp=-182;
         				}else if(i==6||i==7){
         				moveUp=-273;
         				}else{
         				moveUp=0;
         				}
         				if (i%2==0){
         				moveLeft=0;
         				}else{
         				moveLeft=-200;
         				}
         				if(selected_id == "Stage_panel0_grp" + (i+1)){
         				sym.getSymbol("panel0").$("grp" + (i+1)).animate({width:390, height:320, left:moveLeft, top:moveUp}, 800);
         				sym.getSymbol("panel0").$('#gt'+(i+1)).css("display","inherit");
         				}else{				
         				sym.getSymbol("panel0").$("grp" + (i+1)).hide();
         				sym.getSymbol("panel0").$('#gt'+(i+1)).css("display","none");
         				}
         			}
         			sym.getSymbol("panel0").$("fulltable").show(); 
         		}
         
         		function doReset() {
         			for (var i=0; i<8; i++){
         				moveUp=0;
         				moveLeft=0;
         				sym.getSymbol("panel0").$("grp" + (i+1)).show();
         				sym.getSymbol("panel0").$("grp" + (i+1)).animate({width:190, height:73, left:moveLeft, top:moveUp}, 400);
         				sym.getSymbol("panel0").$('#gt'+(i+1)).css("display","none");
         			}
         			sym.getSymbol("panel0").$("fulltable").hide(); 
         		}
         

      });
      //Edge binding end

      

      

   })("stage");
   //Edge symbol end:'stage'

//=========================================================
   //Edge symbol: 'panel01'
   (function(symbolName) {

      

      

      

   })("panel-0");
   //Edge symbol end:'panel-0'

//=========================================================
   //Edge symbol: 'panel02'
   (function(symbolName) {

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1097, function(sym, e) {
         sym.stop();
         var dates = sym.getVariable("dates3");
         sym.$("rnd3matches").html(dates);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 500, function(sym, e) {
         sym.stop();
         //get the value of a Symbol variable
         var dates = sym.getVariable("dates2");
         sym.$("rnd2matches").html(dates);

      });
      //Edge binding end

      

      

      

      

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1750, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

   })("panel-1");
   //Edge symbol end:'panel-1'

   //=========================================================
   
   //Edge symbol: 'table'
   (function(symbolName) {   
   
      

   })("table");
   //Edge symbol end:'table'

   //=========================================================
   
   //Edge symbol: 'last16'
   (function(symbolName) {   
   
   })("last16");
   //Edge symbol end:'last16'

   //=========================================================
   
   //Edge symbol: 'quarters'
   (function(symbolName) {   
   
   })("quarters");
   //Edge symbol end:'quarters'

   //=========================================================
   
   //Edge symbol: 'semis'
   (function(symbolName) {   
   
   })("semis");
   //Edge symbol end:'semis'

})(jQuery, AdobeEdge, "GRAPHICNEWS-29739");