$(document).ready(function() {


	// BANNERS DEL HEADER
	if ($('#destacados .destacadosSlides li').length > 1) {
		$('#destacados .destacadosSlides').owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: true,
			autoplayTimeout: 5000,
			autoplaySpeed: 1000,
			dots: false,
			loop: true,
			nav: false,
			animateOut: 'fadeOut',
			items: 1
		});
	} else {
		$('#destacados .destacadosSlides').removeClass("owl-carousel");
	}

	var sWidth;

	function setMobile() {
		$("body").removeClass("d").addClass("m");
	}

	function setDesktop() {
		$("body").removeClass("m").addClass("d");
		$("body").removeClass("show-menu");
	}

	$(window).resize(function() {
		sWidth = $(window).width();
		if (sWidth >= 768) {
			if($("body").hasClass("m")) {
				setDesktop();
			}
		} else {
			if($("body").hasClass("d")) {
				setMobile();
			}
		}
	}).trigger("resize");

	$(".fa-navicon").click(function() {
		$("body").toggleClass("show-menu").removeClass("show-search");
		if ($("body").hasClass("show-menu")) {
			$("#wrapper").bind("click", function() {
				$("body").removeClass("show-menu");
			});
		} else {
			$("#wrapper").unbind("click");
		}
		return false;
	});
	$(".fa-close").click(function(e) { $("body").removeClass("show-menu"); return false; });
	
	// APPENDAROUND (Items que cambian de posicion segun plataforma)
	$(".article-image").appendAround();
	

	// "HOME" -------------------------------------------------
	if ($("body").is("#home")) {

		var owlSlides = $('.galeriaSlides');
		owlSlides.owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: false,
			autoplayTimeout: 8000,
			autoplaySpeed: 1000,
			dots: true,
			loop: true,
			nav: true,
			navText: ['',''],
			items: 1
		});
		
		
        // var tip = $("#tip");

				// $tipVACIO = ""
				// $tipSINMOVERSE = "<a class='placa' href='HomeBanking.aspx' style='opacity: 1; top: 10px;'><span class='high'>IMPORTANTE</span> <span class='logoccc'>CCC</span><em><span>Pagos sin moverse de casa!</span></em></a>";
				// $tipMIFACTURA = "<a class='placa' href='FacturaElectronica.aspx' target='_blank' style='opacity: 1; top: 10px;'><h3 style='padding-top: 0.5em; font-size: 1.6em; line-height: 1.2em;'>MI FACTURA</h3><em><span>Ir a Mi Factura</span></em></a>";
				// $tipCOMOPAGAR = "<a class='placa' href='FormasPago.aspx' target='_blank' style='opacity: 1; top: 10px;'><h3 style='padding-top: 0.5em; font-size: 1.6em; line-height: 1.2em;'>COMO Y DONDE PAGAR</h3> <em><span>Cómo pagar</span></em></a>";
				// $tipWIFIMAXPLUS = "<a class='placa' href='Wifi.aspx' style='opacity: 1; top: 10px;'><span class='logocccwifi'>CCCWIFI.MAX y PLUS</span> <h3 style='margin: 1em 0;'>Máxima<br/>&nbsp;Velocidad</h3> <em><span>Más Info</span></em></a>";
				// $tipPAGOELECTRONICO = "<a class='placa' href='downloads/Formas-Pago-Electronico.pdf' target='_blank' style='opacity: 1; top: 10px;'><h3 style='padding-top: 0.5em; font-size: 1.6em; line-height: 1.2em;'>FORMAS DE PAGO ELECTRONICO</h3> <em><span>Descargar PDF</span></em></a>";
        //$tipHTML2 = "<a class='placa' href='#' style='opacity: 1; top: 10px;'><span class='high'><h2><b>QUEDATE EN CASA</b></h2></span><span class='logoccc'>CCC</span></a>";
				// $tipHTML3 = "<a class='placa' href='ComoTener.aspx' style='opacity: 1; top: 10px;'><span class='high'>Como tener</span> <span class='logoccc'>CCC</span><em><span>Tenga el mejor<br/>&nbsp;servicio hoy</span></em></a>";
				// $tipHTML4 = "<a class='placa' href='http://www.viaccc.com/ComoTener.aspx?SRV=FUT' style='opacity: 1; top: 10px;'><h3>PACK FÚTBOL premium</h3> <span class='high'>Por cable y aereo</span> <h3>Llame al<br/>&nbsp;431-1547</h3> <em><span>Contratalo<br/>&nbsp;ahora</span></em> <span class='high'>Stock limitado!</span></a>";
				// $tipHTML5 = "<a class='placa' href='ComoTener.aspx' style='opacity: 1; top: 10px;'><span class='logocccdigital'>CCCDIGITAL.HD</span> <span class='high'>Por cable y aereo</span> <h3>Llame al<br/>&nbsp;431-1547</h3> <em><span>Contratalo<br/>&nbsp;ahora</span></em> <span class='high'>Stock limitado!</span></a>";
		
		// owlSlides.on('change.owl.carousel', function(event) {
		// 	tip.stop().css({opacity: 0});
		// })

		// owlSlides.on('changed.owl.carousel', function(event) {
		// 	tip.stop().animate({opacity: 0}, "slow", function() {
		// 		tip.css("top","-100px")
		// 	});
		// })
		
		// owlSlides.on('translated.owl.carousel', function(event) {
    // 	switch (event.page.index) {
		// 		case 0:
		// 			tip.html($tipSINMOVERSE).css('opacity', 0);
		// 			break;
		// 		case 1:
		// 			tip.html($tipVACIO).css('opacity', 0);
		// 			break;
		// 		case 2:
		// 			tip.html($tipMIFACTURA).css('opacity', 0);
		// 			break;
		// 		case 3:
		// 			tip.html($tipCOMOPAGAR).css('opacity', 0);
		// 			break;
		// 		case 4:
		// 			tip.html($tipWIFIMAXPLUS).css('opacity', 0);
		// 			break;
		// 		default:
		// 			tip.html($tipVACIO).css('opacity', 0);
		// 	}
		// 	tip.animate({opacity: 1,top: "10px"}, { duration: 1000, easing: 'easeOutBack' });
		// });
		// tip.html($tipSINMOVERSE)
		// .delay(1500).css({"opacity":0,"top":"-100px"}).animate({opacity: 1,top: "10px"}, {duration: 500, easing: 'easeOutBack'});
		
		$(".btn-programacion").appendAround();

		$('#noticias .main').owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: true,
			autoplayTimeout: 1000,
			autoplaySpeed: 1000,
			dots: false,
			loop: true,
			navText: ['',''],
			margin: 10,
			responsive: {
				0: { items: 1 },
				300: { items: 2 },
				600: { items: 3 },
				800: { items: 4 },
				984: { items: 1 }
			}
		});
		
		
		$('.bannerInfo').owlCarousel({
			touchDrag: false,
			mouseDrag: false,
			autoplay: true,
			autoplayHoverPause: false,
			autoplayTimeout: 5000,
			autoplaySpeed: 500,
			animateOut: 'fadeOut',
			dots: false,
			loop: true,
			nav: false,
			items: 1
		});
		

		// ACTIVAR SCROLL DE GRILLA
		$(".scroller").mCustomScrollbar();

		// ACTIVAR TABS
		//activarTabs($('#grilla'));

		getNoticias();

		$('#institucional li a').hover(function () {
			$(this).find(".cont").stop().animate({top: 0},250);
			$(this).find(".preview").stop().animate({opacity: 0},250);
		  },function () {
			$(this).find(".cont").stop().animate({top: "100%"},250);
			$(this).find(".preview").stop().animate({opacity: 1},750);
		  }
		);
 
		$("#noticias .main .img").append("<span class='play'></span>");

		$("#noticias .main a").fancybox({
			'type': 'iframe',
			'scrolling': 'no',
			'padding': 5,
			'margin': 15,
			'autoSize': false,
			'minWidth': 200,
			'minHeight': 300,
			'maxWidth': 800,
			'maxHeight': 900,
			'autoScale': true,
			'autoDimensions': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			beforeLoad : function() {
				this.titulo  = this.element.data('titulo');
				this.copete = this.element.data('copete');
                this.bajada = this.element.data('bajada');
				this.fechaemision = this.element.data('fechaemision');
			},
			afterLoad: function() {
				this.title = "<time>" + this.fechaemision + "</time><h3>" + this.titulo + "</h3><p>" + this.copete + "</p><p>" + this.bajada + "</p>";
			},
			helpers : {
				title: {
					type: 'inside'
				}
			}
		});

	// DIGITAL & DIGITAL HD -------------------------------------------------
	} else if ($("body").is("#digital") || $("body").is("#digitalhd")) {

		var allPanels = $('.accordion > dd').hide();
		var y;

		$('.accordion > dt > a').append("<span class='masInfo'>+ Info</span>").data("open",false)
		.click(function() {
			if (!$(this).data("open")) {
				$(this).parent().next().slideDown(250);
				$(this).data("open",true);
			} else {
				$(this).parent().next().slideUp(250);
				$(this).data("open",false);
			}

			return false;
		}).each(function(index, element) {
			y = (30 * index) + 55;
            $(this).css("background-position", "0 -"+y+"px");
        });

		getNoticias();
		activarDestacados();
		showPlaca();

	// CCC BASICO -------------------------------------------------
	} else if ($("body").is("#basico")) {

		var y;
		$('#basico #contenido .col1 ul li').each(function(index, element) {
			y = (30 * index) + 55;
            $(this).css("background-position", "0 -"+y+"px");
        });

		getNoticias();
		activarDestacados();
		showPlaca();

	// PROGRAMA -------------------------------------------------
	} else if ($("body").is("#programa")) {

		getNoticias();
		activarDestacados();

		// ACTIVAR SCROLL DE GRILLA
		$(".scroller").mCustomScrollbar();

	// ANUNCIE EN CCC -------------------------------------------------
	} else if ($("body").is("#anuncie")) {

		getNoticias();
		activarDestacados();

	// AYUDA ----------------------------------------------------------
	} else if ($("body").is("#ayuda")) {

		getNoticias();
		activarDestacados();

		var y;

		$('h3.accordion-main').append("<span class='masInfo'>+ Info</span>")
		.each(function(index, element) {
			y = (30 * index) + 55;
      $(this).css("background-position", "0 -"+y+"px");
    });

		var faqAccordian;
		var faqSubAccordian;

		var faqNextButton;
		var faqSearchInput;

		$(document).ready(function() {
			faqNextButton = $("#faq_btn_next");
			faqSearchInput = $('#faq_search');
			var faqAccordionInput = $("#faq_accordion");
			var faqSubAccordionInput = $(".faq_subaccordion");

			faqAccordian = faqAccordionInput.accordion({
				heightStyle: "content",
				collapsible: true,
				active: false,
				create: function(event, ui) {
					$('#faq_loading').hide();
					faqAccordionInput.show();
				}
			});

			faqSubAccordian = faqSubAccordionInput.accordion({
				heightStyle: "content",
				collapsible: true,
				active: false
			});
			faqSearchInput.on('change keyup paste click', function() {
				faqSearch();
			});

			faqNextButton.on('click', function() {
				var new_skip_index = parseInt(faqNextButton.attr('data')) + 1;
				faqNextButton.attr('data', new_skip_index);
				faqSearch();
				return false;
			});

		});

		function faqSearch() {
			$('.faq_highlight').contents().unwrap();

			var faq_term = faqSearchInput.val().toLowerCase();
			var accord_num = 0;
			var match_found = false;
			var top_accord_id = 0;
			var last_top_accord_id = 0;
			var title = '';
			var content = '';
			var skip_count = 0;
			var skip_index = parseInt(faqNextButton.attr('data'));

			if (faq_term.length >= 3) {

				$('.faq_subaccordion h3').each(function() {
					var h3 = $(this);

					// strip the icon tag
					title = h3.html().replace(/<[^>]+>/gim, '').toLowerCase();

					if (title.indexOf(faq_term) != -1) {

						top_accord_id = parseInt(h3.parent().attr('id').split("_")[1]);
						if (last_top_accord_id != top_accord_id) {
							last_top_accord_id = top_accord_id;
							accord_num = 0;
						}

						if (skip_index != skip_count) {
							skip_count++;
						} else {

							var regex = new RegExp('(' + faq_term + ')', 'ig');
							h3.html(h3.html().replace(regex, '<span class="faq_highlight">$1</span>'));

							var params = [{
								elem: faqAccordian,
								option: "active",
								optionValue: top_accord_id

							}, {
								elem: h3.parent(),
								option: "active",
								optionValue: accord_num
							}];

							updateAccordion(params);

							match_found = true;
							return false;
						}
					} else {
						top_accord_id = parseInt(h3.parent().attr('id').split("_")[1]);
						if (last_top_accord_id != top_accord_id) {
							last_top_accord_id = top_accord_id;
							accord_num = 0;
						}

						content = h3.parent().find('>p').html().replace(/<[^>]+>/gim, '').toLowerCase();

						if (content.indexOf(faq_term) != -1) {
							if (skip_index != skip_count) {
								skip_count++;
							} else {
								var regex = new RegExp('(' + faq_term + ')', 'ig');
								h3.parent().find('>p').html(content.replace(regex, '<span class="faq_highlight">$1</span>'));
								var params = [{
									elem: faqAccordian,
									option: "active",
									optionValue: top_accord_id
								}, {
									elem: h3.parent(),
									option: "active",
									optionValue: accord_num
								}];

								updateAccordion(params);

								match_found = true;
								return false;
							}
						}
					}

					accord_num = accord_num + 1;
				});
			}

			// No match close both accordions
			if (match_found == false) {

				var params = [{
					elem: faqAccordian,
					option: "active",
					optionValue: false
				}, {
					elem: faqSubAccordian,
					option: "active",
					optionValue: false
				}];

				updateAccordion(params);

				faqNextButton.attr('data', 0);
				faqNextButton.hide();
				faqSearchInput.removeClass("results");
			} else {
				faqNextButton.show();
				faqSearchInput.addClass("results");
			}
		}

		function updateAccordion(params) {

			for (var i = 0; i < params.length; i++) {
				var elem = params[i].elem;
				var option = params[i].option;
				var optionValue = params[i].optionValue;

				elem.accordion("option", option, optionValue);
			}
		}

		// FORMAS DE PAGO ----------------------------------------------------------
	} else if ($("body").is("#pagos")) {

		// TEMPORARIO
		// $.fancybox({
		// 	'width': '100%',
		// 	'maxWidth': 500,
		// 	'maxHeight': 500,
		// 	// 'height': '40%',
		// 	'autoScale': true,
		// 	'transitionIn': 'fade',
		// 	'transitionOut': 'fade',
		// 	'type': 'iframe',
		// 	'href': 'pagos.html',
		// 	'modal': true,
		// });

		getNoticias();
		activarDestacados();

		$('.entidad').append("<span class='suc'>Sucursales</span>").addClass("open").data("open",true)
		.click(function() {
			if (!$(this).data("open")) {
				$(this).data("open",true).addClass("open").next().slideDown();
			} else {
				$(this).data("open",false).removeClass("open").next().slideUp();
			}
			return false;
		});

		$(".entidades li a").click(function() {
			$(this).parent().parent().find("li").removeClass("sel").find(".sombra").remove().end().find(".sombrasel").remove();
			$(this).parent().addClass("sel");
			$(".textoBase .entidad").hide();
			acomodarTabs($(this).parent().index());
			return false;
		});
		
		$(".entidades li a").css("opacity", 0.4);

		function acomodarTabs(order) {
			//$(".entidades .nos").append("<img src='images/tabs-sombra.png' width='100%' height='8' class='sombra'>").find("a").css("opacity",0.3);
			var active = $(".entidades .sel");
			/*if (active.hasClass('btu')) {
				active.append("<img src='images/tabs-selizq.png' width='254' height='78' class='sombrasel'>");
			} else if (active.hasClass('cpa')) {
				active.append("<img src='images/tabs-selder.png' width='242' height='78' class='sombrasel'>");
			} else {
				active.append("<img src='images/tabs-selcen.png' width='254' height='78' class='sombrasel'>");
			}*/
			/*if (order) {
				active.prev().find(".sombra").css("width",238);
			}
			active.find("a").css({"opacity":1,"box-shadow":"none"});*/

			$(".textoBase .table-container").show().not(".textoBase .table-container:eq("+order+")").hide();
			$(".entidades").removeClass("deselected");
		}

		var entidad = parseInt(GetURLParameter('entidad_id'));
		if (!isNaN(entidad)) {
			$(".entidades li:nth-child("+entidad+") a").trigger("click");
		} else {
			$(".entidades").addClass("deselected");
		}

	// WIFI ----------------------------------------------------------
	} else if ($("body").is("#wifi")) {

		var y;

		$('.botones li a').append("<span class='masInfo'>+ Info</span>")
		.each(function(index, element) {
			y = (30 * index) + 55;
            $(this).css("background-position", "0 -"+y+"px");
        });

		getNoticias();
		activarDestacados();
		showPlaca();

	// WIFI INTERNAS ----------------------------------------------------------
	} else if ($("body").is("#wifiPass") || $("body").is("#wifiCondiciones") || $("body").is("#wifietapa")) {

		getNoticias();
		activarDestacados();

		if ($("body").is("#wifietapa")) {
			$('ul.tabs li').matchHeight();
			$('ul.tabs li').not(".disabled").click(function() {
				var tab_id = $(this).attr('data-tab');

				$('ul.tabs li').removeClass('current');
				$('.tab-content').removeClass('current');

				$(this).addClass('current');
				$("#"+tab_id).addClass('current');
				$("#"+tab_id+" .map").html("<iframe src='"+$("#"+tab_id+" .map").data("url")+"'></iframe>");
			})
		}

	// CCCMOVIL ----------------------------------------------------------
	} else if ($("body").is("#cccmovil") || $("body").is("#cccmovilregistro") || $("body").is("#cccmovilCondiciones")) {

		getNoticias();
		activarDestacados();

	// EMPRESA ----------------------------------------------------------
	} else if ($("body").is("#empresa")) {

		getNoticias();
		activarDestacados();

	// HOME BANKING ----------------------------------------------------------
	} else if ($("body").is("#banking")) {

	getNoticias();
	activarDestacados();

	// CONTACTO -------------------------------------------------------
	} else if ($("body").is("#contacto")) {

		getNoticias();
		activarDestacados();
		
		$("#container:not(.contacto-wifi) .box .content").matchHeight();

	// "PROGRAMACION" -------------------------------------------------
	} else if ($("body").is("#programacion")) {

		$("header > .wrap").append("<h2>Programación</h2>");
		$('.tips span').tooltipsy();

	// "NOTICIAS"
	} else if ($("body").is("#noticias")) {
		
		getNoticias();
		activarDestacados();

	// "NOTICIAS DETALLE"
	} else if ($("body").is("#noticiasDetalle")) {
		
		getNoticias();
		activarDestacados();

	// "VIDEO NOTICIAS"
	} else if ($("body").is("#videonoticias")) {
		
		getNoticias();
		activarDestacados();

		$(".main a, a.fancy .img, a.fancy2").append("<span class='play'></span>");

		/*var mood = $('#galeriaScroll ul').moodular({
			auto: false,
			api: true,
			speed: 500
		});

		$('#galeriaScroll a.next').bind('click', function () { mood.next(); return false; });
		$('#galeriaScroll a.prev').bind('click', function () { mood.prev(); return false; });*/

		var lis = $('.destacadas .secundarias li', this);
		for(var i = 0; i < lis.length; i+=3) {
			lis.slice(i, i+3).wrapAll('<div class="pagina"></div>');
		}

		$('.destacadas .secundarias ul').owlCarousel({
			touchDrag: true,
			autoplay: false,
			autoplayHoverPause: true,
			autoplayTimeout: 10000,
			autoplaySpeed: 1000,
			dots: true,
			loop: true,
			nav: true,
			navText: ['',''],
			responsive: {
				0: { items: 1, slideBy: 1, margin: 15, stagePadding: 10 },
				768: { items: 2, slideBy: 2, margin: 15, stagePadding: 10 }
			}
		});
		
		
		$('.ediciones ul').owlCarousel({
			touchDrag: true,
			autoplay: false,
			autoplayHoverPause: true,
			autoplayTimeout: 10000,
			autoplaySpeed: 1000,
			dots: true,
			loop: true,
			nav: true,
			navText: ['',''],
			items: 1,
			responsive: {
				0: { items: 1, margin: 15, stagePadding: 15 },
				400: { items: 2, margin: 15, stagePadding: 15 },
				600: { items: 3, margin: 15, stagePadding: 10 },
				800: { items: 4, margin: 15, stagePadding: 10 }
			}
		});


		$("a.fancy").fancybox({
			'type': 'iframe',
			'scrolling': 'no',
			'padding': 5,
			'margin': 15,
			'autoSize': false,
			'minWidth': 200,
    		'minHeight': 300,
    		'maxWidth': 800,
    		'maxHeight': 900,
			'autoScale': true,
			'autoDimensions': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			beforeLoad : function() {
				this.titulo  = this.element.data('titulo');
				this.copete = this.element.data('copete');
                this.bajada = this.element.data('bajada');
				this.fechaemision = this.element.data('fechaemision');
			},
			afterLoad: function() {
				this.title = "<time>" + this.fechaemision + "</time><h3>" + this.titulo + "</h3><p>" + this.copete + "</p><p>" + this.bajada + "</p>";
			},
			helpers : {
				title: {
					type: 'inside'
				}
    		}
		});

		$("a.fancy2").fancybox({
			'type': 'iframe',
			'scrolling': 'no',
			'padding': 5,
			'margin': 15,
			'fitToView': false,
			'autoSize': false,
			'minWidth': 200,
    		'minHeight': 300,
    		'maxWidth': 800,
    		'maxHeight': 900,
			'autoScale': true,
			'autoDimensions': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
		});
		
	// DESTACADOS
	} else if ($("body").is("#destacados")) {
		
		getNoticias();
		showPlaca();

	// CANALES PROPIOS
	} else if ($("body").is("#canalesPropios")) {
		
		$('.canal .canalSlides').owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: true,
			autoplayTimeout: 5000,
			autoplaySpeed: 1000,
			dots: false,
			loop: true,
			nav: false,
			animateOut: 'fadeOut',
			items: 1
		});

		getNoticias();
		activarDestacados();
		showPlaca();

	// PROGRAMACION PROPIA
	} else if ($("body").is("#programacionPropia")) {
		getNoticias();

	// COMO TENER CCC
	} else if ($("body").is("#comoTener")) {
		getNoticias();
		activarDestacados();
		
		// $("#container .box .content").matchHeight();
		
	// PRODUCTOS
	} else if ($("body").is("#productos")) {
		getNoticias();
		activarDestacados();
	// BENEFICIOS
	} else if ($("body").is("#beneficios")) {
		getNoticias();
		activarDestacados();
		
		$(".beneficio .box").matchHeight({ byRow: false, target: $(".beneficio .box0") });
		
	// PREMIUM DIGITAL
	} else if ($("body").is("#premiumDigital")) {
		getNoticias();
		activarDestacados();
	// PRODUZCA CON CCC
	} else if ($("body").is("#produccion")) {
		getNoticias();
		activarDestacados();
		
		$("#container .box .content").matchHeight();
		
	// REVISTA
	} else if ($("body").is("#revista")) {
		getNoticias();
		activarDestacados();
		
		$(".col2 ul").addClass("li-01");
		
		$('.fasciculos').owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: true,
			autoplayTimeout: 5000,
			autoplaySpeed: 1000,
			navText: ['',''],
			dots: false,
			loop: true,
			
			nav: true,	
			responsive: {
				0: { items: 2, margin: 15, stagePadding: 15 },
				480: { items: 3, margin: 15, stagePadding: 15 },
				640: { items: 4, margin: 15, stagePadding: 15 },
				800: { items: 5, margin: 15, stagePadding: 15 },
				1000: { items: 6, margin: 18, stagePadding: 18 }
			}
		});

		// LO MEJOR DE CCC
	} else if ($("body").is("#mejorccc")) {
		getNoticias();
		activarDestacados();

	// LO MEJOR DE CCC - DETALLE
	} else if ($("body").is("#mejorcccdetalle")) {
		getNoticias();
		activarDestacados();
		
	// SORTEOS
	} else if ($("body").is("#sorteos")) {
		getNoticias();
		activarDestacados();
		
		$('.ganadores ul').owlCarousel({
			touchDrag: true,
			autoplay: true,
			autoplayHoverPause: true,
			autoplayTimeout: 5000,
			autoplaySpeed: 1000,
			navText: ['',''],
			dots: false,
			loop: true,
			
			nav: true,	
			responsive: {
				0: { items: 2, margin: 15, stagePadding: 15 },
				480: { items: 3, margin: 15, stagePadding: 15 },
				640: { items: 4, margin: 15, stagePadding: 15 },
				800: { items: 5, margin: 15, stagePadding: 15 },
				1000: { items: 6, margin: 18, stagePadding: 18 }
			}
		});

	}


});


function showPlaca() {
	$(".placa-wrap .placa").css({opacity: 0,top: "-150px"}).delay(1500).animate({opacity: 1,top: "10px"}, 1000, 'easeOutBack', function() {
		$(".placa-wrap").css({height: 100, overflow: "visible"});
	});
}

// ACTIVAR TABS DE LA GRILLA DE PROGRAMACION ---------------------------
function activarTabs(div, origen) {
	origen = (typeof origen === "undefined") ? "" : origen;
	var w = parseInt($('.tabbed .cont li',div).css('width'));
	var l = $('.tabbed .cont li',div).length;
	$('.tabbed .cont',div).css('width', w*l);	
	var fondo = $('#fondo');

	$('.tabbed .nav li a',div).click(function() {
		if(!$(this).parent().hasClass('current')) {
			var i = $(this).parent().index();
			$('.tabbed .nav li',div).removeClass('current');
			$(this).parent().addClass('current');
			$('.tabbed .cont',div).css('opacity',0).animate({opacity: 1, left: -w*i}, 500);

			if (div.is("#grilla")) {
				fondo.removeClass().addClass("color"+i);
				fondo.css({"display":"none"}).fadeIn("slow");
			}
		}
		return false;
	});
}

// ACTIVAR DESTACADOS ---------------------------
function activarDestacados() {
	$('#destacadosProg li a').hover(function () {
		$(this).find(".cont").stop().animate({top: 0},250);
	  },function () {
		$(this).find(".cont").stop().animate({top: "100%"},250);
	  }
	);
}

// FEED DE NOTICIAS ---------------------------
var headline_count;
var current_headline = 0;
var old_headline = 0;
function getNoticias() {
	
	var jqxhr = $.getJSON("archivos/NoticiasStickerVideos.aspx", function() {
		
	}).done(function(data) {
		
		$("header > .wrap").css({"height": "210px"}).append("<div id='noticiasContainer'><a href='NoticiasVideo.aspx'><p id='noticiasTitulo'>CCC Noticias</p></a><ul id='noticiasFeed'></ul></div>");
		$.each(data, function(i,item) {
			ct = "<a href='" + item.video + "' class='fancy' data-copete='" +  item.copete + "' data-titulo='" + item.titulo + "' data-bajada='" + item.bajada + "' data-fechaemision='" + item.fechaemision + "'><span class='txt1'>"+item.titulo+", </span><span class='txt2'>"+item.copete+". </span><span class='txt3'>"+item.bajada+"</span></a>";
			$("<li></li>").append(ct).appendTo('#noticiasFeed')
				
		});
		$("ul#noticiasFeed").liScroll({travelocity: 0.1});
		
	}).fail(function() {
		$("header > .wrap").css({"height": "160px"});
	});


	$("#noticiasFeed li a").fancybox({
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 5,
		'margin': 15,
		'autoSize': false,
		'minWidth': 200,
    	'minHeight': 300,
    	'maxWidth': 800,
    	'maxHeight': 900,
		'autoScale': true,
		'autoDimensions': false,
		'transitionIn': 'none',
		'transitionOut': 'none',
		beforeLoad : function() {
			this.titulo  = this.element.data('titulo');
			this.copete = this.element.data('copete');
            this.bajada = this.element.data('bajada');
			this.fechaemision = this.element.data('fechaemision');
		},
		afterLoad: function() {
			this.title = "<time>" + this.fechaemision + "</time><h3>" + this.titulo + "</h3><p>" + this.copete + "</p><p>" + this.bajada + "</p>";
		},
		helpers : {
			title: {
				type: 'inside'
			}
    	}
	});

};
/*function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count;
	$("#noticiasFeed li:eq("+old_headline+")")
	.animate({left: -800, opacity: 0},"slow", function() {
		$(this).css({left: 990, opacity: 1});
	});
	$("#noticiasFeed li:eq("+current_headline+")")
		.css('opacity', 0)
		.animate({left: 40, opacity:1},"slow");
	old_headline = current_headline;
}*/

// ------------------------------------------------------------------------
// FUNCIONES --------------------------------------------------------------
function GetURLParameter(sParam) {
	var sPageURL = window.location.search.substring(1);
	var sURLVariables = sPageURL.split('&');
	for (var i = 0; i < sURLVariables.length; i++) {
		var sParameterName = sURLVariables[i].split('=');

		if (sParameterName[0] == sParam) {
			return sParameterName[1];
		}
	}
}
