//Limpiar el value de los inputs

function formDefaultValue (elemento, defaultValue) {

	if (elemento.value==defaultValue) {

		elemento.value = "";

	}

	return true;

}

function formDefaultValueCheck (elemento,defaultValue) {

	if(elemento.value == "") {

		elemento.value = defaultValue;

	}

}



//Igualar altura

function equalHeight(group) {

    tallest = 0;

    group.each(function() {

        thisHeight = $(this).height();

        if(thisHeight > tallest) {

            tallest = thisHeight;

        }

    });

    group.height(tallest);

}





$(document).ready(function(){

	$('input').inputCSS();

	$('#footer ul li:first').addClass("first");
	
	var contador_des = 1;
	$("#block1 .itemScrool,#block2 .itemScrool").each(function(){
		if(contador_des == 3){
			$(this).css("marginRight","0px");				
			contador_des = 1;
			}else{ 
				contador_des++;
			}
		}
	);
	$('#footer ul li:last, #listFooter li:last, .capaFil ul li:last, .blockfaq li:last, #slide li:last, #menu li:last, #menu li:last a').addClass("last");

	$("#linkAvan").click(function(event) {

		$('#group_producto').hide(500);

		$("#buscador_avanzado").slideDown(1000);

		$('#linkAvan').hide();

		$('#buscador_cancelar').show(1000);

		$('#titbusca').hide();

		$('#titbuscaAvn').show();

	});

	$("#buscador_cancelar").click(function(event) {

		$("#buscador_avanzado").slideUp(1000);

		$('#group_producto').show(1000);

		$('#linkAvan').show(1000);

		$('#buscador_cancelar').hide(1000);

		$('#titbusca').show();

		$('#titbuscaAvn').hide();

	});

	$("#linkAmigo").click(function(event) {

		$(".formulariAmigo").slideToggle(1000);

		$('#blockProdFicha').toggleClass("activeAmigo");

		$('#linkDir').toggleClass("activelinkdir");

		$('#separAm').toggleClass("colorWhite");

	});

	//Recorro todos los items

	var contador = 0;

	$( ".listProductos li, .categoriaProductos li" ).each(

		function(){

			if(contador == 2){

				$(this).addClass("last");					

				contador = 0;

			}else{ 

				contador++;

			}

		}

	);

	$(".scrollable").scrollable({size:4});

	$("#link_taw").click(function(){
		$(this).toggleClass("active");
		$("#taw").slideToggle();
	});

	//Reemplazo fuentes

	cuffonReplace();

	/*

	var contador = 0;

	$( ".items .itemScrool" ).each(

		function(){

			if(contador == 4){

				$(this).addClass("first");					

				contador = 0;

			}else{ 

				contador++;

			}

		}

	);*/

	//Igualamos la altura de los bloques
/*
	if ($(".scrollable").outerHeight()>$(".itemScrool").outerHeight()){

		var altura=$(".scrollable").outerHeight();

	}else{

		var altura=$(".itemScrool").outerHeight();

		$(".scrollable").addClass("otraClass");

	}

	$(".scrollable").height(altura);
*/
	

	//Igualamos la altura de los bloques

	setTimeout("equalHeight($('.itemScrool,.listProductos li'));",5000);

});



function cuffonReplace(){

	//Fuentes

	Cufon.replace('.precio, .precioAnt, .precioResl, .preci1F, .titleCat, #paginacion, .titleCatSin, .descuentoFicha, .tituloAntes, .tituloAhora, .precioHel, .descuentoPeque, #titleSlogan', {fontFamily:'HelveticaRounded-Condensed',hover: true});

	Cufon.replace('.euro, .eurMyr, .precioAntEuro, .precioResleur, #linkAmigo, #linkPrint, .preci2F, .preci3F, .infoAten span, #errorPago span, .noStock h6, .noStockFicha h6', {fontFamily:'Myriad Pro Cond'});

}



function refreshUpdate(i){

	carga_url('index.php?aE=x&ac=home-refresh-update&pag='+i,'homenews',false, 'fade');

}



function searchSelectFamily(val){

	carga_url('index.php?aE=x&ac=search-subfamily-update&f='+val,'subfamily',false, 'fade');

}



function changeFamily(val){

	document.getElementById('iProcesar').src="index.php?aE=x&ac=productos-change-family&family="+val;

}
