function load_movies(url){var hash=proccess_hash(url);if(hash){window.location.hash=hash;}else{window.location.hash='';}
var url_new='http://'+window.location.host+'/models/search/'+hash;$('#models').animate({opacity:'0.1'},1000);url_new=prepareUrl(url_new);$.ajax({url:url_new,async:true,type:"post",dataType:"json",success:function(data){if(data.success==true){if(data.pager){$('div.paging').empty();;$('div.paging').html(data.pager);}else{$('div.paging').empty();}
if(data.total){$('div.info .total').html(data.total);}else{$('div.info .total').html('0');}
if(data.sort){$('p.sort').html(data.sort);}
$('#models').empty().html(data.content);$('#models img').preload({placeholder:presets.image_url+'waiting-model.jpg',notFound:presets.image_url+'noimage-model.jpg'});$('#models').animate({opacity:'1'},2000);}else{showFlashData('error','<strong>Sorry.</strong> Something goes wrong...');}}});}
var search_filter={filter:'',values:''};function init_filter(filter)
{search_filter.filter=filter;}
function proccess_hash(url)
{var ser=presets.base_url+'models/search/';var hash=url.substr(ser.length);return hash;}
$(document).ready(function(){$("#content .sidebar .models-filter select").selectbox({animationSpeed:'fast'});if(window.location.hash!=''){load_movies(presets.base_url+'models/search/'+window.location.hash.substr(1));}else{load_movies(window.location.href);}
$('div.paging a, div.title p.filter a').live('click',function(){if(!$(this).hasClass('end')){$('div.title p.filter a').removeClass('active');$(this).addClass('active');load_movies($(this).attr('href'));}
return false;});$('#models_filter input[type=submit]').click(function(){var search_url='';for(var i=0;i<search_filter.filter.length;i++)
{if($('#'+search_filter.filter[i]).val()){search_url=search_url+search_filter.filter[i]+'/'+$('#'+search_filter.filter[i]).val()+'/';}}
var subhash=proccess_hash(windlow.location.href);load_movies(presets.base_url+'models/search/'+subhash+search_url);return false;});$('p.sort a').live('click',function(){load_movies($(this).attr('href'));return false;});});

