

$(document).ready(function(){function getData(olddata){return{current:{q:$("#profession").val(),town:$("#townsel").val(),id:$("#id_resume").val()},previous:{q:olddata.current.q,town:olddata.current.town,id:olddata.current.id}};}
var idt=false;var curdata={current:{q:false,town:false,id:false},previous:{q:false,town:false,id:false}};var updateSimilarVacancies=function(){idt&&clearTimeout(idt);idt=setTimeout(function(){if($("#similar-vacancies-container").hasClass("force-close"))
{return;}
$container=$("#similar-vacancies-container");$prompt=$("#similar-vacancies-prompt");curdata=getData(curdata);if(!curdata.current.q){$container.hide();$("#similar-vacancies-closer").hide();$("#similar-vacancies-opener").hide();$("#showall").remove();$("#reviewlink").remove();$prompt.children("div.nothing-found").hide();$prompt.children("div.empty-input").show().end().show();return}
if(curdata.current.q!=curdata.previous.q||curdata.current.town!=curdata.previous.town)
{$container.hide();$prompt.children("div.nothing-found").hide();$prompt.children("div.empty-input").hide();$prompt.show().children("span").show();$("#showall").remove();$("#reviewlink").remove();$.getJSON("/js/request/similar_resumes.php",curdata.current,function(data){$prompt.children("span").hide();$("#similar-vacancies-closer").show();$("#similar-vacancies-table").populateVacancyTable(data.resumes);if(data.resumes&&data.resumes.length){$container.show();$prompt.hide();$("#showall").remove();$("#reviewlink").remove();$("#similar-resumes-showall").clone().show().attr("id","showall").attr("href",function(ref){return this.href.replace(/__q__/,curdata.current.q).replace(/__town__/,curdata.current.town)}).children(".count").text(data.total).end().insertAfter($container);if(data.rev){$("#similar-review-link").clone().show().attr("id","reviewlink").attr("href",function(ref){return this.href.replace(/__id__/,data.rev.id)}).children("span").text(data.rev.title).end().appendTo($container);}}else{var t=$("#townsel option:selected").text();$("#similar-vacancies-opener").hide();$prompt.children("div.nothing-found").show().children(".keywords").text(curdata.current.q).end().children(".town").text(t?t:'(все города)');}});}
else
{$("#similar-vacancies-closer").show();if($("#similar-vacancies-table tbody tr:not(.sample)").length){$container.show();$("#showall").show();$prompt.hide();}else{$("#similar-vacancies-opener").hide();$prompt.children("div.nothing-found").show();}}},350);};$.fn.extend({populateVacancyTable:function(data){$tb=this.children("tbody");$tb.children(":not(.sample)").remove();for(i in data){$newrow=$tb.children(".sample").clone().removeClass("sample").appendTo($tb).show().children();$newrow.children(".resume-id").text(data[i].id);if(data[i].avatar!=''){$newrow.children("a.resume-avatar").attr("href",function(ref){return this.href.replace(/__idr__/,data[i].id)}).html(data[i].avatar);}else{$newrow.children("a.resume-avatar").remove();}
$newrow.children("a.resume-name-link").attr("href",function(ref){return this.href.replace(/__idr__/,data[i].id)}).text(data[i].name);$newrow.children("span.resume-salary").append("<nobr>"+data[i].slr.replace(/&nbsp;/g," ")+"</nobr>");var work_text='';if(data[i].work_history_name)
work_text=work_text+data[i].work_history_name+"<br>";$newrow.children(".resume-description").append(work_text+
data[i].work_history_prof+"<br>"+
data[i].work_history_work);}}});$("#profession").bind("blur",updateSimilarVacancies);$.browser.msie&&$("#profession").bind("keyup",updateSimilarVacancies);$.browser.msie||$("#profession").bind("keypress",updateSimilarVacancies);$("#townsel").bind("change",updateSimilarVacancies);$("#similar-vacancies-opener").bind("click",function(){$("#similar-vacancies-container").removeClass("force-close");updateSimilarVacancies.call();return false});$("#similar-vacancies-closer").bind("click",function(){$("#similar-vacancies-prompt").show().children().hide();$("#similar-vacancies-opener").show();$("#similar-vacancies-container").addClass("force-close").hide();$("#showall").hide();$(this).hide();return false});$("#similar-vacancies-block").show();});