/* CBN LONDRINA */

//tamanho da fonte
function fontSize(action, container) {
	container = typeof(container) != 'undefined' ? container : "" 
	baseSize = parseInt($(container).css("font-size"))
 
	$els = $(container)
 
	$els.each(function(){
		$fs = parseInt($(this).css("font-size"))
		if(action=="plus" && baseSize<15) $fs+=1
		else if(action=="minus" && baseSize>11) $fs-=1
		$(this).css("font-size", $fs)
	})
}

function OpenCBNAoVivo() {
    var openWindow = window.open('http://streaming.fabricahost.com.br/APKBarra/player.php?cliente=cbnlondrina&radio=cbnlondrina&player=audio', 'Live', 'width=320, height=205');
    if (openWindow == null) {
        alert("Desabilite o bloqueador de pop-up para ouvir a CBN.");
    }
}

function CallCBNExpress() {
    window.location.href = "/Institucional/FaleConosco?s=4";    
}

jQuery(function() {
	Project._init();
});

var Project = {
	/**
	* @author			Flavia Gomes <flavinhaaw@gmail.com>
	* @description		Chama todas as funções e debuga
	*/
	_init: function () {
		try {
			Project._dropDown();
			Project._navMenu();
			Project._fecharComentario();
			Project._abrirComentario();
			Project._lastChilds();
			Project._firstChilds();
			Project._rollOver();
		} catch (e) {
			//console.log('Error: ' + e.description);
		}
	},

	//dropdown header
	_dropDown: function () {
		$('a.abrirdrop').click(function () {
			$('.dropdown_aberto').slideDown();
			$('.dropdown').css('background', 'url(/Content/Imagens/bg/box_dropdown_header_on.png) no-repeat');
			$(this).hide();
			$('a.fechardrop').show();
		});
		$('a.fechardrop').click(function () {
			$('.dropdown_aberto').slideUp();
			$('.dropdown').css('background', 'url(/Content/Imagens/bg/dropdown.png) no-repeat');
			$(this).hide();
			$('a.abrirdrop').show();
		});
	},

	//nav menu
	_navMenu: function () {
		$('div.titulo_menu a').toggle(function () {
			$(this).parent().find('span').removeClass('bt_menos');
			$(this).parent().find('span').addClass('bt_mais');
			$(this).parent().next().slideUp('fast');
		}, function () {
			$(this).parent().find('span').removeClass('bt_mais');
			$(this).parent().find('span').addClass('bt_menos');
			$(this).parent().next().slideDown('fast');
		});
	},

	//fechar comentario
	_fecharComentario: function () {
		$('a.bt_fechar').click(function () {
			$('div.enviar_comentario').hide();
			return false;
		});
	},

	//abrir comentario
	_abrirComentario: function () {
		$('a.ger_comentario').click(function () {
			if ($(this).hasClass('scroll')) {
				$('html, body').animate({scrollTop: $('#wrapper').height()}, 800);
				$('div.enviar_comentario').show();
			} else {
				$('div.enviar_comentario').toggle();
			}
			return false;
		});
	},

	//bugIe
	_ieBug: function () {
		$('#abrir_comentar').click(function () {
			//$('#footer').css('bottom', '-320px');
			return false;
		});
	},
	_ieBugFecha: function () {
		$('a.bt_fechar').click(function () {
			//$('#footer').css('bottom', '0');
			return false;
		});
	},

	//last-childs
	_lastChilds: function () {
		var elementos = ['.lc li', 'div.mais_noticias_londrina ul', 'div.mais_noticias_londrina ul li'];

		for (var i = 0; i < elementos.length; i++) {
			$(elementos[i] + ':last-child').addClass('last-child');
		}
	},
	
	//first-childs
	_firstChilds: function () {
		$('ul#resultado_busca_tags li:first-child a').addClass('tag');
	},

	//rollover
	_rollOver: function () {
		var elementos = [
			'div.not_principal',
			'ul.demais_noticias li h2',
			'div.mais_noticias_londrina ul li',
			'ul.resultado_busca li'
		];

		for (var i = 0; i < elementos.length; i++) {
			$(elementos[i]).hover(
				function () {
					$(this).children('#rollover').show();
					$(this).css('z-index', '1');
				},
				function () {
					$(this).children('#rollover').hide();
					$(this).css('z-index', 'auto');
				}
			);
		}

		if ($.browser.msie) $('div.mais_noticias_londrina ul li').find('#rollover').addClass('iefix');
	}
}
