window.addEvent('domready',function(){
	//SHOW RESTORE BTN
	$('lt-restore').fade('hide');
	$('lt-restore').setStyle('display','block');
	//HIDE VODSET
	if($('lt-vodset')){
		$('lt-vodset').fade('hide');
		if(Browser.Platform.ios){
			var gestureOverlay = new Element('div',{'id':'gestureOverlay','style':'width:480px;height:100%;position:absolute;z-index:1;top:0px;left:245px;background:url(images/alpha50.png);'});
			var gestureImg = new Element('img',{'src':'images/2fingerscroll.png','style':'position:absolute;top:85px;left:105px;','width':'223','height':'197','alt':''});
			gestureImg.inject(gestureOverlay);gestureOverlay.inject($('lt-mainmod'));
			$('gestureOverlay').addEvent('click',function(){
				$('gestureOverlay').destroy();
			});
		}
	}
	//TEAMS LINEUP EVENTS
	var teamAcc1 = new Fx.Accordion($('lt-teampanel1').getElements('a.lt-teampanelbar'), $('lt-teampanel1').getElements('div.lt-accmod'),{
		onActive: function(toggler){
			toggler.addClass('lt-teampanelbarOn');
		},
		onBackground: function(toggler){
			toggler.removeClass('lt-teampanelbarOn');
		},
		opacity: false
	});
	var teamAcc2 = new Fx.Accordion($('lt-teampanel2').getElements('a.lt-teampanelbar'), $('lt-teampanel2').getElements('div.lt-accmod'),{
		onActive: function(toggler){
			toggler.addClass('lt-teampanelbarOn');
		},
		onBackground: function(toggler){
			toggler.removeClass('lt-teampanelbarOn');
		},
		opacity: false
	});
	//TIMELINE TWEEN
	tlTween = new Fx.Tween($('lt-regularbar'),{
		duration: 500,
		onComplete: function(){
			$('lt-extrabar').fade('hide');
			$('lt-extrabar').setStyle('display','block');
			$('lt-extrabar').fade(1);
		}
	});
	//COMMENTS
	if($('lt-mintab') && $('lt-comtab')){
		$('lt-comments').setStyle('display','none');
		$('lt-mintab').addEvent('click',function(e){e.stopPropagation();$('lt-mintab').addClass('lt-tabOn');$('lt-comtab').removeClass('lt-tabOn');$('lt-minamin').setStyle('display','block');$('lt-comments').setStyle('display','none');});
		$('lt-comtab').addEvent('click',function(e){e.stopPropagation();$('lt-comtab').addClass('lt-tabOn');$('lt-mintab').removeClass('lt-tabOn');$('lt-comments').setStyle('display','block');$('lt-minamin').setStyle('display','none');});
	}
	//FETCH JSON
	fetchJson();
	//PLAYER FX
	$('lt-restore').addEvent('click',function(e){
		e.stopPropagation();
		restorePlayer();
	});
	//POLL
	var pollLinks = $('lt-poll').getElements('a.lt-linkpoll');
	pollLinks.each(function(item,index){
		item.addEvent('mouseenter',function(e){
			e.stopPropagation();
			this.getParent().addClass('lt-pollhover');
		});
		item.addEvent('mouseleave',function(e){
			e.stopPropagation();
			this.getParent().removeClass('lt-pollhover');
		});
	});
});
//GLOBAL VARS
var mainTimer;
var fullObj = 'true';
var digitHash = {'0':'0','1':'47','2':'94','3':'140','4':'188','5':'234','6':'282','7':'328','8':'375','9':'423'};
var playTime;
var minTimer;
var tlTween;
var extra = false;
var gameOver = false;
var ptysFx;
var last = 0;
var lastExtra = 0;
var iosFeed;
var divFB;
var mainDelay = 120000;
//GLOBAL FUNCTIONS
function playVod(feed){
	if(!Browser.Platform.ios){
		if($('lt-liveplayer')){
			$('lt-liveplayer').setStyle('width','150px');
			$('lt-liveplayer').setStyle('height','84px');
			$('lt-liveplayer').setStyle('right','10px');
			$('lt-liveplayer').setStyle('bottom','40px');
			if(!Browser.ie){
				$('kaltura_live').set('width','150');
				$('kaltura_live').set('height','116');
			}
		}
		if($('lt-restore').getStyle('opacity') != 1)$('lt-restore').fade(1);
		if($('lt-liveplayer'))$('kaltura_live').sendNotification('changeVolume', 0);
		if($('lt-vodset'))$('lt-vodset').setStyle('opacity','1');
		$('kaltura_vod').sendNotification("changeMedia",{entryId:feed});
		$('kaltura_vod').addJsListener('mediaReady','playVodGoal');
		if($('lt-liveplayer'))$('lt-liveplayer').setStyle('border','1px solid #ffffff');
		if($('lt-liveplayer')){
			$('lt-vodplayer').addEvent('mouseenter',function(e){
				e.stopPropagation();
				$('lt-liveplayer').fade('hide');
			});
			$('lt-vodplayer').addEvent('mouseleave',function(e){
				e.stopPropagation();
				$('lt-liveplayer').fade('show');
			});
		}
	}else{
		if($('lt-liveplayer')){
			$('lt-liveplayer').empty();
			$('lt-liveplayer').set('html','<video id="lt-htmlplayer" src="' + feed + '" type="video/mp4" controls="controls" autoplay="autoplay" width="480" height="300"></video>');
			$('lt-htmlplayer').load();
			$('lt-htmlplayer').play();
			$('lt-restore').fade(1);
		}else if($('lt-vodset')){
			if($('gestureOverlay'))$('gestureOverlay').destroy();
			$('lt-vodset').setStyle('opacity','1');
			$('lt-vodplayer').empty();
			$('lt-vodplayer').set('html','<video id="lt-htmlplayer" src="' + feed + '" type="video/mp4" controls="controls" autoplay="autoplay" width="480" height="300"></video>');
			$('lt-htmlplayer').load();
			$('lt-htmlplayer').play();
			$('lt-restore').fade(1);
		}
	}
}
function playVodGoal(){
	$('kaltura_vod').sendNotification('doPlay');
	$('kaltura_vod').removeJsListener('mediaReady','playVodGoal');
	$('kaltura_vod').addJsListener('playerPlayEnd','restorePlayer');
}
function restorePlayer(){	
	if($('lt-liveplayer'))$('lt-liveplayer').fade('show');
	if(!Browser.Platform.ios){
		if($('lt-liveplayer')){
			$('kaltura_live').sendNotification('changeVolume', 1);
			$('kaltura_vod').sendNotification('doStop');
			$('lt-liveplayer').setStyle('width','480px');
			$('lt-liveplayer').setStyle('height','300px');
			$('lt-liveplayer').setStyle('right','0px');
			$('lt-liveplayer').setStyle('bottom','0px');
			if(!Browser.ie){
				$('kaltura_live').set('width','480');
				$('kaltura_live').set('height','300');
			}
			$('lt-restore').fade('hide');
			$('lt-restore').setStyle('display','block');
			$('lt-liveplayer').setStyle('border','none');
			$('lt-vodplayer').removeEvents();
		}else if($('lt-vodset')){
			$('kaltura_vod').sendNotification('doStop');
			$('lt-vodset').setStyle('opacity','0');
			$('lt-restore').fade('hide');
		}
	}else{
		if($('lt-liveplayer')){
			$('lt-liveplayer').empty();
			$('lt-liveplayer').set('html','<video id="lt-htmlplayer" src="' + iosFeed + '" type="video/mp4" controls="controls" autoplay="autoplay" width="480" height="300"></video>');
			$('lt-htmlplayer').load();
			$('lt-htmlplayer').play();
		}else if($('lt-vodset'))$('lt-vodset').setStyle('opacity','0');
		$('lt-vodplayer').empty();
		$('lt-restore').fade(0);
	}
}
function fetchJson(){
	var jsonSource;
	if($('lt-vodset'))jsonSource = 'json2.php';
	else jsonSource = 'json.php';
	clearTimeout(mainTimer);
	var jsonRequest = new Request.JSON({url: jsonSource,
		onSuccess: function(json){
		    if(json){
		    	deployJson(json);
		    	if(json.extra.length > 0){
			    	if($('lt-regularbar').getStyle('width').toInt() != 610)tlTween.start('width','610');
			    }
			    //GAME OVER
				if(json.matchdata.finished == 'true')gameOver = true;
		    }
		    if(gameOver == false)mainTimer = fetchJson.delay(mainDelay);
		}
	}).post({'fullObj': fullObj, 'last': last, 'lastExtra': lastExtra, 'match': match, 'datematch': datematch});
}
function deployJson(json){
	if(fullObj == 'true'){
		fullObj = 'false';
		match = json.match;
		//CERTIFICA PARTIDO
		kalturaIdContenido = json.matchinfo.local.name + '_' + json.matchinfo.visitor.name;
		$('fondo-pagina').setStyle('background','url(' + json.bgimg + ') top center no-repeat');
		$('fondo-pagina').setStyle('background-color',json.bgcolor);
		loadMatchInfo(json.matchinfo);
		if(!Browser.Platform.ios && $('lt-liveplayer')){
		//INSET PLAYER
			//LIVE PLAYER
			if($('lt-liveplayer')){
				var livePlayer = new Swiff('http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/' + json.feed,{
				    id: 'kaltura_live',
				    width: '100%',
				    height: '100%',
				    container: 'lt-liveplayer',
				    properties: {
				    	name: 'kaltura_live',
				    	allowFullScreen: 'true',
				    	allowNetworking: 'all',
				    	allowScriptAccess: 'always',
				    	bgcolor: '#000000',
				    	"xmlns:dc": 'http://purl.org/dc/terms/',
				    	"xmlns:media": 'http://search.yahoo.com/searchmonkey/media/',
				    	rel: 'media:video',
				    	resource: 'http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/' + json.feed
				    },
				    params: {
				        allowFullScreen: 'true',
				        allowNetworking: 'all',
				        allowScriptAccess: 'always',
				        wmode: 'opaque',
				        bgcolor: '#000000',
				        movie: 'http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/' + json.feed
				    },
				    vars: {
				        'foo': 'bar',
				        'vast.prerollUrl': 'http://www.tvazteca.com/tmp-gato/oaskaltura/kalturavast.php?campania=video.aztecadeportes%2Ffutbolxinternet&entryId=0_xwx9hqjb&autoPlay=1&bufferTime=5&disableUrlHashing=1&bufferTime=5&streamerType=hdnetwork&akamaiHD.loadingPolicy=preInitialize&akamaiHD.asyncInit=true&seekFromStart=0&debugmode=0&host=www.kaltura.com' 
				    }
				});
			}
			var liveReady = false;
		}else{
			iosFeed = json.iosfeed;
			if($('lt-liveplayer'))restorePlayer();
		}
		if(!Browser.Platform.ios && $('lt-vodplayer')){
			//VOD PLAYER
			if($('lt-vodplayer')){
				var vodPlayer = new Swiff('http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/-1',{
				    id: 'kaltura_vod',
				    width: '100%',
				    height: '100%',
				    container: 'lt-vodplayer',
				    properties: {
				    	name: 'kaltura_vod',
				    	allowFullScreen: 'true',
				    	allowNetworking: 'all',
				    	allowScriptAccess: 'always',
				    	bgcolor: '#000000',
				    	"xmlns:dc": 'http://purl.org/dc/terms/',
				    	"xmlns:media": 'http://search.yahoo.com/searchmonkey/media/',
				    	rel: 'media:video',
				    	resource: 'http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/-1'
				    },
				    params: {
				        allowFullScreen: 'true',
				        allowNetworking: 'all',
				        allowScriptAccess: 'always',
				        wmode: 'opaque',
				        bgcolor: '#000000',
				        movie: 'http://www.kaltura.com/index.php/kwidget/cache_st/1304000753/wid/_459791/uiconf_id/5260641/entry_id/-1'
				    },
				    vars: {
				        'foo': 'bar',
				        'vast.prerollUrl': 'http://www.tvazteca.com/tmp-gato/oaskaltura/kalturavast.php?campania=video.aztecadeportes%2Ffutbolxinternet&entryId=0_xwx9hqjb&autoPlay=1&bufferTime=5&disableUrlHashing=1&bufferTime=5&streamerType=hdnetwork&akamaiHD.loadingPolicy=preInitialize&akamaiHD.asyncInit=true&seekFromStart=0&debugmode=0&host=www.kaltura.com' 
				    }
				});
			}
		}
	}
	loadMatchData(json.matchdata);
	loadMatchEvents(json.events,'regular');
	loadMatchEvents(json.extra,'extra');
}
function loadMatchEvents(json,face){
	if(json.length > 0){
		json.each(function(item,index){
			if(face == 'regular' && (item.id).toInt() > last)last = (item.id).toInt();
			if(face == 'extra' && (item.id).toInt() > lastExtra)lastExtra = (item.id).toInt(); 
			if(item.erase == '1')eraseItem(item,face);
			else if(item.update == '1'){
				eraseItem(item,face);
				createItem(item,face);
			}else createItem(item,face);
		});
	}
}
function eraseItem(item,face){
	if($('lt-minrow' + (item.id).toInt()))$('lt-minrow' + (item.id).toInt()).destroy();
	if($('lt-' + item.team + 'playericon' + (item.id).toInt()))$('lt-' + item.team + 'playericon' + (item.id).toInt()).destroy();
	if($('lt-' + item.team + 'eventicon' + (item.id).toInt()))$('lt-' + item.team + 'eventicon' + (item.id).toInt()).destroy();
	if($('lt-' + item.team + 'playericonB' + (item.id).toInt()))$('lt-' + item.team + 'playericonB' + (item.id).toInt()).destroy();
}
function createItem(item,face){
	//MINXMIN
	var realMin;
	if(face == 'regular')realMin = (item.minute).toInt();
	else if(face == 'extra')realMin = (item.minute).toInt() + 90;
	var existsA;
	if($('lt-minrow' + (item.id).toInt()))existsA = true;else existsA = false;
	if(existsA == false){
		var minRow = new Element('div',{'id':'lt-minrow' + (item.id).toInt(),'class':'lt-minrow'});
		var minSqr = new Element('div',{'class':'lt-minsquare','html':realMin + "'"});
		var minTxt = new Element('p',{'html':item.description});
		minSqr.inject(minRow);minTxt.inject(minRow);
		var place = getInjectPlace((item.id).toInt());
		if(place == 0){
			minRow.addClass('lt-mainOdd');
			minRow.inject($('lt-minamin'),'bottom');
		}
		else if(place == null){
			minRow.addClass('lt-mainOdd');
			minRow.inject($('lt-minamin'),'top');
		}
		else {
			if(!$('lt-minrow' + place).hasClass('lt-mainOdd'))minRow.addClass('lt-mainOdd');
			minRow.inject($('lt-minrow' + place),'before');
		}
	}
	//TIMELINE
	if(item.type == '2' || item.type == '7' || item.type == '9' || item.type == '11'){
		var existsB;
		if($('lt-' + item.team + 'eventicon' + (item.id).toInt()))existsB = true;else existsB = false;
		if(existsB == false){
			var styleClass;
			var styleLeft;
			var parent;
			//STYLECLASS
			if(item.team == 'local')styleClass = 'lt-eventicona';
			else if(item.team == 'visitor')styleClass = 'lt-eventiconb';
			//PARENT
			if(face == 'regular' && item.team == 'local')parent = 'lt-localtlbar';
			else if(face == 'regular' && item.team == 'visitor')parent = 'lt-visitortlbar';
			else if(face == 'extra' && item.team == 'local')parent = 'lt-localextrabar';
			else if(face == 'extra' && item.team == 'visitor')parent = 'lt-visitorextrabar';
			//STYLE LEFT
			if(face == 'regular')styleLeft = ((item.minute.toInt()) * 100) / 90;
			else if(face == 'extra')styleLeft = ((item.minute.toInt()) * 100) / 30;
			styleLeft = Math.round(styleLeft);
			if(face == 'regular' && styleLeft > 100)styleLeft = 100;
			var evtIco = new Element('a',{'id':'lt-' + item.team + 'eventicon' + (item.id).toInt(),'href':'javascript:void(0);','class':styleClass,'style':'left:' + styleLeft + '%'});
			var evtImg;
			var evtSpan;
			var playerImg;
			var playerImg2;
			if(item.type == '2'){
				evtImg = new Element('img',{'src':'images/evt-swap.png','width':'24','height':'24','alt':'SWP'});
				evtSpan = new Element('span',{'html':'<strong>' + item.minute + "'</strong>: Sale jugador #" + item.player + ',&nbsp;Entra jugador #' + item.playernew});
				playerImg =  new Element('img',{'id':'lt-' + item.team + 'playericon' + (item.id).toInt(),'class':'lt-playericon','src':'images/icn-swap.png','width':'17','height':'17','alt':'SWP'});
				playerImg2 =  new Element('img',{'id':'lt-' + item.team + 'playericonB' + (item.id).toInt(),'class':'lt-playericon','src':'images/icn-swap.png','width':'17','height':'17','alt':'SWP'});
			}else if(item.type == '7'){
				evtImg = new Element('img',{'src':'images/evt-yellow.png','width':'24','height':'24','alt':'TA'});
				evtSpan = new Element('span',{'html':'<strong>' + item.minute + "'</strong>: Tarjeta amarilla para jugador #" + item.player});
				playerImg =  new Element('img',{'id':'lt-' + item.team + 'playericon' + (item.id).toInt(),'class':'lt-playericon','src':'images/icn-yellow.png','width':'17','height':'17','alt':'TA'});
			}else if(item.type == '9'){
				evtImg = new Element('img',{'src':'images/evt-red.png','width':'24','height':'24','alt':'TR'});
				evtSpan = new Element('span',{'html':'<strong>' + item.minute + "'</strong>: Tarjeta roja para jugador #" + item.player});
				playerImg =  new Element('img',{'id':'lt-' + item.team + 'playericon' + (item.id).toInt(),'class':'lt-playericon','src':'images/icn-red.png','width':'17','height':'17','alt':'TR'});
			}else if(item.type == '11'){
				if(item.video != 'null'){
					evtImg = new Element('img',{'src':'images/evt-video.png','width':'24','height':'24','alt':'GOL'});
					evtSpan = new Element('span',{'html':'<strong>' + item.minute + "'</strong>: Gol de jugador #" + item.player + '&nbsp;<strong>(video)</strong>'});
				}else{
					evtImg = new Element('img',{'src':'images/evt-goal.png','width':'24','height':'24','alt':'GOL'});
					evtSpan = new Element('span',{'html':'<strong>' + item.minute + "'</strong>: Gol de jugador #" + item.player});
				}
				playerImg =  new Element('img',{'id':'lt-' + item.team + 'playericon' + (item.id).toInt(),'class':'lt-playericon','src':'images/icn-goal.png','width':'17','height':'17','alt':'GOL'});
			}
			evtImg.inject(evtIco);
			if(!Browser.Platform.ios)evtSpan.inject(evtIco);
			evtIco.inject(parent);
			//VOD EVENT
			if(item.type == '11' && item.video != 'null'){
				$('lt-' + item.team + 'eventicon' + (item.id).toInt()).addEvent('click',function(e){
					e.stopPropagation();
					if(Browser.Platform.ios){
						var formatedUrl = (item.iosvideo).replace('rtmpe://vod.statictvazteca.com/ondemand','http://video.statictvazteca.com');
						formatedUrl = formatedUrl.replace('mp4:am','IP');
						playVod(formatedUrl);
					}else playVod(item.video);
				});
			}
			//PLAYER NAME ICON
			if($('lt-' + item.team + 'player' + item.player))playerImg.inject($('lt-' + item.team + 'player' + item.player));
			if(item.type == '2')if($('lt-' + item.team + 'player' + item.playernew))playerImg2.inject($('lt-' + item.team + 'player' + item.playernew));
		}
	}
}
function getInjectPlace(x){
	x = x.toInt();
	if(x == 1)return 0;
	else{
		var firstMin = $('lt-minamin').getFirst();
		if(firstMin == null)return null;
		else{
			var place;
			if(x>firstMin.get('id').replace('lt-minrow','').toInt()){
				place = firstMin.get('id').replace('lt-minrow','').toInt();
			}else{
				var allMin = $('lt-minamin').getElements('div.lt-minrow');
				for(i=0;i<allMin.length;i++){
					var itemId = allMin[i].get('id').replace('lt-minrow','').toInt();
					if(x>itemId){
						place = itemId;
						i =	(allMin.length) - 1;
					}
				}
			}
			return place;
		}
	}	
}
function loadMatchInfo(json){
	var localFlag = new Element('img',{'src':json.local.logo,'alt':json.local.name});
	var visitorFlag = new Element('img',{'src':json.visitor.logo,'alt':json.visitor.name});
	localFlag.inject($('lt-localflag'));visitorFlag.inject($('lt-visitorflag'));
	var localName = new Element('h1',{'class':'fleft','html':json.local.name});
	var visitorName = new Element('h1',{'class':'fright','html':json.visitor.name});
	localName.inject($('lt-localname'));visitorName.inject($('lt-visitorname'));
	var ptyLocalTeam = new Element('h1',{'class':'fleft','html':json.local.name});
	var ptyVisitorTeam = new Element('h1',{'class':'fright','html':json.visitor.name});
	ptyLocalTeam.inject($('lt-ptyteams'));ptyVisitorTeam.inject($('lt-ptyteams'));
	var tlLocalName = new Element('h1',{'html':json.local.name});
	var tlVisitorName = new Element('h1',{'html':json.visitor.name});
	tlLocalName.inject($('lt-tllocalname'));tlVisitorName.inject($('lt-tlvisitorname'));
	var localFormation = new Element('img',{'src':json.local.formationimg,'width':'245','height':'339','alt':'Formación'});
	var visitorFormation = new Element('img',{'src':json.visitor.formationimg,'width':'245','height':'339','alt':'Formación'});
	$('lt-localformation').empty();$('lt-visitorformation').empty();
	localFormation.inject($('lt-localformation'));visitorFormation.inject($('lt-visitorformation'));
	fillPlayers(json.local.lineup,'local','lt-localplaying');
	fillPlayers(json.local.backup,'local','lt-localbackup');
	fillPlayers(json.visitor.lineup,'visitor','lt-visitorplaying');
	fillPlayers(json.visitor.backup,'visitor','lt-visitorbackup');
}
function fillPlayers(players,team,container){
	var even = false;
	players.each(function(item,index){
		var playerDiv = new Element('div',{'id':'lt-' + team + 'player' + item.playernumber,'class':'lt-playername'});
		var playerName = new Element('p',{'html':'&nbsp;' + item.playername});
		var playerNumber = new Element('strong',{'class':'lt-playerstrong' + team,'html':item.playernumber});
		if(even == true)playerDiv.addClass('lt-evenname');
		if(even == false)even = true;else even = false;
		playerNumber.inject(playerName,'top');playerName.inject(playerDiv);playerDiv.inject($(container));
	});
}
function loadMatchData(json){
	//SCORE SET
	showScore(json.scorelocal,'local');
	showScore(json.scorevisitor,'visitor');
	//TIME HALF
	if(json.playhalf == '1T' || json.playhalf == '1t')$('lt-timehalf').set('html','PRIMER TIEMPO');
	if(json.playhalf == '2T' || json.playhalf == '2t')$('lt-timehalf').set('html','SEGUNDO TIEMPO');
	if(json.playhalf == 'TE' || json.playhalf == 'te')$('lt-timehalf').set('html','TIEMPO EXTRA');
	if(json.playhalf == 'PE' || json.playhalf == 'pe'){$('lt-timehalf').set('html','PENALES');$('lt-timemin').setStyle('display','none');}
	//PLAYTIME
	clearTimeout(minTimer);
	playTime = (json.playtime).toInt();
	if(gameOver == false && json.active == 'true')catchTime();
	//PENALTIES
	if(json.penalties.enabled == 'true'){
		if($('lt-penalties').getStyle('display') == 'none'){
			$('lt-penalties').fade('hide');
			$('lt-penalties').setStyle('display','block');
			$('lt-penalties').fade(1);
		}
		fillPenalties(json.penalties.shotslocal,'local');
		fillPenalties(json.penalties.shotsvisitor,'visitor');
	}
}
function showScore(number,team){
	number = number.toInt();
	if(number <= 9){
		$('lt-' + team + 'digit2').tween('background-position','0px -' + digitHash[number] + 'px');
		$('lt-' + team + 'digit1').setStyle('display','none');
	}
	else if(number > 9 && number <= 99){
		$('lt-' + team + 'digit1').setStyle('display','block');
		var digit1 = number.toString();
		digit1 = digit1.substr(0,1);
		var digit2 = number.toString();
		digit2 = digit2.substr(1,1);
		$('lt-' + team + 'digit1').tween('background-position','0px -' + digitHash[digit1] + 'px');
		$('lt-' + team + 'digit2').tween('background-position','0px -' + digitHash[digit2] + 'px');
	}
}
function catchTime(){
	if(gameOver == false){
		clearTimeout(minTimer);
		$('lt-timemin').set('html','MINUTO&nbsp;' + playTime);
		playTime++;
		minTimer = catchTime.delay(60000);
	}
}
function fillPenalties(penalties,team){
	$('lt-' + team + 'ptyrow').empty();
	penalties.each(function(item,index){
		var ptyDiv = new Element('div',{'class':'lt-penalty'})
		if(item.goal == 'true')ptyDiv.addClass('lt-ptyscored');
		else if(item.goal == 'false')ptyDiv.addClass('lt-ptyfailed');
		var ptyPlayer = new Element('span',{'class':'lt-ptyplayer','html':item.player});
		var ptyBox = new Element('span',{'class':'lt-ptybox'});
		ptyBox.inject(ptyDiv);ptyPlayer.inject(ptyDiv);ptyDiv.inject($('lt-' + team + 'ptyrow'));
	});
}
function vote(x){
	var pollRes = $('lt-poll').getElements('div.lt-pollres');
	pollRes.each(function(item,index){
		item.empty();
		item.addClass('lt-pollwait');
	});
	var pollId = $('lt-poll').get('name');
	var pollRequest = new Request.JSON({url: 'poll.php', 
		onSuccess: function(json){
		    var pollLinks = $('lt-poll').getElements('a.lt-linkpoll');
		    pollLinks.each(function(item,index){
		    	item.getParent().removeClass('lt-pollhover');
		    	item.destroy();
		    });
		    if(json){
		    	(json.response).each(function(item,index){
		    		var resper = new Element('p',{'html': item.value});
		    		$('lt-pollres' + item.resId).removeClass('lt-pollwait');
		    		resper.inject($('lt-pollres' + item.resId));
		    	});
		    	var resTot = new Element('p',{'class':'lt-pollty','html':'TOTAL DE VOTOS:&nbsp;' + json.total});
		    	var pollH3 = $('lt-poll').getElement('h3');
		    	resTot.inject(pollH3,'after');
		    	var resty = new Element('p',{'class':'lt-pollty','html':'GRACIAS POR TU VOTO'});
		    	resty.inject($('lt-poll'),'bottom');
		    }
		}
	}).post({'option': x,'pollId': pollId});
}
function enableFbComs(){
	$('lt-comments').set('html','<fb:comments width="610" numposts="8"></fb:comments>');
	funcFB = "FB.init({appId: '187725799275', status: true, cookie: true, xfbml: true});";
	funcFB = "window.fbAsyncInit = function() {FB.init({appId: '187725799275', status: true, cookie: true, xfbml: true});};(function() {var e = document.createElement('script'); e.async = true;e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);}());";
	window.eval(funcFB);
	commentFB = 0;
}
function setForOas(){}

