var FILTROS = {

	buscaFiltro:function(texto,cl,tipo,lng,limite,offset)
	{
		var final=""; 
		var a = 0 ;
		var temp ;
		var stars ="";
		var finalanyos="";
		var className ="";
		
		
		var url = "/" + lng + "/busqueda/resultados";
		
		if( tipo != null )
		{
			if (tipo.id == "star1") className = "valoracion-1 ezsr-stars-1"; 
			if (tipo.id == "star2") className = "valoracion-2 ezsr-stars-2";   
			if (tipo.id == "star3") className = "valoracion-3 ezsr-stars-3"; 
			if (tipo.id == "star4") className = "valoracion-4 ezsr-stars-4"; 
			if (tipo.id == "star5") className = "valoracion-5 ezsr-stars-5";
		}
				
		if (className !="") $('#st').removeClass();  $('#st').toggleClass(className);
		
		$('#filtros input:checkbox').each(function (i) { //comprobamos los checks de tipos
				if (this.checked)
				{
					
						if ((this.id =="audio") || (this.id =="video") || (this.id =="foto"))
						{
							final += "," + this.value
							a++;
						}
				}
			});
	
		final = final.substr(1,final.length);
	
		if (a==0)
		{
			final="image,video,podcast";
		}
	
		$('#anyo input:checkbox').each(function (i)  //comprobamos los checks de a�os
		{
				if (this.checked) 
					{
						finalanyos += "," + this.value
						
					}
			});
			
			finalanyos = finalanyos.substr(1,finalanyos.length);
	
				if ($('#st').hasClass("valoracion-0")) stars=""; //comprobamos si hay alguna estrella pintada
				if ($('#st').hasClass("valoracion-1")) stars=1;
				if ($('#st').hasClass("valoracion-2")) stars=2;
				if ($('#st').hasClass("valoracion-3")) stars=3;
				if ($('#st').hasClass("valoracion-4")) stars=4;
				if ($('#st').hasClass("valoracion-5")) stars=5;
	
			
			
		if (stars=="")
				{
					className = "valoracion-0 ezsr-stars-0";
				}
				else
				{
					className = "valoracion-"+stars+ " ezsr-stars-" + stars;
				}	
	
				$('#st').removeClass();  
				$('#st').toggleClass(className);
	
	
			 
	
			$.get(url, { SearchText:texto,clase:final,valoracion:stars,anyo:finalanyos,limit:limite,pagina:offset },
						function(data)
						{
                                                       /* alert( data );*/
							$('#resultados').empty();
							$('#resultados').append($(data));
						}
					);
	},
	
	cambiaIdioma:function(texto,lng,limite,offset)
	{
        $("#languages").val('');
        var langs = new Array();
        if( $("#lnges").attr( 'checked' ) )
        {
            langs[langs.length] = $("#lnges").val();
        }

        if( $("#lngen").attr( 'checked' ) )
            langs[langs.length] = $("#lngen").val();

		var url = "/" + lng + "/content/search/?SearchText=" + texto + '&Langs=' + langs.join('_' );
		document.location.href= url ;
	}
}

