// JavaScript Document
//Functión de Facebook:
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

$(document).ready( function() {
	//Normalizamos divs vacíos:
	
	//Navegación:
	$('img#promocion').click( function() {
		$(location).attr('href', 'promociones/');
	});
	$('dd#banner_1').click( function() {
		$(location).attr('href', 'precios/?track=banner');
	});
	$('dd#banner_2').click( function() {
		$(location).attr('href', 'agendar-clase-de-prueba/');
	});
	$('dd#banner_3').click( function() {
		$(location).attr('href', 'agendar-clase-de-prueba/');
	});
	$('li#li_p_kids').click( function() {
		$(location).attr('href', 'programas/ninos/');
	});
	$('li#li_p_estudiantes').click( function() {
		$(location).attr('href', 'programas/estudiantes/');
	});
	$('li#li_p_ejecutivos').click( function() {
		$(location).attr('href', 'programas/ejecutivos/');
	});
	$('li#li_p_empresas').click( function() {
		$(location).attr('href', 'programas/empresas/');
	});
	$('li#li_p_especializados').click( function() {
		$(location).attr('href', 'programas/especializados/');
	});
	$('button#test').click( function() {
		$(location).attr('href', 'cuanto-sabes/');
	});
	//SlideDeck:
	$('.skin-slidedeck dl.slidedeck').slidedeck({
		autoPlay: true,
		cycle: true, 
		autoPlayInterval: 6000,
		hideSpines: true
	}).vertical();
	$('#central_left > img').click( function() {
		$('.skin-slidedeck dl.slidedeck').slidedeck().prev();
	});
	$('#central_right > img').click( function() {
		$('.skin-slidedeck dl.slidedeck').slidedeck().next();
	});

	//Twitter:
	$("#tweeter").tweet({
		username: "HarmonHallWeAre",
		join_text: "auto",
		count: 2,
		template: '{time}{join}{text}'
	});
});

//Normalizamos el height de los divs centrales
function ResizeDivs() {
	var max_height = 0;
	$('div#central_container').children().each( function() {
		$(this).height('');
	});
	$('div#central_container').children().each( function() {
		if($(this).height() > max_height) max_height = $(this).height();
	});
	$('div#central_container').children().each( function() {
		if($(this).height() < max_height) $(this).height(max_height);
	});
}
