// Base OMO


$(document).ready(function(e) {
	
	 
	$(".contenido-sub-post").find("img").parent().hide();
	$(".contenido-post").find("img").parent().hide();
	$(".ficha-contenido").find("p").find("img").hide();
	$(".post-destacado").find(".enlaces").css('margin','0 0 0 125px');
	$(".contenido-post .leyenda").eq(0).css('min-height','210px');
	$(".home-principal-post").find("p:first").css({
		"display":"block",
		"height":"100px"
	});
	$(".contenido-sub-post").find("p").append("...");
	
	$(document).pngFix();

	//Burbujas de productos del HOME PAGE
	$('.producto-home').hover(
		function () {
			var title=$(this).attr('title');
			$('.burbuja-productos').hide();
			$('.burbuja-'+title).fadeIn();
		}, 
		function () {
			$('.burbuja-productos').hide();
		}
	);
	
	//Funciionalidad al hacer FOCUS en los inputs del SIDEBAR
	$("input[name=s]").val("BUSCAR");
	$("input[name=email-sidebar]").val("Ingresa tu e-mail");
	
	$("input[name=s]").focus(function(){
		if ($(this).val() == "BUSCAR") {
			$(this).val("");
		}
	});
	$("input[name=s]").blur(function(){
		if ($(this).val() == "" ){
			$(this).val("BUSCAR");
		}
	});
	
	$("input[name=email-sidebar]").focus(function(){
		if ($(this).val() == "Ingresa tu e-mail") {
			$(this).val("");
		}
	});
	$("input[name=email-sidebar]").blur(function(){
		if ($(this).val() == "" ){
			$(this).val("Ingresa tu e-mail");
		}
	});
	
	//FORMATEAR FECHA A ESPANOL
	formatearFecha();
	
	//FANCYBOX EMAIL
	$("a.email").fancybox({
		'scrolling':'no'					
	});
	//FANCYBOX RALLY OMO
	$("a.rally").fancybox({
		'scrolling':'no'
	});	
	
	//SETEADOR DE FONDO BLANCO
	var fondoConectado = $(".connected");
	if(fondoConectado.lenght > 0) {
		$(".connected").css({
			'background':'url(/wp-content/themes/omo-new/img/derecha/bg-head-connected.png) no-repeat'
		});
	}
	else {
		$(".head").css({
			'background':'url(/wp-content/themes/omo-new/img/derecha/bg-head.png) no-repeat'
		});
	}
});

function formatearFecha() {

	var fecha = $(".ficha-contenido").find("h5").text();
	
	if (fecha != "") {
		var mesAno = fecha.toString().split("de ");
		var mes = mesAno[1].toString().split(" 20");

		if (mes[0] == "January") {
			mes[0] = "Enero"
		}
		else if (mes[0] == "February") {
			mes[0] = "Febrero"
		}
		else if (mes[0] == "March") {
			mes[0] = "Marzo"
		}
		else if (mes[0] == "April") {
			mes[0] = "Abril"
		}
		else if (mes[0] == "May") {
			mes[0] = "Mayo"
		}
		else if (mes[0] == "June") {
			mes[0] = "Junio"
		}
		else if (mes[0] == "July") {
			mes[0] = "Julio"
		}
		else if (mes[0] == "August") {
			mes[0] = "Agosto"
		}
		if (mes[0] == "September") {
			mes[0] = "Septiembre"
		}
		if (mes[0] == "October") {
			mes[0] = "Octubre"
		}
		if (mes[0] == "November") {
			mes[0] = "Noviembre"
		}
		if (mes[0] == "December") {
			mes[0] = "Diciembre"
		}

		$(".ficha-contenido").find("h5").text(mesAno[0] +"de "+ mes[0] + " de 20" + mes[1]);
	}
}

