$().ready(function() {
				
	$('a.inframe').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana').before(e);
				$('#envivo').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#envivo').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e);
				
				
				//$('#otraVentana').show(50);
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#envivo').next('iframe').slideDown(500);
				$('#envivo').attr('title','Hide');
				
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				$('#link_envivo').html(e);
				e.html('En Vivo');
				$('#otraVentana').hide(50);
				e.data('state', 'closed');
				$('#envivo').next('iframe').slideUp(500);
				$('#envivo').attr('title','Show');
			} 
			return false;
		});
	
	$('a.inframe_superior').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana').before(e);
				
				$('#envivo').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#envivo').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#envivo').next('iframe').slideDown(500);
				$('#envivo').attr('title','Hide');
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				//$('#link_envivo').html(e);
				
				e.html('<img src="img_stat/mundial/envivo_click_aqui.jpg" />');
				$('#header_buscar').html(e);
				
				$('#otraVentana').hide(50);
				e.data('state', 'closed');
				$('#envivo').next('iframe').slideUp(500);
				$('#envivo').attr('title','Show');
			} 
			return false;
		});
	
	$('a.inframe_calendario_otro').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana_calendario').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana_calendario').before(e);
				$('#calendario').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#calendario').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e);
				
				
				//$('#otraVentana').show(50);
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana_calendario').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana_calendario').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#calendario').next('iframe').slideDown(500);
				$('#calendario').attr('title','Hide');
				
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				//$('#link_calendario').html(e);
				e.html('>>Ver calendario completo');
				$('#ver_calendario_interior').html(e);
				
				$('#otraVentana_calendario').hide(50);
				e.data('state', 'closed');
				$('#calendario').next('iframe').slideUp(500);
				$('#calendario').attr('title','Show');
			} 
			return false;
		});
	
	$('a.inframe_calendario').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana_calendario').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana_calendario').before(e);
				$('#calendario').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#calendario').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e);
				
				
				//$('#otraVentana').show(50);
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana_calendario').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana_calendario').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#calendario').next('iframe').slideDown(500);
				$('#calendario').attr('title','Hide');
				
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				$('#link_calendario').html(e);
				e.html('Calendario');
				$('#otraVentana_calendario').hide(50);
				e.data('state', 'closed');
				$('#calendario').next('iframe').slideUp(500);
				$('#calendario').attr('title','Show');
			} 
			return false;
		});	
	
	$('a.inframe_estadisticas').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana_estadisticas').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana_estadisticas').before(e);
				$('#estadisticas').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#estadisticas').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e);
				
				
				//$('#otraVentana').show(50);
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana_estadisticas').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana_estadisticas').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#estadisticas').next('iframe').slideDown(500);
				$('#estadisticas').attr('title','Hide');
				
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				$('#link_estadisticas').html(e);
				e.html('Estadisticas');
				$('#otraVentana_estadisticas').hide(50);
				e.data('state', 'closed');
				$('#estadisticas').next('iframe').slideUp(500);
				$('#estadisticas').attr('title','Show');
			} 
			return false;
		});
	
	$('a.inframe_clasificacion').click(function() {
			var e=$(this);
			if (!e.data('state')) {	//if state is undefined
		
				e.data('state','open'); //set the state to 'open'
				e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">');
				
				$('#menu').hide(1000);
				$('#otraVentana_clasificacion').show(500);
			
				// Extract the frame height from the rel attribute
				var frameHeight=e.attr('rel');
				var pat1 = new RegExp('height:');
				pat1.test(frameHeight);
				frameHeight=RegExp.rightContext;
				var pat2 = new RegExp('px');
				pat2.test(frameHeight);
				frameHeight = RegExp.leftContext;
				if ( !frameHeight || (Math.ceil(frameHeight) != Math.floor(frameHeight)) ) {
					//if it's null or not an integer
					frameHeight = '550'; //default frame height, in case none is specified
				};
				frameHeight += 'px';
			
				frameWidth = '940px';
			
				// Insert the iframe just after the link
				//e.after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; display:none;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				//var iframe=e.next('iframe');
				
				// Insert the iframe en el div correspondiente
				$('#otraVentana_clasificacion').before(e);
				$('#clasificacion').after('<iframe class="inframe" style="width:'+frameWidth+'; height:'+frameHeight+'; display:none; margin-left:18px" src=' + e.attr('href') + ' frameborder="0" ></iframe>');
				var iframe=$('#clasificacion').next('iframe');
				

				// Insert the "loading..." text
				//iframe.before(e);
				
				
				//$('#otraVentana').show(50);
				//iframe.before($('#otraVentana'));
				iframe.before(' <small class="quiet inframe-loading"> Cargando...</small>')
				iframe.load(function(){	//once content was loaded
					iframe.slideDown(500);	//slide it down
					iframe.prev('small').remove();	//remove the 'loading...'
				});
				e.attr('title','Hide');	//set the link title to 'Hide'
			} 
			else if(e.data('state')=='closed') { //if state is 'closed'
				$('#otraVentana_clasificacion').before(e.html('<img width="80" src="img_stat/mundial/bt_cerrar.jpg">'));
				$('#otraVentana_clasificacion').show(500);
				$('#menu').hide(1000);
				//e.html('Cerrar');
				e.data('state', 'open');
				$('#clasificacion').next('iframe').slideDown(500);
				$('#clasificacion').attr('title','Hide');
				
			}
			else if(e.data('state')=='open') { //if state is 'open'
				$('#menu').show(1000);
				$('#link_clasificacion').html(e);
				e.html('Clasificacion');
				$('#otraVentana_clasificacion').hide(50);
				e.data('state', 'closed');
				$('#clasificacion').next('iframe').slideUp(500);
				$('#clasificacion').attr('title','Show');
			} 
			return false;
		});

	
	});
