Cufon.replace('h1, .entry, button, .moviepanel .col2 p, .moviepanel .col2 h2, .bar a, a.bts');

$(document).ready(function() {
	$('select[name=models]').change(function() {
		if($(this).val() != '') {
                        w = document.getElementsByName('models')[0].selectedIndex;
                        categoryText = document.getElementsByName('models')[0].options[w].text;
                        categoryText = friendlyUrl(categoryText);
			             location.href='/pornstars/'+categoryText+'/'+$(this).val();
		}
	});

	$('select[name=categories]').change(function() {
		if($(this).val() != '') {
                        w = document.getElementsByName('categories')[0].selectedIndex;
                        categoryText = document.getElementsByName('categories')[0].options[w].text;
                        categoryText = friendlyUrl(categoryText);
                        location.href='/category/'+categoryText+'/movies/'+$(this).val();
		}
	});

    $('select[name=movies]').change(function() {
		if($(this).val() != '') {
                        w = document.getElementsByName('movies')[0].selectedIndex;
                        categoryText = document.getElementsByName('movies')[0].options[w].text;
                    	categoryText = friendlyUrl(categoryText);
			         location.href='/movies/'+categoryText+'/'+$(this).val();
		}
	});	
});

function friendlyUrl(txt) {
  return txt
    .toLowerCase() // change everything to lowercase
    .replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces		
    .replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
    .replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
    .replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
    .replace(/^-+|-+$/g, "") // trim leading and trailing hyphens				
  ; 
}
