/**
 * O objeto slider, que cuida do player de apresentação 
 * das notícias relacionadas
 *
 * @author youzoom js departments
 * @version 1.01
 */
function Slider (sets, elemts)
{
	var settings =
	{
		ITEM_HEIGTH: 78,
		nPERPAGE: 4,
		speed: 700
	};
	
	var elementos =
	{
		container: $('#yzoom-widget-slider'),
		palco: null,
		itens: null,
		btUp: null, // $('#yzoom-slider-btup a'),
		btDown: null,// $('#yzoom-slider-down a'),
		lista: null, // $('#yzoom-slider-lista'),
		top: 0,
		bottom: 3
	};
	
	settings = $.extend(settings, sets);
	elementos = $.extend(elementos, elemts);
	
	var toup, offset, dif, $this, titulo, texto, autor, h, h2, topv;
	
	/**
	 * Método responsavel ajustar todos os itens  da lista do slider.
	 * Caso o conteudo do item possua altura maior que a altura permitida(settings.ITEM_HEIGTH),
	 * sua fonte, e a altura da linha será decrementada até que se adeque.
	 */
	function fix ()
	{
		$this = $(this);
		titulo = $this.children('h3');
		autor = $this.children('small');
		
		h = parseInt(titulo.height() + autor.height() + 10);
		
		
		if (h > settings.ITEM_HEIGTH)
		{
			var fontSize, lHeight;
			
			while (h > settings.ITEM_HEIGTH)
			{
				lHeight = yzoom.tools.getIntByPixels(titulo.css('line-height'));
				fontSize = yzoom.tools.getIntByPixels(titulo.css('font-size'));
				fontSize--;
				
				titulo.css('font-size', fontSize + 'px');
				titulo.css('line-height', lHeight + 'px');
				
				h = parseInt(titulo.height() + autor.height() + 10);
			}
		}
		
		dif = (settings.ITEM_HEIGTH - h) / 3;
		
		titulo.css('margin-top', dif + 'px');
		
		return;
	}
	
	/**
	 * Responsável rolar a lista para baixo
	 */
	function down ()
	{
		if (elementos.top == 0) return false;
		
		elementos.top = parseInt(elementos.top - settings.nPERPAGE);

		if (elementos.top < 0) elementos.top = 0;
		
		elementos.bottom = parseInt(elementos.top + settings.nPERPAGE);
		
		toup = parseInt(settings.ITEM_HEIGTH * elementos.top);
		
		if (toup == 0)
			topv = "0px";
		else
			topv = "-" + toup + "px";

		elementos.lista.animate({top: '-' + parseInt(toup+2) + 'px'}, settings.speed);
		elementos.lista.animate({top: topv}, 20);

		return false;
	}
	
	/**
	 * Responsável rolar a lista para cima
	 */
	function up ()
	{
		if (elementos.bottom == elementos.itens.length) return false;
		
		elementos.bottom = parseInt(elementos.bottom + settings.nPERPAGE);
		dif = parseInt(elementos.itens.length - elementos.bottom);
	
		if (dif < 0) elementos.bottom = parseInt(elementos.bottom + dif);

		elementos.top = elementos.bottom - settings.nPERPAGE;
		
		toup = parseInt(settings.ITEM_HEIGTH * elementos.top);
		
		if (toup == 0)
			topv = "0px";
		else
			topv = "-" + toup + "px";
		
		elementos.lista.animate({top: '-' + parseInt(toup+2) + 'px'}, settings.speed);
		elementos.lista.animate({top: topv}, 20);
			
		return false;
	}
	
	function init ()
	{
		elementos.btUp = elementos.container.find('#yzoom-slider-btup > a');
		elementos.btDown = elementos.container.find('#yzoom-slider-btdown > a');
		elementos.lista = elementos.container.find('#yzoom-slider-lista');
		elementos.itens = elementos.lista.children('li');
		elementos.palco = elementos.container.find('#yzoom-slider-palco');
		
		elementos.bottom = settings.nPERPAGE - 1;
		elementos.palco.css('height', settings.nPERPAGE * settings.ITEM_HEIGTH + 'px');
		
		// elementos.itens.each(fix);

		elementos.btUp.click(down);
		elementos.btDown.click(up);
		
		// elementos.lista.animate({top: '-77px'});
	}

	init();
	
	return this;
}

function initSlider3 ()
{
	var settings =
	{
		nPERPAGE: 3
	};
	
	yzoom.widget.Slider(settings);
}

/**
 * -> O PLAYER DA PÁGINA INICIAL:
 * 
 * A estrutura padrão do player é:
 *
 *	<ul id="lista-player" class="lista-limpa">
 *      <li><a title="$TITULO"><img src="IMAGEMSRC" width="935" height="164" alt="" title="" /></a></li>
 *  </ul>
 *
 * Onde:
 *	$TITULO representa o titulo do item, este titulo será exibido no letrero quando seu item for exibido.
 *	
 * Observações: É necessário que a "lista-player" seja construida no lado servidor,
 * o controlador do slide (botão 1, 2, etc), será construido no lado cliente pelo script, não
 * havendo a necessidade de se preucupar com o elemento:
 *
 *	<ul id="lista-controle-player" class="lista-limpa">
 *   	<li>&nbsp;</li>
 *  </ul>
 * 
 * O slide, suportará no maximo oito elementos, e o letrero exibirá no máximo 86 caracteres. Havendo mais que
 * 86 caracteres, o será exibido apenas 83 caracteres mais reticências. Caso o usuário possua javascript desabilitado, 
 * não haverá dano na estrutura da página, os slides serão renderizados, porém, com exeção do 1° slide, 
 * os demais slides não serão exibidos, graças as configurações definidas no documento CSS.
 */
 
function Player ()
{
	var player =
	{
		ITEM_WIDTH: 940,
		INTERVAL: 5000,
		LETRERO_MAX_LENGTH: 86,
		last: 1,
		current: 1,
		timeout: null,
		container: $('#container-player'),
		stage: $('#palco-player'),
		lista: $('#lista-player'),
		itens: $('#lista-player').children('li'),
		letrero: $('#legenda'),
		controle: $('#player-paginas'),
		btForward: $('#player-bt-forward'),
		btBackward: $('#player-bt-back'),
		itensControle: null
	};
	
	if (!player.itens.length) 
	{
		player.container.remove();
		return false; 
	}
	
	// player.itens.eq(0).find('img').ready(function () { player.loader.remove(); });
	
	$(document).ready(function ()
	{
		player.letrero.show();
		buildControlador();
		setPlayer();
				
		return;
	});
	
	
	function setPlayer ()
	{
		// Caso houver apenas um slide, adota uma postura diferente,
		// não configura o player, e exibe o titulo do item no letrero do player
		if (player.itens.length == 1)
		{
			player.letrero.text(player.itens.eq(0).find('img').attr('alt'));
			player.btForward.hide();
			player.btBackward.hide();
			
			return false;
		}
	
		player.lista.css('width', parseInt(player.itens.length * player.ITEM_WIDTH) + 'px');
		player.itensControle.click(handleClick);
		
		player.btForward.click(showNext);
		player.btBackward.click(showPrev);
		
		show(1);

		return;
	}
	
	function buildControlador ()
	{
		// Caso não haja slides, não construirá o controlador,
		// mas exibirá o titulo do item unico no letrero
		if (player.itens.length == 1)
		{
			player.letrero.text(player.itens.eq(0).find('img').attr('alt'));
			return false;
		}
		
		var html, title, i;
		
		html = "";
		
		for (var i=0; i<player.itens.length; i++)
		{
			title = player.itens.eq(i).find('img').attr('alt');
			title = getTituloParaLetrero(title);
			
			html += '<a class="pag wgt" rel="'+parseInt(i+1)+'" title="'+ title +'"></a>';
		}
		
		
		player.controle.html(html);
		player.itensControle = player.controle.children('a');
		
		player.controle.css('width', parseInt(i * (player.itensControle.width() + 3) + 3) + 'px');
		
		return;
	}

	function handleClick ()
	{
		var i, $this;
		
		$this = $(this);
		i = parseInt($this.attr('rel'));
		
		show(i);
		
		return false;
	}
	
	function showNext ()
	{
		unsetTimeOut();
		
		if (player.current == player.itens.length)
		{
			player.current = 1;
		}
		else
		{
			player.current++;
		}
		
		show(player.current);	
		
		return false;
	}
	
	function showPrev ()
	{
		unsetTimeOut();
		
		if (player.current == 1)
		{
			player.current = player.itens.length;
		}
		else
		{
			player.current--;
		}
		
		show(player.current);	
		
		return false;
	}
	
	function show (i)
	{
		unsetTimeOut();
		bloquearBts();
		
		var left;
		var item;
	
		player.current = i;
		i--;
		
		left = parseInt(player.ITEM_WIDTH * i);
		
		player.itensControle.removeClass('ativa');
		item = player.itensControle.eq(i);
		
		item.addClass('ativa');
		player.letrero.text(item.attr('title'));

		// player.lista.animate({left: '-' + Math.abs(left+4) + 'px'}, 300);
		player.lista.animate({left: '-' + Math.abs(left) + 'px'}, 300, liberarBts);

		setTimeOut();
		
		return;
	}
	
	function bloquearBts ()
	{
		player.btForward.unbind('click');
		player.btBackward.unbind('click');
	}
	
	function liberarBts ()
	{
		player.btForward.click(showNext);
		player.btBackward.click(showPrev);
	}
	
	function setTimeOut ()
	{
		player.timeout = setTimeout(showNext, player.INTERVAL);
		return;
	}
	
	function unsetTimeOut ()
	{
		clearTimeout(player.timeout);
		return;
	}
	
	function getTituloParaLetrero (str)
	{
		return yzoom.tools.limitarTexto(str, player.LETRERO_MAX_LENGTH);
	}
	
	return this;
}


/**
 * Quando o input portador do id informado estiver em foco, seu conteudo padrão será escondido,
 * caso o foco mude e o elemento não conter informação, o valor padrão retornará a se exibido.
 *
 * @param id ID do elemento
 */
function frmSetDefaultValue (id)
{
	var elemento = document.getElementById(id);
	elemento.title = jQuery.trim(elemento.value);
	
	$(elemento).blur(function() {
		
		if(jQuery.trim(this.value) == "") {
			this.value = this.title;	
		}
	});
	
	$(elemento).focus(function() {
		
		if(jQuery.trim(this.value) == this.title) {
			this.value = "";	
		}
	});
}

function limitarTexto (str, tam_max)
{
	if (str.length > tam_max)
	{
		str = str.substring(0, tam_max - 3);
		str += "...";
	}

	return str;
}

/**
 * Recebe um valor em pixels e extrai a parte inteira.
 * Exemplo:
 *  getIntByPixels("25px") retornará 25.
 *
 * @param string val Valor em pixel. Ex: 25px
 * @return int Valor em inteiro.
 */
function getIntByPixels (val)
{
	return parseInt( val.substring(0, val.lastIndexOf('p')) );
}


function programacaoController ()
{
	// var boxes = $(".mais-informacao");
	var itens = $('.lst-programacao-grande li');
	var container = $("#programacao-box");
	var current = $('.programa-info .ativa');
	var box;
	
	itens.find('.link-vejamais').click(handleClick);
	itens.find('.titulo-link a').click(handleClick);
	
	if ((itens.length * itens.eq(0).height() - 25) > container.height())
	{
		container.css('height', 'auto');
	}
	
	function handleClick ()
	{
		if ($.browser.msie) current.hide();
		else current.slideUp();
		
		box = $(this).parents('.programa-info').children('div.mais-informacao');
		current = box;

		if ($.browser.msie) box.show();
		else box.slideDown();
		
	}
}

/**
 * O "Namespace" yzoom.
 */
var yzoom = new function ()
{
	var private =
	{
		callback: new Array(),
		main: main
	};

	var public = 
	{
		tools:
		{
			setDefaultValue: frmSetDefaultValue,
			getIntByPixels: getIntByPixels,
			limitarTexto: limitarTexto,
			loadAndCall: loadAndCall
		},
		widget:
		{
			programacaoController: programacaoController,
			Player: Player,
			Slider: Slider,
			intSliderImgRelacionada: initSlider3,
			initSlider3: initSlider3
		}
	};
	
	/**
	 * Recebe uma referencia para uma função, e a cadastra na fila 
	 * portaleducacao.callback, que será executada após o carregamento 
	 * da página pela função método main.
	 *
	 * @param fn Referencia à função que sera chamada.
	 */
	function loadAndCall (fn)
	{
		private.callback[private.callback.length] = fn;
	}
	
	function main ()
	{
		$('.lb').lightBox();
		
		/**
		 * Faz as chamadas de todas as funções cadastradas pelo método
		 * loadAndCall
		 */
		var fn;
		
		for (var i=0; i<private.callback.length; i++)// i<yzoom.callback.length; i++)
		{
			fn = private.callback[i];
			fn();
		}
	}
	
	$(document).ready(private.main);
	
	return public;
}


/**
 * Método para enviar NewsLetter
 */
function cadastraNewsletter() {

    var p_acao = "adicionar";
    var p_mail_nome = $("#ipt-nome").val();
    //var p_mail_nome = $("#nomeNews").val();
    var p_mail_email = $("#ipt-email").val();
    
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(p_mail_email.length == 0 ){
        showMessageModalBox("O campo e-mail não pode estar vazio.");

    }else if(er.test(p_mail_email)==false){
        showMessageModalBox("Informe um e-mail válido");

    }else {
        var ajaxURL = '/_ajax/ger_mailing.php';

        $.post(ajaxURL, {
            acao: p_acao,
            mail_nome: p_mail_nome,
            mail_email: p_mail_email
        }, function(jsonReturn) {

            if(jsonReturn.status == "sucesso") {

                $("#nomeNews").val("");
                $("#emailNews").val("");

                showMessageModalBox("Seu e-mail foi cadastrado com sucesso.");

            } else {

                if(jsonReturn.msg=='E-mail já cadastrado'){
                    $("#nomeNews").val("");
                    $("#emailNews").val("");
                    showMessageModalBox("E-mail cadastrado com sucesso.");
                }
                else
                    showMessageModalBox("Erro ao cadastrar seu e-mail");
            }

        }, "json");
    }
}

function showMessageModalBox(html) {

    $.fn.colorbox({
        html:'<div style="background: #FFF; height: 140px; padding: 15px 0 0 20px; overflow: hidden; color:#000;" class="verde"><h2 class="have-color">Newsletter TV Campo Grande</h2><br><br><p>'+html+'<p></div>',
        width:410,
        height:225,
        open:true,
        iframe:false,
        close: "fecharNews"
    });
}

// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(b,gb){var v="none",t="click",N="LoadedContent",d=false,x="resize.",o="y",u="auto",f=true,M="nofollow",q="on",n="x";function e(a,c){a=a?' id="'+k+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===n?m.width():m.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function Q(c){c=b.isFunction(c)?c.call(h):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function cb(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!==q)a[c]=a[c].call(h);a.rel=a.rel||h.rel||M;a.href=a.href||b(h).attr("href");a.title=a.title||h.title}function db(d){h=d;a=b.extend({},b(h).data(r));cb();if(a.rel!==M){i=b("."+H).filter(function(){return (b(this).data(r).rel||this.rel)===a.rel});g=i.index(h);if(g===-1){i=i.add(h);g=i.length-1}}else{i=b(h);g=0}if(!w){w=F=f;R=h;try{R.blur()}catch(e){}b.event.trigger(hb);a.onOpen&&a.onOpen.call(h);y.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":u}).show();a.w=p(a.initialWidth,n);a.h=p(a.initialHeight,o);c.position(0);S&&m.bind(x+O+" scroll."+O,function(){y.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll."+O)}T.add(I).add(J).add(z).add(U).hide();V.html(a.close).show();c.slideshow();c.load()}var eb={transition:"elastic",speed:300,width:d,initialWidth:"600",innerWidth:d,maxWidth:d,height:d,initialHeight:"450",innerHeight:d,maxHeight:d,scalePhotos:f,scrolling:f,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:f,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,loop:f,slideshow:d,slideshowAuto:f,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,overlayClose:f,escKey:f,arrowKey:f},r="colorbox",k="cbox",hb=k+"_open",P=k+"_load",W=k+"_complete",X=k+"_cleanup",fb=k+"_closed",G=b.browser.msie&&!b.support.opacity,S=G&&b.browser.version<7,O=k+"_IE6",y,j,E,s,Y,Z,ab,bb,i,m,l,K,L,U,T,z,J,I,V,C,D,A,B,h,R,g,a,w,F,c,H=k+"Element";c=b.fn[r]=b[r]=function(c,d){var a=this;if(!a[0]&&a.selector)return a;c=c||{};if(d)c.onComplete=d;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=f}a.each(function(){b(this).data(r,b.extend({},b(this).data(r)||eb,c)).addClass(H)});c.open&&db(a[0]);return a};c.init=function(){var h="hover";m=b(gb);j=e().attr({id:r,"class":G?k+"IE":""});y=e("Overlay",S?"position:absolute":"").hide();E=e("Wrapper");s=e("Content").append(l=e(N,"width:0; height:0"),L=e("LoadingOverlay").add(e("LoadingGraphic")),U=e("Title"),T=e("Current"),J=e("Next"),I=e("Previous"),z=e("Slideshow"),V=e("Close"));E.append(e().append(e("TopLeft"),Y=e("TopCenter"),e("TopRight")),e().append(Z=e("MiddleLeft"),s,ab=e("MiddleRight")),e().append(e("BottomLeft"),bb=e("BottomCenter"),e("BottomRight"))).children().children().css({"float":"left"});K=e(d,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(y,j.append(E,K));s.children().hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)}).addClass(h);C=Y.height()+bb.height()+s.outerHeight(f)-s.height();D=Z.width()+ab.width()+s.outerWidth(f)-s.width();A=l.outerHeight(f);B=l.outerWidth(f);j.css({"padding-bottom":C,"padding-right":D}).hide();J.click(c.next);I.click(c.prev);V.click(c.close);s.children().removeClass(h);b("."+H).live(t,function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return f;else{db(this);return d}});y.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(w&&a.arrowKey&&!F&&i[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();I.click()}else if(b.keyCode===39&&(g<i.length-1||a.loop)){b.preventDefault();J.click()}})};c.remove=function(){j.add(y).remove();b("."+H).die(t).removeData(r).removeClass(H)};c.position=function(f,b){function c(a){Y[0].style.width=bb[0].style.width=s[0].style.width=a.style.width;L[0].style.height=L[1].style.height=s[0].style.height=Z[0].style.height=ab[0].style.height=a.style.height}var e,h=Math.max(m.height()-a.h-A-C,0)/2+m.scrollTop(),g=Math.max(m.width()-a.w-B-D,0)/2+m.scrollLeft();e=j.width()===a.w+B&&j.height()===a.h+A?0:f;E[0].style.width=E[0].style.height="9999px";j.dequeue().animate({width:a.w+B,height:a.h+A,top:h,left:g},{duration:e,complete:function(){c(this);F=d;E[0].style.width=a.w+B+D+"px";E[0].style.height=a.h+A+C+"px";b&&b()},step:function(){c(this)}})};c.resize=function(b){if(w){b=b||{};if(b.width)a.w=p(b.width,n)-B-D;if(b.innerWidth)a.w=p(b.innerWidth,n);l.css({width:a.w});if(b.height)a.h=p(b.height,o)-A-C;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}l.css({height:a.h});c.position(a.transition===v?0:a.speed)}};c.prep=function(o){var d="hidden";function n(t){var o,q,s,n,d=i.length,e=a.loop;c.position(t,function(){function t(){G&&j[0].style.removeAttribute("filter")}if(w){G&&p&&l.fadeIn(100);a.iframe&&b("<iframe frameborder=0"+(a.scrolling?"":" scrolling='no'")+(G?" allowtransparency='true'":"")+"/>").attr({src:a.href,name:(new Date).getTime()}).appendTo(l);l.show();U.show().html(a.title);if(d>1){T.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d)).show();J[e||g<d-1?"show":"hide"]().html(a.next);I[e||g?"show":"hide"]().html(a.previous);o=g?i[g-1]:i[d-1];s=g<d-1?i[g+1]:i[0];if(a.slideshow){z.show();g===d-1&&!e&&j.is("."+k+"Slideshow_on")&&z.click()}if(a.preloading){n=b(s).data(r).href||s.href;q=b(o).data(r).href||o.href;if(Q(n))b("<img/>")[0].src=n;if(Q(q))b("<img/>")[0].src=q}}L.hide();a.transition==="fade"?j.fadeTo(f,1,function(){t()}):t();m.bind(x+k,function(){c.position(0)});b.event.trigger(W);a.onComplete&&a.onComplete.call(h)}})}if(w){var p,f=a.transition===v?0:a.speed;m.unbind(x+k);l.remove();l=e(N).html(o);l.hide().appendTo(K.show()).css({width:function(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?u:d}).css({height:function(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);K.hide();b("#"+k+"Photo").css({cssFloat:v});S&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==d}).css({visibility:d}).one(X,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(f,0,function(){n(0)}):n(f)}};c.load=function(){var j,d,q,m=c.prep;F=f;h=i[g];a=b.extend({},b(h).data(r));cb();b.event.trigger(P);a.onLoad&&a.onLoad.call(h);a.h=a.height?p(a.height,o)-A-C:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,n)-B-D:a.innerWidth&&p(a.innerWidth,n);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,n)-B-D;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-A-C;a.mh=a.h&&a.h<a.mh?a.h:a.mh}j=a.href;L.show();if(a.inline){e("InlineTemp").hide().insertBefore(b(j)[0]).bind(P+" "+X,function(){b(this).replaceWith(l.children())});m(b(j))}else if(a.iframe)m(" ");else if(a.html)m(a.html);else if(Q(j)){d=new Image;d.onload=function(){var e;d.onload=null;d.id=k+"Photo";b(d).css({margin:u,border:v,display:"block",cssFloat:"left"});if(a.scalePhotos){q=function(){d.height-=d.height*e;d.width-=d.width*e};if(a.mw&&d.width>a.mw){e=(d.width-a.mw)/d.width;q()}if(a.mh&&d.height>a.mh){e=(d.height-a.mh)/d.height;q()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";setTimeout(function(){m(d)},1);i[1]&&(g<i.length-1||a.loop)&&b(d).css({cursor:"pointer"}).click(c.next);if(G)d.style.msInterpolationMode="bicubic"};d.src=j}else e().appendTo(K).load(j,function(c,a,b){m(a==="error"?"Request unsuccessful: "+b.statusText:this)})};c.next=function(){if(!F){g=g<i.length-1?g+1:0;c.load()}};c.prev=function(){if(!F){g=g?g-1:i.length-1;c.load()}};c.slideshow=function(){function f(){z.text(a.slideshowStop).bind(W,function(){d=setTimeout(c.next,a.slideshowSpeed)}).bind(P,function(){clearTimeout(d)}).one(t,function(){e()});j.removeClass(b+"off").addClass(b+q)}var e,d,b=k+"Slideshow_";z.bind(fb,function(){z.unbind();clearTimeout(d);j.removeClass(b+"off "+b+q)});e=function(){clearTimeout(d);z.text(a.slideshowStart).unbind(W+" "+P).one(t,function(){f();d=setTimeout(c.next,a.slideshowSpeed)});j.removeClass(b+q).addClass(b+"off")};if(a.slideshow&&i[1])a.slideshowAuto?f():e()};c.close=function(){if(w){w=d;b.event.trigger(X);a.onCleanup&&a.onCleanup.call(h);m.unbind("."+k+" ."+O);y.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){j.find("iframe").attr("src","about:blank");l.remove();j.add(y).css({opacity:1,cursor:u}).hide();try{R.focus()}catch(c){}setTimeout(function(){b.event.trigger(fb);a.onClosed&&a.onClosed.call(h)},1)})}};c.element=function(){return b(h)};c.settings=eb;b(c.init)})(jQuery,this)


/**
 * Método para enviar NewsLetter
 */
function programacaoDoDia() {

    var item = $("#lista-menu-lateral li");
    var box = $("#programacao-box");
    var primeiro = $("#lista-menu-lateral a.ativo");

    inicializa();
    
    item.children("a").click(function(){

        item.each(function(){
            item.children("a").removeClass("ativo");
            item.children("span").removeClass();
        })

        $(this).addClass("ativo");
        $(this).parent().children("span").addClass("seta-indicadora png");

        var ajaxURL = '/_ajax/ger_programacao.php';
        var data = $(this).attr("rel");

        box.html('<div style="width: 100%; text-align: center; padding-top: 100px; "><img src="/_imagens/loading-ajax.gif"></div>');

        $.post(ajaxURL, {
            progm_data: data
        }, function(jsonReturn) {

            if(jsonReturn.status == "sucesso") {

                box.html(jsonReturn.programacao);
				yzoom.widget.programacaoController();
            } else {

                alert("erro");
            }

        }, "json");

    });

    function inicializa(){

        var ajaxURL = '/_ajax/ger_programacao.php';
        var data = primeiro.attr("rel");

        $.post(ajaxURL, {
            progm_data: data
        }, function(jsonReturn) {

            if(jsonReturn.status == "sucesso") {

                box.html(jsonReturn.programacao);
				yzoom.widget.programacaoController();

            } else {

                alert("erro");
            }

        }, "json");

    }

}









































