var base = $('base').attr('href');

function buscar()
{

	words = $('#words').val().replace(' ','+');
	category = $('#category').val();
	studio = $('#studio').val();
	
	url = '';
		
	if(words)
	{
		if(category == '0')
		{
			category = 'todos';
		}
		
		if(studio == '0')
		{
			studio = 'todos';
		}
		
		location.href = base+'peliculas/buscar/'+category+'/'+studio+'/'+words;
	}
	else
	{
	
		there_is_category = (category != 0);
		there_is_studio = (studio != 0);  
	
		if(there_is_category && there_is_studio)
		{
			location.href = base+'peliculas/buscar/'+category+'/'+studio;
		}
		else if(there_is_category)
		{
			location.href = base+'peliculas/categoria/'+category;
		}
		else if(there_is_studio)
		{
			location.href = base+'peliculas/estudios/'+studio;
		}
		else
		{
			alert("Debe completar al menos una opcion de busqueda");
		}
	}
	
	return false;
	
}
