/***********************
* 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 teamsArr=["2","4004","4007","4012","4014","4015","4017","4019","4025","4032","4034","4038","4048","4054","4067","4080","4094","4103","4104","4112","4124","4209","4222","4226","4234","4239","4291","4452","4570","4771","4959","4991"];
         var dataURL = ('http:'==document.location.protocol?"http://www2.graphicnews.com/":"https://www.graphicnews.org/")+ "infostradasports/api.php";
         var startSeason= Date.parse("September 17, 2013");
         var endGroupstage = Date.parse("December 14, 2013");
         var endRnd2 = Date.parse("March 21, 2014");
         var endSemis = Date.parse("April 28, 2014");
         var endSeason = Date.parse("May 24, 2014");
         var oneDay = 86400000;
         var todayDate = new Date();
         var todayTime = todayDate.getTime();
         var headline;
         var sources;
         var latest;
         // Group stage text captions
         var tabletxt=[];
         tabletxt[0] = sym.getSymbol("panel0").getSymbol("fulltable").$("table1Txt");
         tabletxt[1] = sym.getSymbol("panel0").getSymbol("fulltable").$("table2Txt");
         tabletxt[2] = sym.getSymbol("panel0").getSymbol("fulltable").$("table3Txt");
         tabletxt[3] = sym.getSymbol("panel0").getSymbol("fulltable").$("table4Txt");
         tabletxt[4] = sym.getSymbol("panel0").getSymbol("fulltable").$("table5Txt");
         tabletxt[5] = sym.getSymbol("panel0").getSymbol("fulltable").$("table6Txt");
         tabletxt[6] = sym.getSymbol("panel0").getSymbol("fulltable").$("table7Txt");
         tabletxt[7] = sym.getSymbol("panel0").$("matches");
         tabletxt[8] = sym.getSymbol("panel0").$("table9Txt");
         tabletxt[9] = sym.getSymbol("panel0").$("table10Txt");
         var tableArr=[];
         var team1;
         var team2;
         var score;
         var match;
         var cap1;
         var cap2;
         var cap3;
         var btn0txt = sym.getSymbol("btn0").$("btn0Txt");
         var btn1txt = sym.getSymbol("btn1").$("btn1Txt");
         var phasetxt=[];
         phasetxt[0]=sym.getSymbol("panel0").$("grp1Txt");
         phasetxt[1]=sym.getSymbol("panel0").$("grp2Txt");
         phasetxt[2]=sym.getSymbol("panel0").$("grp3Txt");
         phasetxt[3]=sym.getSymbol("panel0").$("grp4Txt");
         phasetxt[4]=sym.getSymbol("panel0").$("grp5Txt");
         phasetxt[5]=sym.getSymbol("panel0").$("grp6Txt");
         phasetxt[6]=sym.getSymbol("panel0").$("grp7Txt");
         phasetxt[7]=sym.getSymbol("panel0").$("grp8Txt");
         phasetxt[8]=sym.getSymbol("panel1").$("rnd2Txt");
         phasetxt[9]=sym.getSymbol("panel1").$("qfTxt");
         phasetxt[10]=sym.getSymbol("panel1").$("sfTxt");
         phasetxt[11]=sym.getSymbol("panel1").$("fnlTxt");
         var phaseArr=[];
         var btn0;
         var btn1;
         var btn2;
         var dates1;
         var dates2;
         var dates3;
         var monthstring;
         var months;
         var matchtxt=[];
         matchtxt[0]= sym.getSymbol("matchtracker").$("tabBtn1");
         matchtxt[1]= sym.getSymbol("matchtracker").$("tabBtn2");
         matchtxt[2]= sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("timeline").$("koTxt");
         matchtxt[3]= sym.getSymbol("matchtracker").getSymbol("teams").$("cap1Txt");
         matchtxt[4]= sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").$("pensTxt");
         matchtxt[5]= sym.getSymbol("matchtracker").getSymbol("teams").$("cap2Txt");
         var matchArr=[];
         
         var squadtxt=[];
         squadtxt[0] = sym.getSymbol("panel2").$("squadTxt0");
         squadtxt[1] = sym.getSymbol("panel2").$("squadTxt1");
         squadtxt[2] = sym.getSymbol("panel2").$("squadTxt2");
         squadtxt[3] = sym.getSymbol("panel2").$("squadTxt3");
         var squadTxtArr=[];
         
         var squadNotes=[];
         var squadApps=[];
         var positionstxt;
         var positionArr;
         
         var d=new Date();
         
         //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
         $.ajax({	
         	type: "GET",
         	url: "GN30764.xml",
         	dataType: "xml",
         	success: function(xml) {
         		headline = $(xml).find('headline').text();
         		sym.$("headlineTxt").html(headline);				
         		sources = $(xml).find('sources').text();
         		sym.$("sourcesTxt").html(sources);
         		monthstring = $(xml).find('months').text();
         		months=monthstring.split(",");
         
         		for (var t=0; t<9; t++){
         		tableArr[t]= $(xml).find('table'+t).text();
         		tabletxt[t].html(tableArr[t]);
         		}
         		tabletxt[9].html(tableArr[8]);
         		for (var p=0; p<12; p++){
         		phaseArr[p]= $(xml).find('grp'+p).text();
         		phasetxt[p].html(phaseArr[p]);
         		//phasetxt[p].css("pointer-events","none");
         		}
         		phaseArr[12]= $(xml).find('grp12').text();
         		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);
         		btn2 = $(xml).find('btn2').text();
         
         		for (var m=0; m<5; m++){
         		matchArr[m]= $(xml).find('match'+m).text();
         		matchtxt[m].html(matchArr[m]);
         		}
         		matchtxt[5].html(matchArr[3]);
         
         		for (var s=0; s<4; s++){
         			squadTxtArr[s]=  $(xml).find('squad'+s).text();
         			squadtxt[s].html(squadTxtArr[s]);
         		}
         		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);
         
         		positionstxt = $(xml).find('positions').text();
         		positionArr = positionstxt.split(",");
         			for (var i=0;i<32;i++){
         				squadNotes[i]= $(xml).find('note'+i).text();
         				squadApps[i]= $(xml).find('apps'+i).text();
         			}
         		}
         	});
         
         function getSquadCaptions(teamId){
         			for (var i=0;i<32;i++){
         				if (teamId==teamsArr[i]){
         				sym.getSymbol('panel2').$('dynTxt0').html(squadNotes[i]);
         				sym.getSymbol('panel2').$('dynTxt1').html(squadApps[i]);
         				}
         			}
         }
         if (todayTime<endSemis){
         		sym.getSymbol("panel1").$("fn").css("pointer-events","none");
         }
         if (todayTime<=endRnd2){
         		sym.getSymbol("panel1").$("quarters").css("pointer-events","none");
         		sym.getSymbol("panel1").$("semis").css("pointer-events","none");
         }
         if (todayTime<=endGroupstage){
         		sym.getSymbol("panel1").$("last16").css("pointer-events","none");
         }
         
         //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 getDDmonthYY(thisDateStr) {
         	var dateTxt = thisDateStr.substring(thisDateStr.indexOf('(') + 1, thisDateStr.indexOf(')'));
         	var thisDate = new Date(parseInt(dateTxt, 10));
         	var mm = thisDate.getMonth();
         	var dd = thisDate.getDate();
         	return months[mm] + " " + dd +", "+ (thisDate.getFullYear()).toString();
         }
         
         function parsedDate(thisDateStr){
         	var matchRndDate = thisDateStr.substring(thisDateStr.indexOf('(') + 1, thisDateStr.indexOf(')'));
         	var dDate = parseInt(matchRndDate,10);
         	return dDate;
         }      
         
         //LIVE DATA
         var matchInterval;
         var teamInterval;
         var playInterval;
         var showMatch = function(match){ //to handle lexical scope
         	return function (e) {
         		getMatchInfo(match);
         		getMatch(match);
         		getTeams(match);
         		sym.$("matchtracker").fadeIn(400);
         		sym.$("panel0").fadeOut(400);
         		sym.$("panel1").fadeOut(400);
         		sym.$("panel2").fadeOut(400);
         		sym.$("cup").fadeOut(400);
         		matchInterval = setInterval(function() { getMatchInfo(match); }, 60000);
         		teamInterval = setInterval(function() { getTeams(match); }, 60000);
         		playInterval = setInterval(function() { getMatch(match); }, 60000);
         		for (var i=0; i<2; i++){
         			sym.getSymbol("btn"+i).$("btn"+i+"Txt").css({'color':'rgba(255,255,255,1.0)','pointer-events':'none'});
         			sym.getSymbol("btn"+i).$("btnbg").css({'background-color':'rgba(0,156,178,0.5)', 'width':'198px'});
         		}
         		sym.getSymbol("btn1").$('btnbg').css({'width':'200px'});
         		e.preventDefault();
         		e.stopPropagation();
         
         	};
         };
         
         var showSquad = function(team,teamname,nat){ //to handle lexical scope
         	return function (e) {
         		sym.getSymbol('panel2').$('squad').empty();
         		sym.getSymbol('panel2').$('teamnameTxt').html(teamname);
         		sym.getSymbol('panel2').$('countryTxt').html(nat);
         		sym.getSymbol('panel2').$('teampic').attr('src','squads/'+team+'.jpg');
         		sym.getSymbol('panel2').$('home').attr('src','squads/'+team+'_h.png');
         		sym.getSymbol('panel2').$('away').attr('src','squads/'+team+'_a.png');
         		sym.getSymbol('panel2').$('crest').attr('src','crests/'+team+'.png');
         		sym.getSymbol('panel2').$('teamflag').attr('src','flags/'+nat+'.jpg');
         		getSquadCaptions(team);
         		getSquad(team);
         		sym.$("panel2").fadeIn(400);
         		sym.$("matchtracker").fadeOut(400);
         		sym.$("panel0").fadeOut(400);
         		sym.$("panel1").fadeOut(400);
         		sym.$("cup").fadeOut(400);
         		for (var i=0; i<2; i++){
         			sym.getSymbol("btn"+i).$("btn"+i+"Txt").css({'color':'rgba(255,255,255,1.0)','pointer-events':'none'});
         			sym.getSymbol("btn"+i).$("btnbg").css({'background-color':'rgba(0,156,178,0.5)', 'width':'198px'});
         		}
         		sym.getSymbol("btn1").$('btnbg').css({'width':'200px'});
         		e.preventDefault();
         		e.stopPropagation();
         	};
         };
         var squadData;
         function getSquad(team){
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&squad="+team,
         		contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         		async: true,
         		crossDomain: true,
         		success: function (data) {
         			squadData=data;
         			for (var i = 0; i <squadData.length; i++) {
         				var shirtNr = squadData[i].n_ShirtNr;
         				var player = squadData[i].c_Person;
         				var nation = squadData[i].c_PersonNatioShort;
         				var position = squadData[i].n_FunctionCode;
         				var ycards = squadData[i].n_CardsYellow;
         				var rcards = squadData[i].n_CardsRed;
         				var goals = squadData[i].n_Goals;
         				var matches = squadData[i].n_MatchesStart;
         				var minutes = squadData[i].n_MinutesPlayed;
         					if (position>0&&position<16){
         						var squadlist = "<div id='player"+i+"'>";
         						squadlist += "<div class='squadCol1' id='sqdshirt"+i+"'></div>";
         						squadlist += "<div class='squadCol2'><span id='sqdplayerName"+i+"'></span>";
         						squadlist += "<span id='sqdnation"+i+"'></span></div>";
         						squadlist += "<div class='squadCol3' id='sqdapps"+i+"'></div>";
         						squadlist += "<div class='squadCol4' id='sqdgls"+i+"'></div>";
         						squadlist += "<div class='squadCol5' id='sqdmins"+i+"'></div>";
         						squadlist += "<div class='squadCol6' id='sqdpos"+i+"'></div>";
         						squadlist += "</div><div class='playerdetails'></div>";
         					}
         					sym.getSymbol('panel2').$('squad').append(squadlist);
         					$('#player'+i).css({'width':'98%','font-size':'12px','font-family':'pragmatica-web, sans-serif', 'display':'inline-table'});
         					$('.squadCol1').css({'width':'5%', 'color':'rgb(0,156,178)','padding-left':'1%', 'text-align':'right','display':'table-cell'});
         					$('.squadCol2').css({'width':'46%', 'padding-left':'3%','display':'table-cell'});
         					$('#sqdplayerName'+i).css({'font-weight':700});
         					$('.squadCol3').css({'width':'8%', 'display':'table-cell', 'text-align':'center'});
         					$('.squadCol4').css({'width':'8%', 'display':'table-cell', 'text-align':'center'});
         					$('.squadCol5').css({'width':'8%', 'display':'table-cell', 'text-align':'center'});
         					$('#sqdnation'+i).css({'padding-left':'3px','font-style':'oblique'});
         					$('.squadCol6').css({'width':'20%', 'color':'rgb(0,156,178)','font-style':'oblique','text-align':'right', 'padding-right':'1%','display':'table-cell'});
         					$('#sqdshirt'+i).text(shirtNr);
         					$('#sqdplayerName'+i).text(player);
         					$('#sqdnation'+i).text(nation);
         					$('#sqdapps'+i).text(matches);
         					$('#sqdmins'+i).text(minutes);
         					$('#sqdgls'+i).text(goals);
         					var tactical;
         					if (position==1){
         						tactical=positionArr[0];
         					}else if(position==2){
         						tactical=positionArr[1];
         					}else if(position==4){
         						tactical=positionArr[2];
         					}else if(position==8){
         						tactical=positionArr[3];
         					}
         					$('#sqdpos'+i).text(tactical);				
         				}
         			}
         		});
         }
         
         var fixtureData;   
         function getFixtures() { 
          $.ajax({ type: "GET", url: dataURL,
                         data: "gn=30764&yr=2013&editionID=20605",
                         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
                         async: true,
                         crossDomain: true,
                         success: function (data) {
                              fixtureData = data;
               $("#gt1").empty();
         		$("#gt2").empty();
         		$("#gt3").empty();
         		$("#gt4").empty();
         		$("#gt5").empty();
         		$("#gt6").empty();
         		$("#gt7").empty();
         		$("#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();
         		sym.getSymbol("panel0").$("matches").empty();
               for (var i = 0; i < fixtureData.length; i++) {
         		var matchesRnd = parsedDate(fixtureData[i].d_Date);
         		var matchDay = fixtureData[i].n_PhaseID;
         		var phaseLevel = fixtureData[i].n_PhaseLevel;
         
         		if ((phaseLevel==17)&&(((todayTime<startSeason)&&(i>87))||((todayTime>endGroupstage)&&(i>fixtureData.length-8))||((matchesRnd>todayTime-(oneDay*0.75))&&(matchesRnd<todayTime+(oneDay*14))))){
         		if (i%2 == 0){
         					var fixtureTxt = "<table class='fixtxt even' id='matchf" + i + "'>";
         				}else{
         					var fixtureTxt = "<table class='fixtxt' id='matchf" + i + "'>";
         				}
         		fixtureTxt += "<tr><td width='45%' style='padding-left:3px' id='teamh" + i + "'></td>";
         		fixtureTxt += "<td width='10%' style='text-align:center' id='score" + i + "'></td>";
         		fixtureTxt += "<td width='45%' style='text-align:right' id ='teama" + i + "'></td>";
         		fixtureTxt += "</tr></table>";
         		btn0txt.html(btn0+btn2);
         		} //closes if parsedate	
         
         		var tableTxt = "<table class='fixt grp font12' id='match"+i+"'><tr>";
         		tableTxt +="<td id='grpcresth" + i + "' style='width:5%'></td>";
         		tableTxt +="<td id='hometeam" + i + "' style='width:33%'></td>";
         		tableTxt +="<td style='width:20%; text-align:center'><span id ='groupscore" + i + "'></td>";
         		tableTxt +="<td id='awayteam" + i + "' style='width:33%; text-align:right;'></td>";
         		tableTxt +="<td id='grpcresta" + i + "' style='width:5%'></td>";
         		tableTxt +="<td id='result" + i + "' style='width:4%; text-align:right;'></td></tr></table>";
         
         		var stage16Txt = "<table class='fixt leg font12'><tr style='background-color:rgb(222,231,242); height:20px'>";
         		stage16Txt += "<td style='width:24px' id='cresth16"+ i +"'></td><td colspan='2' style='padding-left:5px' id='hometeam" + i + "'></td></tr>";
         		stage16Txt += "<tr style='background-color:rgb(222,231,242); height:20px'><td style='width:24px' id='cresta16"+ i +"'></td>";
         		stage16Txt += "<td colspan='2' style='padding-left:5px' id='awayteam" + i + "'></td></tr></table>"; 
         
         		var semiTxt = "<table class='fixt stage semi font14'><tr>";
         		semiTxt += "<td rowspan='3' style='width:55px' id='cresth"+ i +"'></td><td colspan='2'></td>";
         		semiTxt += "<td rowspan='3' style='width:55px; text-align:right' id='cresta"+ i +"'></td></tr>"; 
         		semiTxt += "<tr><td style='width:150px; padding-left:5px; font-weight:bold' id='homeleg" + i + "'></td>"
         		semiTxt += "<td style='width:150px; padding-right:5px; text-align:right; font-weight:bold' id='awayleg" + i + "'></td></tr>";
         		semiTxt += "<tr><td colspan='2'></td></table>";
         
         		var stageTxt = "<table style='font-size:12px; font-family:pragmatica-web, sans-serif; border-collapse:collapse; width:390px' id='match"+i+"'>";
         		stageTxt += "<tr style='background-color:rgb(222,231,242)'>";
         		stageTxt += "<td colspan='4'><center id='date" + i + "'></td></tr>";
         		stageTxt += "<tr><td width='25%' rowspan='3' id='cresth"+ i +"' style='text-align:left'></td>";
         		stageTxt += "<td colspan='2'><center id='hometeam" + i + "'></td>";
         		stageTxt += "<td  width='25%' rowspan='3' id='cresta"+ i +"' style='text-align:right'></td></tr>";
         		stageTxt += "<tr><td colspan='2'><b><center id='score" + i + "'></b></td></tr>";
         		stageTxt += "<tr><td colspan='2'><center id='awayteam" + i + "'></td></tr>";
         		stageTxt += "<tr style='background-color:rgb(222,231,242)'><td colspan='2'><i><span id='stad" + i + "'></span</i></td>";
         		stageTxt += "<td colspan='2' style='text-align:right'><i><span id='ref" + i + "'></span></i></td></tr></table>";
         
         		var legTxt = "<table class='fixt leg font11' id='match"+i+"'><tr>";
         		legTxt += "<td style='width:35%'><span id='teamhshort" + i + "'></td>";
         		legTxt += "<td style='width:25%'><center id='score16" + i + "'></td>";
         		legTxt += "<td style='width:35%; text-align:right;'><span id='teamashort" + i + "'></td>";
         		legTxt += "<td id='result" + i + "' style='width:5%; text-align:right;'></td></tr></table>";
         
                         $('.fixt').css({'font-family':'pragmatica-web, sans-serif','border-collapse':'collapse'});
                         $('.grp').css({'width':'100%','height':'16px','line-height':'11px','border-bottom':'solid 1px rgb(235,240,250)'});
                         $('.leg').css({'width':'190px','border-bottom':'thin'});
                         $('.stage').css({'width':'390px'});
                         $('.semi').css({'background-color':'rgb(222,231,242)','border-bottom':'thin'});
                         $('.font14').css({'font-size':'14px'});
                         $('.font12').css({'font-size':'12px'});
                         $('.font11').css({'font-size':'11px'});
                         switch (fixtureData[i].n_PhaseID) {
                             case 103954:
                                sym.getSymbol("panel0").$('#gt1').append(tableTxt);
                                 break;
                             case 103955:
                                 sym.getSymbol("panel0").$('#gt2').append(tableTxt);
                                 break;
                             case 103956:
                                 sym.getSymbol("panel0").$('#gt3').append(tableTxt);
                                 break;
                             case 103957:
                                 sym.getSymbol("panel0").$('#gt4').append(tableTxt);
                                 break;
                             case 103958:
                                 sym.getSymbol("panel0").$('#gt5').append(tableTxt);
                                 break;
                             case 103959:
                                 sym.getSymbol("panel0").$('#gt6').append(tableTxt);
                                 break;
                             case 103960:
                                 sym.getSymbol("panel0").$('#gt7').append(tableTxt);
                                 break;
                             case 103961:
                                 sym.getSymbol("panel0").$('#gt8').append(tableTxt);
                                 break;
         
                            case 103947: 			//last16
         								if ((fixtureData[i].n_KnockoutPhaseID)==103992){
         									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)==103993){
         									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)==103994){
         									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)==103995){
         									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)==103996){
         									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)==103997){
         									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)==103998){
         									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)==103999){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("last16").$('l168').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("last16").$('l168').append(legTxt);
         								}
         							break;
         
                            case 103948: 			//quarters
         								if ((fixtureData[i].n_KnockoutPhaseID)==104000){
         									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)==104001){
         									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)==104002){
         									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)==104003){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("quarters").$('qf4').append(stage16Txt);										
         									}
                                 sym.getSymbol("panel1").getSymbol("quarters").$('qf4').append(legTxt);
         								}
         							break;
                          case 103949://semis
         								if ((fixtureData[i].n_KnockoutPhaseID)==104004){
         									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)==104005){
         									if ((fixtureData[i].n_Leg)==1){
         										 sym.getSymbol("panel1").getSymbol("semis").$('sf2').append(semiTxt);										
         									}
         								sym.getSymbol("panel1").getSymbol("semis").$('sf2').append(tableTxt);
         								}
         							break;
         			case 103950: //final
         			sym.getSymbol("panel1").$('fn').append(stageTxt);
         			break;
         		}
         		sym.getSymbol("panel0").$("matches").append(fixtureTxt);                
         					var matchID = fixtureData[i].n_MatchID; 
         					var pens;
         					$('.fixtxt').css({'width':'100%','height':'15px','font-size':'12px','font-family':'pragmatica-web, sans-serif','line-height':'13px'});
         					$('.even').css({'background-color':'rgba(215,230,245,0.5)'});
         					$("#match"+i).css({'cursor':'pointer'});
         					$("#match"+i).on('click',showMatch(matchID));
         					$("#match"+i).on('mouseover',function(){ $(this).css({'font-weight':700,'background-color':'rgb(235,240,250)'});});
         					$("#match"+i).on('mouseout',function(){ $(this).css({'font-weight':400,'background-color':'rgb(255,255,255)'});});
         					$("#matchf"+i).css({'cursor':'pointer'});
         					$("#matchf"+i).on('click',showMatch(matchID));
         					$("#matchf"+i).on('mouseover',function(){ $(this).css({'font-weight':700});});
         					$("#matchf"+i).on('mouseout',function(){ $(this).css({'font-weight':400});});
                         $('#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);
         						 $('#score' + i).css({'font-size':'11px','padding':0,'background-color':'rgb(100,100,100)','color':'rgb(255,255,255)','border-bottom':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(150,150,150)','border-top':'solid 1px rgb(200,200,200)'});
         						 $('#score16' + i).html('<b>' + (fixtureData[i].n_HomeGoals)+ '-' +(fixtureData[i].n_AwayGoals) + '</b>' + pens);
         						 $('#score16' + i).css({'background-color':'rgb(100,100,100)','color':'rgb(255,255,255)','border-bottom':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(150,150,150)','border-top':'solid 1px rgb(200,200,200)'});
         						 $('#groupscore' + i).html('<b>' + (fixtureData[i].n_HomeGoals)+ '-' +(fixtureData[i].n_AwayGoals) + '</b>' + pens);
         						 $('#groupscore' + i).css({'background-color':'rgb(100,100,100)','color':'rgb(255,255,255)','border-bottom':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(150,150,150)','border-top':'solid 1px rgb(200,200,200)'});
                         }else{
         						 $('#score' + i).html('');
         						 //$('#score' + i).css({'background-color':'rgb(255,255,255)','font-size':'11px','padding':'0 2px','border-top':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(150,150,150)','border-bottom':'solid 1px rgb(200,200,200)'});
         						 $('#score16' + i).html('<i>' + getDDMMYY(fixtureData[i].d_Date) + '</i>');
         						 $('#score16' + i).css({'background-color':'rgb(255,255,255)','font-size':'11px','padding':'0 2px','border-top':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(150,150,150)','border-bottom':'solid 1px rgb(200,200,200)'});
         						 $('#groupscore' + i).html('<i>' + getDDMMYY(fixtureData[i].d_Date) + '</i>');
         						 $('#groupscore' + i).css({'background-color':'rgb(255,255,255)','font-size':'11px','padding':'0 2px','border-top':'solid 1px rgb(0,0,0)','border-left':'solid 1px rgb(0,0,0)','border-right':'solid 1px rgb(150,150,150)','border-bottom':'solid 1px rgb(200,200,200)'});
                         }
         
                         $('#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>4)&&(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='<img src="crests/null.png" height="55px" width="55px">';
                         grpcrestH='<img src="crests/null.png" height="15px" width="15px">';
                         crestHsemi='<img src="crests/null.png" height="20px" width="20px">';
                          $('#hometeam' + i).html(phaseArr[12]);
         					}else{
         					 $('#hometeam' + i).text(fixtureData[i].c_HomeTeam);
         					$('#hometeam' + i).on('click',showSquad(fixtureData[i].n_HomeTeamID,fixtureData[i].c_HomeTeam,fixtureData[i].c_HomeTeamNatioShort));
         					$('#hometeam' + i).css({'cursor':'pointer'});
         					$('#hometeam' + i).on('mouseover',function(){$(this).css({'color':'rgb(0,156,178)'});});
         					$('#hometeam' + i).on('mouseout',function(){ $(this).css({'color':'rgb(0,0,0)'});});
         					$('#homeleg' + i).on('click',showSquad(fixtureData[i].n_HomeTeamID,fixtureData[i].c_HomeTeam,fixtureData[i].c_HomeTeamNatioShort));
         					$('#homeleg' + i).css({'cursor':'pointer'});
         					$('#homeleg' + i).on('mouseover',function(){$(this).css({'color':'rgb(0,156,178)'});});
         					$('#homeleg' + i).on('mouseout',function(){ $(this).css({'color':'rgb(0,0,0)'});});
                         crestH='<img src="crests/'+(fixtureData[i].n_HomeTeamID) +'.png" height="55px" width="55px">';
                         grpcrestH='<img src="crests/'+(fixtureData[i].n_HomeTeamID) +'.png" height="15px" width="15px">';
                         crestHsemi='<img src="crests/'+(fixtureData[i].n_HomeTeamID) +'.png" height="20px" width="20px">';
         					}
                         $('#cresth' + i).html(crestH);
                         $('#grpcresth' + i).html(grpcrestH);
                         $('#cresth16' + i).html(grpcrestH);
                         $('#cresthsemi' + i).html(crestHsemi);                                                
                         if ((fixtureData[i].n_AwayTeamID)<=0){
                         crestA='<img src="crests/null.png" height="55px" width="55px" align="right">';
                         grpcrestA='<img src="crests/null.png" height="15px" width="15px">';
                         crestAsemi='<img src="crests/null.png" height="20px" width="20px">';
         					}else{
                         $('#awayteam' + i).text(fixtureData[i].c_AwayTeam);					
         					$('#awayteam' + i).on('click',showSquad(fixtureData[i].n_AwayTeamID,fixtureData[i].c_AwayTeam,fixtureData[i].c_AwayTeamNatioShort));
         					$('#awayteam' + i).css({'cursor':'pointer'});
         					$('#awayteam' + i).on('mouseover',function(){$(this).css({'color':'rgb(0,156,178)'});});
         					$('#awayteam' + i).on('mouseout',function(){ $(this).css({'color':'rgb(0,0,0)'});});
         					$('#awayleg' + i).on('click',showSquad(fixtureData[i].n_AwayTeamID,fixtureData[i].c_AwayTeam,fixtureData[i].c_AwayTeamNatioShort));
         					$('#awayleg' + i).css({'cursor':'pointer'});
         					$('#awayleg' + i).on('mouseover',function(){$(this).css({'color':'rgb(0,156,178)'});});
         					$('#awayleg' + i).on('mouseout',function(){ $(this).css({'color':'rgb(0,0,0)'});});
                         crestA='<img src="crests/'+(fixtureData[i].n_AwayTeamID) +'.png" height="55px" width="55px" align="right">';
                         grpcrestA='<img src="crests/'+(fixtureData[i].n_AwayTeamID) +'.png" height="15px" width="15px">';
                         crestAsemi='<img src="crests/'+(fixtureData[i].n_AwayTeamID) +'.png" height="20px" width="20px" align="right">';
                         }
                         $('#cresta' + i).html(crestA);
                         $('#grpcresta' + i).html(grpcrestA);
                         $('#cresta16' + i).html(grpcrestA); 
                         $('#crestasemi' + i).html(crestAsemi);                                
               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">';
                             } //closes for                                   
                         } //closes success                                                    	           
                     }); //closes ajax
         }
         
         //MORE LIVE DATA
         var resultsData;
         getGroupResults();
         intervalId = setInterval(getGroupResults,600000);
         
         function getDetails(groupIndex) {
         	var group = groupIndex - 1;
         	var id = 103954 + group;
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&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);
         		}
         	});
         }
         
         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);
         		$('#t' + group + 'n' + i).on('click',showSquad(groupDetails[i].n_TeamID,groupDetails[i].c_Team,groupDetails[i].c_TeamNatioShort));
         		$('#t' + group + 'n' + i).css({'cursor':'pointer'});
         		$('#t' + group + 'n' + i).on('mouseover',function(){$(this).css({'color':'rgb(0,156,178)'});});
         		$('#t' + group + 'n' + i).on('mouseout',function(){ $(this).css({'color':'rgb(0,0,0)'});});
         		$('#t' + group + 'flag' + i).on('click',showSquad(groupDetails[i].n_TeamID,groupDetails[i].c_Team,groupDetails[i].c_TeamNatioShort));
         		$('#t' + group + 'flag' + i).css({'cursor':'pointer'});
         	}
         } 
         
         function getGroupResults() {
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&editionID=20605",
         		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:3px; width:100%'></div>";  
         //				tableTxt += "<table style='width:60%; position:absolute; right:0; background-color:rgb(215,230,245); font-family:pragmatica-web, sans-serif; border:none; border-collapse:collapse; font-size:12px'>";
         				tableTxt += "<table style='width:60%; position:left; margin-left:40%; background-color:rgb(215,230,245); font-family:pragmatica-web, sans-serif; border:none; border-collapse:collapse; font-size:12px'>";
         				tableTxt += "<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>";
         				tableTxt +="<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>";
         				tableTxt += "<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>";
         				tableTxt += "<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>";
         				tableTxt += "<table style='position:absolute; top:0px; width:165px; background-color:rgb(215,230,245); border:none; border-collapse:collapse; font-family:pragmatica-web, sans-serif; font-size:12px'>";
         				tableTxt += "<tr style='background-color:rgb(235,240,250);'><td id='t" + (group - 1) + "flag0'></td><td><span id='t" + (group - 1) + "n0'></td></tr>";
         				tableTxt += "<tr style='background-color:rgb(235,240,250);'><td id='t" + (group - 1) + "flag1'></td><td><span id='t" + (group - 1) + "n1'></td></tr>";
         				tableTxt += "<tr><td id='t" + (group - 1) + "flag2'></td><td><span id='t" + (group - 1) + "n2'></td></tr>";
         				tableTxt += "<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.getSymbol("btn1").$("btn1Txt").css({'color':'rgb(0,156,178)','pointer-events':'none'});
         			sym.getSymbol("btn1").$("btnbg").css('background-color', 'rgb(255,255,255)');
         			sym.$("panel0").hide();
         			sym.getSymbol("btn0").$("btn0Txt").css({'color':'rgb(255,255,255)','pointer-events':'none'});
         			sym.getSymbol("btn0").$("btnbg").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).fadeIn(200);
         			sym.getSymbol("btn"+n).$("btn"+n+"Txt").css({'color':'rgb(0,156,178)','pointer-events':'none'});
         			sym.getSymbol("btn"+n).$("btnbg").css({'background-color':'rgb(255,255,255)','width':'200px','border':'none'});
         			}else{	
         			sym.$("panel"+n).fadeOut(200);
         			sym.getSymbol("btn"+n).$("btn"+n+"Txt").css({'color':'rgb(255,255,255)','pointer-events':'none'});
         			sym.getSymbol("btn"+n).$("btnbg").css({'background-color':'rgb(0,156,178)','width':'200px','border':'none'});
         			}
         		}
         		if (menu==0){
         		menu=1;
         		}else{
         		menu=0;
         		}
         		//doReset(); //Reset group tables
         		sym.$("cup").fadeIn(200);
         		sym.$('matchtracker').fadeOut(200);
         		sym.$("panel2").fadeOut(200);
         		clearInterval(matchInterval);
         		clearInterval(teamInterval);
         		clearInterval(playInterval);
         }
         
         var grpArray = ["grp1","grp2","grp3","grp4","grp5","grp6","grp7","grp8"];
         function bindGrps(){
         		for (var j=0; j<grpArray.length; j++){
         		sym.getSymbol("panel0").$(grpArray[j]).bind('click', doClick);
         		sym.getSymbol("panel0").$(grpArray[j]).css({'cursor':'pointer'});
         		sym.getSymbol("panel0").$(grpArray[j]+'Txt').bind('click', doClick);
         		sym.getSymbol("panel0").$(grpArray[j]+'Txt').css({'cursor':'pointer'});
         		}
         }
         bindGrps();
         sym.getSymbol("panel0").getSymbol("fulltable").$("close").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(){ 
         	var timelinePos=sym.getSymbol('panel1').getPosition();
         	if (todayTime<endSemis){
         		sym.getSymbol("panel1").play();
         	}else{
         		if(timelinePos==1097){//link straight to matchtracker
         				//showMatch(1788734);
         				getMatchInfo(1788734);
         				getMatch(1788734);
         				getTeams(1788734);
         				sym.$("matchtracker").fadeIn(400);
         				sym.$("panel0").fadeOut(400);
         				sym.$("panel1").fadeOut(400);
         				sym.$("panel2").fadeOut(400);
         				sym.$("cup").fadeOut(400);
         				matchInterval = setInterval(function() { getMatchInfo(1788734); }, 60000);
         				teamInterval = setInterval(function() { getTeams(1788734); }, 60000);
         				playInterval = setInterval(function() { getMatch(1788734); }, 60000);
         				for (var i=0; i<2; i++){
         					sym.getSymbol("btn"+i).$("btn"+i+"Txt").css({'color':'rgba(255,255,255,1.0)','pointer-events':'none'});
         					sym.getSymbol("btn"+i).$("btnbg").css({'background-color':'rgba(0,156,178,0.5)', 'width':'199px'});
         				}
         				sym.getSymbol("btn1").$('btnbg').css({'width':'200px'});
         			}else{
         				sym.getSymbol("panel1").play();
         			}
         	}
         });
         
         var toggleGoals=0;
         sym.getSymbol('panel2').$('goals').on('click', function(){
         	if(toggleGoals==0){
         		sym.getSymbol('panel2').$('goalCap').css({'height':'13px'});
         		toggleGoals=1;
         	}else{
         		sym.getSymbol('panel2').$('goalCap').css({'height':'0px'});
         		toggleGoals=0;
         	}
         });
         sym.getSymbol('panel2').$('goalCap').css({'height':'0px'});
         
         var moveLeft=0;
         var moveUp=0;		
         		function doClick() {
         			e.preventDefault();
         			e.stopPropagation();		
         			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)||selected_id == "Stage_panel0_grp" + (i+1)+'Txt'){
         				sym.getSymbol("panel0").$("grp" + (i+1)).stop().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();
         			for (var j=0; j<grpArray.length; j++){
         				sym.getSymbol("panel0").$(grpArray[j]).unbind('click');
         				sym.getSymbol("panel0").$(grpArray[j]).css({'cursor':'auto'});
         			}
         		}
         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)).stop().animate({width:190, height:73, left:moveLeft, top:moveUp}, 400);
         				sym.getSymbol("panel0").$('#gt'+(i+1)).css("display","none");
         			}
         			sym.getSymbol("panel0").$("fulltable").hide();
         			bindGrps(); 
         		}
         
         //MATCHTRACKER
         var swivelstate="lineups";       
         for (var m=0; m<3; m++){
         sym.getSymbol("matchtracker").$("tabBtn" + m).on('click', changeState);
         }
         function changeState (){
         			if (swivelstate=="tracker"){
         				sym.getSymbol("matchtracker").play();
         				sym.getSymbol("matchtracker").$("timeTxt").fadeOut(200);
         				sym.getSymbol("matchtracker").$("tabBtn0").attr("src","images/team.png");
         				sym.getSymbol("matchtracker").$("tabBtn1").css({'color':'rgba(255,255,255,1.0)','box-shadow':'none','background-color':'rgb(0,156,178)'});
         				sym.getSymbol("matchtracker").$("tabBtn2").css({'color':'rgba(255,255,255,1.0)','box-shadow':'3px 3px 4px rgba(100,100,100,0.5)','background-color':'rgb(165,220,225)'});
         
         				swivelstate="lineups";
         			}else if (swivelstate=="lineups"){
         				sym.getSymbol("matchtracker").playReverse();
         				sym.getSymbol("matchtracker").$("timeTxt").fadeIn(200);
         				sym.getSymbol("matchtracker").$("tabBtn0").attr("src","images/clock.png");
         				sym.getSymbol("matchtracker").$("tabBtn2").css({'color':'rgba(255,255,255,1.0)','box-shadow':'none','background-color':'rgb(0,156,178)'});
         				sym.getSymbol("matchtracker").$("tabBtn1").css({'color':'rgba(255,255,255,1.0)','box-shadow':'3px 3px 4px rgba(100,100,100,0.5)','background-color':'rgb(165,220,225)'});
         				swivelstate="tracker";
         			}
         			e.preventDefault()
         }
         changeState();
         
         function getMatchInfo(matchID){
         	var infoData;
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&match="+matchID+"&q=info",
         		contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         		async: true,
         		crossDomain: true,
         		success: function (data) {
         			infoData = data;
         			var matchteam1=infoData[0].c_HomeTeam;
         			var matchteam2=infoData[0].c_AwayTeam;
         			var score1;
         			var score2;
         			if (infoData[0].n_MatchStatusCode<8){
         				score1="0";
         				score2="0";
         			}else{
         				score1=infoData[0].n_HomeGoals;
         				score2=infoData[0].n_AwayGoals;
         			}
         			var matchRef;
         			if (infoData[0].c_Referee==null){
         				matchRef="";
         			}else{
         				matchRef="Referee: " + infoData[0].c_Referee;
         			}
         			var spectators;
         			if (infoData[0].n_Spectators==null){
         				spectators="";
         			}else{
         				spectators="Attendance: " + infoData[0].n_Spectators;
         			}
         			var matchscore = score1 + "-" + score2;
         			var imgH = "crests/"+ infoData[0].n_HomeTeamID + ".png";
         			var imgA = "crests/"+ infoData[0].n_AwayTeamID + ".png";
         			var matchStatus = infoData[0].n_MatchStatusCode;
         			var tacticsH =  infoData[0].c_HomeTactics;
         			var tacticsA =  infoData[0].c_AwayTactics;
         			var matchDate = getDDmonthYY(infoData[0].d_Date);
         			var matchInfo = infoData[0].c_Stadium + ", " + infoData[0].c_City + "<br />" + matchDate + "<br />" + matchRef + "<br />" + spectators ;
         			sym.getSymbol("matchtracker").$("crest1").attr("src",imgH);				
         			sym.getSymbol("matchtracker").$("crest2").attr("src",imgA);				
         			sym.getSymbol("matchtracker").$("team1Txt").text(matchteam1);
         			sym.getSymbol("matchtracker").$("team2Txt").text(matchteam2);
         			sym.getSymbol("matchtracker").$("scoreTxt").text(matchscore);
         			sym.getSymbol("matchtracker").$("matchTxt").html(matchInfo);
                  //matchStatus 8 (in progress), 128 (finished) 
         //PENALTY SHOOTOUT ONLY
         			if (infoData[0].n_PeriodSort>=10){
         			//if (lastPeriod==10){
         				if (infoData[0].n_HomeGoalsShootout>=0||infoData[0].n_AwayGoalsShootout>=0){
         					sym.getSymbol("timer").$("penalties").unbind("click");
         					sym.getSymbol("timer").$("penalties").show();
         					sym.getSymbol("timer").$("penalties").css({'cursor':'pointer'});
         					penShow="show";
         					sym.getSymbol("timer").$("penalties").click(showPenalties);
         				}
         			}
         			if (infoData[0].n_PeriodSort>5){
         				sym.getSymbol("timer").$("timeline").css({'cursor':'ns-resize'});
         				sym.$("timer").on("touchstart",touchStartY);
         				sym.$("timer").on("touchmove", moveMe); //bind touch function
         				sym.$("timer").on("mousedown", mouseMoveMe); //bind mouse function
                  }
         //END PENALTIES 	               							
         		}
         	});
         }
         
         var matchData;
         var diff1;
         var diff2;
         var vAlign;
         var posY;
         var lastAction;
         var lastTime;
         var offset = 0;
         var homePenHeight;
         var awayPenHeight;
         var penHeight;
         var penShow;
         var lastPeriod;
         var lastAction;
         function getMatch(matchID) { 
         	var minutes = sym.getSymbol("matchtracker").$("timeTxt");
         	minutes.text("0");
         	var myTimer = sym.getSymbol("matchtracker").getSymbol("timer");
         	myTimer.stop(0);
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&match="+matchID,
         		contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         		async: true,
         		crossDomain: true,
         		success: function (data) {
         			matchData = data;
         			//actionsHomeArr.length=0;
         			//actionsAwayArr.length=0;
         			//play from last action
         			lastAction = matchData[0].n_ActionTime;
         			lastPeriod = matchData[0].n_PeriodSort;
         			//var offset = 300000;
         						var offset = 360000;
         			var lastTimetxt;
                  var minutes = sym.getSymbol("matchtracker").$("timeTxt");
         			sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").getSymbol("pensDiv").$("homePens").empty();
         			sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").getSymbol("pensDiv").$("awayPens").empty();
         			sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("timeline").$("home").empty();
         			sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("timeline").$("away").empty();
                  //create display for each action	
                  var actionTxt;
                  var penTxt;
                  var HorA;
                  var actionSet;
                  var actionType;
                  var action;
                  var actionTime;
         			var actionMs;
                  var actionPeriod;
                  var player;
                  var sub;
                  for (var i = 0; i <= matchData.length; i++) {
         				if (matchData[i].n_ActionTime>lastAction){
         					lastAction=matchData[i].n_ActionTime;
         				}
         				if (matchData[i].n_PeriodSort>lastPeriod){
         					lastPeriod=matchData[i].n_PeriodSort;
         				}         		        
                  	actionSet = matchData[i].n_ActionSet;
                  	actionType = matchData[i].n_ActionCode;
                  	actionTime = matchData[i].c_ActionMinute;
         				if (actionSet==1||actionSet==2||actionSet==3||actionSet==5){
         					actionMs = matchData[i].n_ActionTime;
         					actionPeriod = matchData[i].n_PeriodSort;
         					player = matchData[i].c_PersonShort;
         					sub = matchData[i].c_SubPersonShort;
         					var obj=	{number:i, time:actionMs};					
         						if (matchData[i].n_HomeOrAway==1){
         							actionTxt = "<div id='action" + i + "' class='actionhome'><div class='whitebg'><div class='tablecell' style='width:75%'><span id='person" + i + "'></span><span id='subperson" + i + "'><span></div><div class='tablecell' id='actionMins" + i + "'></div></div><div id='type" + i + "'></div></div>";
         							penTxt = "<div class='penalty'><table width='100%' style='border:none; border-collapse:collapse'><tr><td id='person" + i + "' width='90%' style='text-align:right'></td><td width='10%' id='type" + i + "'></td></tr></table></div>";
         							HorA = "home";
         							//actionsHomeArr.push(obj);
         						}else if (matchData[i].n_HomeOrAway==-1){
         							//actionsAwayArr.push(obj);
         							HorA = "away";
         							actionTxt = "<div id='action" + i + "' class='actionaway'><div id='type" + i + "'></div><div class='whitebg'><div class='tablecell' id='actionMins" + i + "'></div><div class='tablecell' style='width:75%'><span id='person" + i + "'></span><span id='subperson" + i + "'><span></div></div></div>";
         							penTxt = "<div class='penalty'><table width='100%' style='border:none; border-collapse:collapse'><tr><td width='10%' id='type" + i + "'></td><td id='person" + i + "' width='90%' style='text-align:left'></td></tr></table></div>";
         						}
         					//then append each action (latest at top)
         						if(matchData[i].n_PeriodSort<10){
         							sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("timeline").$(HorA).append(actionTxt);
         						}else{
         							sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").getSymbol("pensDiv").$(HorA+"Pens").prepend(penTxt);
         						}
         						$('#person' + i).text(matchData[i].c_PersonShort);
                           $('#actionMins' + i).text(matchData[i].c_ActionMinute);     
         						if (matchData[i].n_ActionSet==5){
         							$('#subperson' + i).text(" (" + matchData[i].c_SubPersonShort + ")");
         						}else{
         							$('#subperson' + i).text("");
         						} 
         						//create icons for each action
         						switch (actionSet){
         							case 1:
         							action= "goal";
         							break;
         							case 2:
         							if (actionType==12){
         								action="pen";
         							}else{
         								action="miss";
         							}
         							break;
         							case 3:
         							if (actionType==2048){
         								action="yellow";
         							}else{
         								action="red";
         							}
         							break;
         							case 5:
         							action="sub";
         							break;
         						}
         						var imgHTML="<img src='images/"+action +".png' height='25px' width='25px'>";
         						$('#type' + i).html(imgHTML);
         
         						$('.whitebg').css({'width':'83%','background-color':'rgba(255,255,255,0.6)','pointer-events':'none','vertical-align':'top', 'float':'left','border-radius':'5px', 'padding':'1px 3px', 'display':'inline-table'});		
         						$('.actionaway .whitebg').css({'float':'right'});		
         						$('.actionhome, .actionaway').css({'width':'100%','font-size':'12px','font-family':'pragmatica-web, sans-serif','text-align':'left'});
         						$('.tablecell').css({'display':'table-cell'});
         						$('#action' + i).css({'cursor':'pointer','border-radius':'7px', 'height':'20px', 'overflow':'hidden', 'padding':'0'});
         						$('#action' + i).on('mouseover touchstart',function(i){ $(this).css({'z-index':'1000', 'background-color':'rgba(255,255,255,0.8)','box-shadow':'2px 2px 2px rgba(100,100,100,0.5)', 'overflow':'visible','height':'auto' });  });
         						$('#action' + i).on('mouseout touchend',function(){ $(this).css({'z-index':'100', 'background-color':'rgba(255,255,255,0)','box-shadow':'none', 'overflow':'hidden','height':'20px'}); });
         						$('#type' + i).css({'display':'inline'});
         						$('.actionhome #actionMins'+i).css({'text-align':'right'});
         						$('.actionaway #actionMins'+i).css({'text-align':'left'});
         						$('.penalty').css({"background-color":"rgb(255,255,255)","height":"25px","box-shadow":"1px 3px 3px rgba(100,100,100,0.5)","font-size":"12px","font-family":"pragmatica-web, sans-serif", "text-align":"left"});
         							//move actions that are too close together
         							//TRY LOOPING THROUGH actionsHomeArr, COMPARE i==actionsHomeArr[x].number AND TIME WITH actionsHomeArr[x-1].time
         
         							if (i+1 < matchData.length){
         								diff1 = matchData[i+1].n_ActionTime-matchData[i].n_ActionTime;
         								//if (diff1<120000){
         								if (diff1<150000){
         									posoffset=12;
         									//posoffset=18;				
         								}else{
         									//posoffset=3;
         									posoffset=0;
         								}
         							}
         							else{
         								//posoffset=3;
         								posoffset=0;
         							}
         							if ((matchData[i].n_ActionTime>=7200000)&&(lastPeriod<9)){
         								posY="-12px";
         							}else if ((matchData[i].n_ActionTime>=5400000)&&(lastPeriod<5)){
         								posY="-134px";
         							}else{
         							//90minute match
         								posY = 515-Math.round(405/90 * (matchData[i].n_ActionTime/60000)) + posoffset + "px";
         							}
         						$('#action' + i).css({'position':'absolute', 'top':posY});
         				} //close if
         
         				if (lastAction>7200000){					//if after 120 mins but before penalties
         					lastTime=7200000+offset;
         				}else if ((lastAction>6300000)&&(lastPeriod<7)){					//if after 105 mins but before second period
         					lastTime=6300000+offset;
         				}else if ((lastAction>5400000)&&(lastPeriod==11)){					//if after 90 mins match has finished
         					lastTime=5400000+offset;
         				}else if ((lastAction>5400000)&&(lastPeriod<5)){					//if after 90 mins but before extra time
         					lastTime=5400000+offset;
         				}else if((lastAction>2700000)&&(lastPeriod<4)){ 		// if match is in 1st half but > 45 mins
         					lastTime=2700000+offset;
         				}else{
         					lastTime=lastAction+offset;
         				}
         				//display latest time
         				if (lastPeriod==11){
         					lastTimetxt=Math.round((lastTime-offset)/60000);
         				}else if (lastPeriod<9){ //before penalty shootout
         					if(lastAction > 0){	
         						if (sym.isPlaying ("timer")){
         							lastTimetxt=Math.round(sym.getSymbol("matchtracker").getSymbol("timer").getPosition()/60000)-5;
         						}else{
         							lastTimetxt=Math.round(lastAction/60000);
         						}
         					}
         				}else{
         					lastTimetxt="120";
         				}
         				minutes.text(lastTimetxt);
         				myTimer.play(lastTime);
         			} //close for 
         
         			//if penalty shootout Knockout competetions only
         			if (lastPeriod>5){
         				sym.getSymbol("matchtracker").getSymbol("timer").$("timeline").css({'cursor':'ns-resize'});
         				sym.getSymbol("matchtracker").$("timer").on("touchstart",touchStartY);
         				sym.getSymbol("matchtracker").$("timer").on("touchmove", moveMeTimer); //bind touch function
         				sym.getSymbol("matchtracker").$("timer").on("mousedown", mouseMoveTimer); //bind mouse function
                  }
         			//if (lastPeriod>=10){
         			if (lastPeriod==10){
         				sym.getSymbol("matchtracker").getSymbol("timer").$("penalties").unbind("click");
         				sym.getSymbol("matchtracker").getSymbol("timer").$("penalties").show();
         				sym.getSymbol("matchtracker").getSymbol("timer").$("penalties").css({'cursor':'pointer'});
         				penShow="show";
         				sym.getSymbol("matchtracker").getSymbol("timer").$("penalties").click(showPenalties);
         			}
         			homePenHeight=sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").getSymbol("pensDiv").$("homePens").height();
         			awayPenHeight=sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").getSymbol("pensDiv").$("awayPens").height();
         			penHeight = (homePenHeight>awayPenHeight)?homePenHeight:awayPenHeight;
         		} //close success  	                                                  	           
         	}); //close ajax
         }
         
         
         function showPenalties(){
         	if(penShow=="show"){
         		penShow="hide";
         		sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").$("pensDiv").hide();
         		sym.getSymbol("matchtracker").getSymbol("timer").$("timeline").css({'top':0}); //move timeline down
         	}else{
         		penShow="show";
         		sym.getSymbol("matchtracker").getSymbol("timer").getSymbol("penalties").$("pensDiv").show();
         		sym.getSymbol("matchtracker").getSymbol("timer").$("timeline").css({'top':penHeight}); //move timeline down
         	}
         }
         
         function getTeams(matchID) {           
         	var teamData;
         	$.ajax({ type: "GET", url: dataURL,
         		data: "gn=30764&yr=2013&q=teams&match="+matchID,
         		contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         		async: true,
         		crossDomain: true,
         		success: function (data) {
         			teamData = data;
         			for (var i = 0; i < teamData.length; i++) {		
         				if (teamData[i].n_HomeOrAway==1){
         					var teamlist = "hometeam";
         				}else if (teamData[i].n_HomeOrAway==-1){
                  		var teamlist = "awayteam";
         				}
         				if (teamData[i].n_ActionSet==4){
         					var lineupTxt = "<table width='100%' style='font-size:13px;font-family:pragmatica-web, sans-serif; border-collapse:collapse' id='lineup" + i + "'><tr><td width='10%' style='text-align:right;' id='teamShirt" + i + "'></td><td width='75%' style='padding-left:5px' id='teamPerson" + i + "'></td><td width='15%' style='font-style:oblique; font-size:11px; text-align:right' id='teamNat" + i + "'></td></tr></table>";
         				} else if (teamData[i].n_ActionSet==5){
         					var lineupTxt = "<table width='100%' style='font-size:13px;font-family:pragmatica-web, sans-serif; border-collapse:collapse' id='substitute" + i + "'><tr><td width='10%' style='text-align:right; font-style:oblique' id='teamShirt" + i + "'></td><td width='75%' style='font-style:oblique; padding-left:5px' id='teamPerson" + i + "'></td><td width='15%' style='font-style:oblique; font-size:11px; text-align:right' id='teamNat" + i + "'></td></tr></table>";
         				} else if (teamData[i].n_ActionSet==8){
         					var coach = "<b>" + teamData[i].c_Person + "</b> <span style='text-align:right; font-style:oblique; font-size:12px'>" + teamData[i].c_PersonNatioShort + "</span>";
         				}
         				sym.getSymbol("matchtracker").getSymbol("teams").$(teamlist).append(lineupTxt);                
         				sym.getSymbol("matchtracker").getSymbol("teams").$(teamlist + "Txt").html(coach);
         				var actionMins;	                
         				if (teamData[i].c_ActionMinute==null){
         					actionMins="";
         				}else{
         					actionMins=" ("+ teamData[i].c_ActionMinute + ")";
         				}			
         				$('#teamShirt' + i).text(teamData[i].n_ShirtNr);
         				$('#teamPerson' + i).html(teamData[i].c_Person + actionMins);
         				$('#teamNat' + i).text(teamData[i].c_PersonNatioShort);
         				$('#subPerson' + i).text(teamData[i].c_SubPersonShort);
         				$('#actionMins' + i).text(teamData[i].c_ActionMinute); 
         				var posn = teamData[i].n_Position;			
         			}
         
         		}
         	});
         }
         
         //SCROLL TIMELINE
         	var timer = sym.getSymbol("matchtracker").$("timer");
         	var timeHeight = timer.height();
         	var timerY = timer.offset().top;
         	var timerBottomY = timerY + timeHeight;
         	var startY=0;
         	var moveTimer=0
         var startTimer=timerY;
         var timeLine = sym.getSymbol("matchtracker").getSymbol("timer").$("timeline");
         var timeLineHeight = timeLine.height();
         var moveTimerStrip = timeLineHeight-timeHeight;
         	timer.bind("touchstart touchmove", moveMeTimer); //bind touch function
         	timer.bind("mousedown", mouseMoveTimer); //bind mouse function
         
         function touchStartY(e){ //handle touch event
         	startY = e.touches[0].pageY;
         }
         //
         function moveMeTimer(e) {
         		e.preventDefault(); //prevents it firing a mouse click when touched
         		var orig = e.originalEvent;
         		var pos = 0;
         		pos = orig.touches[0].pageY;
         var moveDistance=startY-pos;
         moveTimer=startTimer-moveDistance;   
         	if(pos>=timerY&&pos<=timerBottomY){
         		if(moveTimer<=0){
                  sym.getSymbol("matchtracker").getSymbol("timer").$("timeline").css({'top':moveTimer});
                 }
         	}
         };
         //
         function mouseMoveTimer(e){ //handle mousedown event
         startY = e.pageY;
         sym.getComposition().getStage().getSymbolElement().mousemove(handleMouseMoveTimer); //bind mousemove functions to stage in case cursor goes oustide the thumb
         sym.getComposition().getStage().getSymbolElement().mouseup(handleMouseUpTimer); //bind mouseup functions to stage 
         }	
         
         function handleMouseMoveTimer(jqEvent){
         	var pos = 0;
         		pos = jqEvent.pageY;
         	var moveDistance=startY-pos;
         	moveTimer=startTimer-moveDistance;
         			if(pos>=timerY&&pos<=timerBottomY){
         			if(moveTimer<=0){
                  	sym.getSymbol("matchtracker").getSymbol("timer").$("timeline").css({'top':moveTimer});
                  }
         		}
         }
         
         function handleMouseUpTimer(jqEvent){ // handle mouseup event
         sym.getComposition().getStage().getSymbolElement().unbind("mousemove");
         sym.getComposition().getStage().getSymbolElement().unbind("mouseup");
         startTimer=moveTimer;
         }
         
         function handleTouchUpTimer(jqEvent){ // handle touchup event
         sym.getComposition().getStage().getSymbolElement().unbind("touchmove");
         sym.getComposition().getStage().getSymbolElement().unbind("touchend");
         }
         
         //Opening animation
         sym.$('buttons').fadeOut(0);
         sym.getSymbol('panel0').$('matches').fadeOut(0);
         function playAnim(){
         sym.getSymbol('cup').play();
         sym.$('buttons').delay(1500).fadeIn(200);
         sym.getSymbol('panel0').$('matches').delay(1500).fadeIn(200);
         }
         setTimeout(playAnim, 800);
         
         $('img').on('dragstart',function(e){ e.preventDefault(); }); //make images undraggable

      });
      //Edge binding end

      

      

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

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

      

      

      

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

//=========================================================
   //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);
         //set the value of a Symbol variable

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 500, function(sym, e) {
         sym.stop();
         //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

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

   //=========================================================
   
   //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'

   //=========================================================

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

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

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

      

      

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

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

   //=========================================================
   
   //Edge symbol: 'Timer'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 3000000, function(sym, e) {
         sym.stop();
         // insert code here

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

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

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

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

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

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

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

})(jQuery, AdobeEdge, "GraphicNews-30764");