////////// FOTOS FANCY
$(document).ready(function(){
	$("a.fotofancy[rel]").fancybox({
		'zoomSpeedIn'		: 500,
		'zoomSpeedOut'		: 200,
		'overlayShow'		: true,
		'easingIn'			: 'easeOutBack',
		'easingOut'			: 'easeInBack',
		'overlayOpacity'	: 0.40,
		'centerOnScroll'	: true
	});
})

$(window).load(function () {
	remplazarFuentes();
//	validarFormularioContacto();

	$("ul.submenu").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

	$("ul.menu li span,a").click(function() { //When trigger is clicked...
		id = $(this).attr("id");
		//Following events are applied to the subnav itself (moving subnav up and down)

		$(this).parent().find("ul.submenu."+id).slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.submenu."+id).slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"

	});
});

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);


function remplazarFuentes(){

		Cufon.replace('.numberRed', { fontFamily: 'Futura_B_Cnd', color: '-linear-gradient( #95000e,#77000c)'});
		Cufon.replace('.paginado', { fontFamily: 'Futura_B_Cnd'});
		Cufon.replace('.paginadoAct', { fontFamily: 'Futura_B_Cnd'});
		Cufon.replace('.avanTras', { fontFamily: 'Futura_B_Cnd'});
		Cufon.replace('div.minititHome', { fontFamily: 'Futura_B_Cnd'});

		Cufon.replace('H1', { fontFamily: 'steelfish_B'});
		Cufon.replace('H2', { fontFamily: 'steelfish_B'});
		Cufon.replace('H3', { fontFamily: 'steelfish_R'});
		Cufon.replace('H4', { fontFamily: 'steelfish_R'});
		Cufon.replace('H5', { fontFamily: 'steelfish_R'});
		Cufon.replace('H6', { fontFamily: 'steelfish_R'});

}
/*
function validarFormularioContacto() {
	$(document).ready(function(){
		$("#btEnvia").click(function(){
			//document.formulario_contacto.submit();
			$("#formulario_contacto").submit();
		});

		$("#formulario_contacto").validate({
			rules: {
				nombre: {
					required: true
				},
				email: {
					email: true,
					required: true
				},
				telefono: {
					required: true
				}
			},
			messages: {
				nombre: {
					required: "<br>Por favor, introduzca aquí su nombre"
				},
				email: {
					email: "<br>Por favor, introduzca una dirección de E-Mail válida",
					required: "<br>Por favor, introduzca aquí su E-Mail"
				},
				telefono: {
					required: "<br>Por favor, introduzca aquí su teléfono"
				}
			}
		});
	});
}
*/
function paginar(accion) {

	switch (accion) {
	case 'prev':
		$("#search_form input[name=search_pagina]").val(parseInt($("#search_form input[name=search_pagina]").val())-1);
		$("#search_form").submit();
		break;
	case 'next':
		$("#search_form input[name=search_pagina]").val(parseInt($("#search_form input[name=search_pagina]").val())+1);
		$("#search_form").submit();
		break;
	default:
		$("#search_form input[name=search_pagina]").val(accion);
		$("#search_form").submit();
		break;
	}

}
