window.addEvent('domready', function(){
	//SET BOTTOM POSITION
	setBottomBg();
    //IE6 VALIDATOR
    if (Browser.Engine.trident && Browser.Engine.version == 4) {
        $('logo').setStyle('background', 'url(http://www.statictvazteca.com/plantillas/tortuga/images/logo.jpg)');
        var a3 = $$('a.liga3punto0');
        if (a3) {
            a3.each(function(item){
                item.setStyle('background-image', 'none');
                item.setStyle('background-color', '#252728');
            })
        }
        if ($('findLeft') && $('findRight')) {
            $('findLeft').src = "http://www.statictvazteca.com/plantillas/tortuga/images/find-left.jpg";
            $('findRight').src = "http://www.statictvazteca.com/plantillas/tortuga/images/find-right.jpg";
        }
        var botonera = $$('a.botonera-a');
        if (botonera) {
            botonera.each(function(item){
                item.setStyle('background-image', 'none');
                var spanBg = item.getElement('span');
                spanBg.setStyle('background-image', 'none');
                spanBg.removeClass('botonera-img');
                spanBg.setStyle('width', '30px');
            });
        }
        var btnCool = $$('a.botonCool');
        if (btnCool) {
            btnCool.each(function(item){
                item.setStyle('background-image', 'none');
            });
        }
		var nvoCont = $$('div.star-new');
        if (nvoCont) {
            nvoCont.each(function(item){
                item.setStyle('background-image', 'url(http://desa.tvazteca.com/plantillas/tortuga/images/star-new-ie.gif)');
			    item.setStyle('width', '21px');
				item.setStyle('height', '21px');
            });
        }
    }
	//ROLLOVERS
	var rols = $(document.body).getElements('a.arollover');
	rols.each(function(item){
		var rolParent = item.getParent();
		item.addEvent('mouseenter',function(e){
			e.stop();
			rolParent.addClass('rollOn');
		});
		item.addEvent('mouseleave',function(e){
			e.stop();
			rolParent.removeClass('rollOn');
		});
	});
	//INPUT FIND
	var inputFind = $(document.body).getElement('input#inputFind');
	if(inputFind){
		inputFind.addEvent('focus',function(e){
			e.stop();
			this.value = '';
		});
	}
	//SHUT LIGHTS
	var shutLights = $('shutLights');
	if(shutLights){
		shutLights.addEvent('click',function(e){
			e.stop();
			toggleLight();
			this.blur();
		});
	}
	//SWITCH PLAYER
	var switcher = $('switchPlayer');
	if(switcher){
		$('switchPlayer').addEvent('click',function(e){
			e.stop();
			this.blur();
			switchFlash();
			if($('switchPlayer').hasClass('switch2')){
				$('switchPlayer').removeClass('switch2');
			}else{
				$('switchPlayer').addClass('switch2');
			}
		});	
	}
	//COMBO FIND
	var acbocat = $('acbocat');
	var acboord = $('acboord');
	var divcbocat = $('divcbocat');
	var divcboord = $('divcboord');
	if(acbocat){
		acbocat.addEvent('click',function(e){
			e.stop();
			divcbocat.setStyle('display','block');
			divcboord.setStyle('display','none');
			divcbocat.fade('show');
			this.blur();
		});
		acboord.addEvent('click',function(e){
			e.stop();
			divcboord.setStyle('display','block');
			divcbocat.setStyle('display','none');
			divcboord.fade('show');
			this.blur();
		});
		divcbocat.addEvent('mouseleave',function(e){
			e.stop();
			this.fade(0);
		});
		divcboord.addEvent('mouseleave',function(e){
			e.stop();
			this.fade(0);
		});
	}
	$(document.body).addClass('fondo-pagina');
});
var bodyH;
var bgTimer = null;
var liveTimer = null;
//BOTON COOL IE6 FIX
var isIE = navigator.appName;b_version=navigator.appVersion;b_version=parseFloat(b_version);
if(isIE == 'Microsoft Internet Explorer' && b_version == 4){document.write('<style type="text/css">.botonCool,.botonCool:link,.botonCool:visited{background-image:none !important;}.chico.botonCool{font-size:10px}.mediano.botonCool{font-size:11px}.grande.botonCool{font-size:12px}</style>');}
//FUNCTIONS
function toggleLight(){
	var overlay = $('divOverlay');
	overlay.setStyle('display','block');
	overlay.fade('hide');
	overlay.tween('opacity',0, 0.8);
	overlay.addEvent('click',function(e){
		e.stop();
		overlay.setStyle('display','none');
	});
	window.addEvent('keydown',function(evt){
		if(evt.key == 'esc'){
			overlay.setStyle('display','none');
		}
	});
}
function switchFlash(){
	var fM = $('fullModule');
	if (fM.getStyle('width') == '630px') {
		fM.setStyle('width', '950px');
		if($('videoComponent0Container'))window.VideoComponent.prototype.resizeSWFObject('videoComponent0', 950, 619);
	}
	else {
		fM.setStyle('width', '630px');
		if($('videoComponent0Container'))window.VideoComponent.prototype.resizeSWFObject('videoComponent0',630,410);
	}
}
function activateLive(){
	if(liveTimer != null)liveTimer = $clear(liveTimer);
	var livebtn = $(document.body).getElement('span.ico-envivo');
	if(!$defined(livebtn))var livebtn = $(document.body).getElement('span.ico-envivoOn');
	if(livebtn.hasClass('ico-envivo'))livebtn.removeClass('ico-envivo');
	livebtn.addClass('ico-envivoOn');
	livebtn = livebtn.getParent();
	if(livebtn.hasClass('botonera-a'))livebtn.removeClass('botonera-a');
	livebtn.addClass('botonera-alive');
	livebtn.highlight('#D3271E');
	liveTimer = activateLive.delay(1500);
}
function setBottomBg(){
	if(bgTimer != null)bgTimer = $clear(bgTimer);
	var barHeight = $('bn_frame').getStyle('height').toInt();
	var topAlert = barHeight + 1;
	if($('alto-total')){
		var tot = $('alto-total').getStyle('height').toInt();
		tot = tot + barHeight - 400;
		tot = tot + 'px';
		$('bntopalert').setStyle('top', topAlert + 'px');
		$('bgBottom').setStyle('top', tot);
		$('bgBottom').setStyle('display', 'block');
		bgTimer = setBottomBg.delay(800);	
	}
	$(document.body).setStyle('background-position','50% ' + barHeight + 'px');
}