global_row=-1;global_vendorcat_id=0;global_sort_by='kpif';global_sort_order='desc';global_entity_id=-1;global_result_sync=0;global_getMatches=null;global_over_10000='no';global_loading_count=0;global_saving_count=0;global_ignore_cache=false;loading_img='<div class="ld">Loading...</div>';$(document).ready(function(){updateNativeLanguageLabel();$(".flat_submit,#nav_vendor li").hover(function(){$(this).addClass("nav_vendor_hover");},function(){$(this).removeClass("nav_vendor_hover");});$("#save_title_prepare_message").click(function(){$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=updateTitle&need_id='+$('#need_id').val()+'&title='+$('#contact_title').val()});$('#edit_title').html($('#candidate_title').val());$('#edit_title_wrapper').show();$('div.contact_title').hide('fast');window.open('/employers/need/'+$('#need_id').val()+'/candidates/?cand_action[compose_msg]=1&msg_eids[]='+global_entity_id);});$("#save_title_add_candidates").click(function(){$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=updateTitle&need_id='+$('#need_id').val()+'&title='+$('#candidate_title').val()});$('#edit_title').html($('#candidate_title').val());$('#edit_title_wrapper').show();$('div.candidate_title').hide('fast');addCandidate(global_entity_id,$(this).position());});$("#quick_search_label").click(function(){if($("#quick_search_content").css('display')=='none'){$(this).removeClass("link");$("#quick_search_content").show("fast");$("#qs_up").hide();$("#qs_down").show();}else{$(this).addClass("link");$("#qs_up").show();$("#qs_down").hide();$("#quick_search_content").hide("fast");}});$(".quick_search_label").click(function(){var area=this.id.split("_")[2];if($("#quick_search_"+area).css('display')=='none'){$("#quick_search_"+area).show("fast");$("#quick_search_"+area+"_plus").hide();$("#quick_search_"+area+"_minus").show();}else{$("#quick_search_"+area).hide("fast");$("#quick_search_"+area+"_minus").hide();$("#quick_search_"+area+"_plus").show();}});if(true===global_nliv){$(".nliv").click(function(event){bindNliv(event);});}
$(".vendor_browse_button").hover(function(){$(this).addClass("vendor_browse_button_highlight");},function(){$(this).removeClass("vendor_browse_button_highlight");});$(".edit_title").hover(function(){$(this).addClass("vm_highlight");},function(){$(this).removeClass("vm_highlight");});$("#toggle_requirements").click(function(){if('Show Criteria'==$('#toggle_requirements').html()){$('#toggle_requirements').addClass('vendor_browse_active');$("#requirements").show();$('#toggle_requirements').html('Hide Criteria');}else{$('#toggle_requirements').removeClass('vendor_browse_active');$("#requirements").hide();$('#toggle_requirements').html('Show Criteria');}});$(".req_hover").mouseover(function(){$(this).addClass("over");});$(".req_hover").mouseout(function(){$(this).removeClass("over");});hideLoading();var vendor_type=$('#vendor_match').val();updateVendorControls(vendor_type);if(global_display_default_requirements===true){global_display_default_requirements=false;}else{getMatches(global_sort_by,global_sort_order);}
$('.sort_controls').css("display","none");$('.sort_label').addClass('link');$('#sort_order_'+global_sort_by).css("display","");$('#sort_label_'+global_sort_by).removeClass('link');updateAddAnother();updateControls();updateSelectedVendorCount();var need_id=$('#need_id').val();var job_posted_msg='<b>You are editing requirements for a job that has already been posted.</b><br/><br/>If you change these requirements, it will change who is allowed to see and quote on this job.';if(global_job_posted===true){$.prompt(job_posted_msg,{callback:copyRequirements,buttons:{'Continue editing':true,'New search':false}});}
$(".edit_title").editable("/ajax/ajax_pfe_find?action=updateTitle&need_id="+need_id,{name:'title',event:"click",cancel:'Cancel',submit:'OK',indicator:"<img src='/images/wikiwords/loading.gif' alt='loading'/>",tooltip:'Click to edit...',style:'display: inline'});$(".edit_title_icon").bind("click",function(){$(".edit_title").trigger("click");return false;});$('#req_builder_3').ajaxForm(function(){getMatches(global_sort_by,global_sort_order);});$('#customize_link').click(function(event){$.prompt($('#customize_results').html(),{buttons:{Refresh:true,Cancel:false},callback:function(v){if(v===true){getMatches(global_sort_by,global_sort_order);}}});});$("#invite").click(function(){$('#invite_box').html(loading_img);$('#invite_box').toggle("fast");var invite_to_job=($('#invite_to_job').val()!==undefined)?$('#invite_to_job').val():'';var checked_entities=getCheckedEntities();$.ajax({url:'/ajax/ajax_pfe_find.php',data:'action=get_recent_jobs&providers='+checked_entities+'&invite_to_job='+invite_to_job,type:"GET",dataType:"json",error:function(){},success:function(json){$('#invite_box').html(json.jobs);}});});$("#invite_to_apply").click(function(){var invite_entities=confirm("Set all of these users to invite to apply?");if(invite_entities){$('#invite_to_apply_box').toggle("fast");$('#invite_to_apply_box').html(loading_img);var checked_entities=getCheckedEntities();$.ajax({url:'/ajax/ajax_pfe_find.php',data:'action=invite_to_apply&eids='+checked_entities,type:"GET",dataType:"json",error:function(){$('#invite_to_apply_box').html("Something went real bad wrong.");},success:function(json){$('#invite_to_apply_box').html(json.invite_success);}});}});$("#post_job").click(function(){if(typeof(job_started)!=="undefined"){if(typeof(global_over_10000)!=="undefined"){if(global_over_10000==='yes'){var offset=$("#post_job").offset();$('#postjob_over_10000').css({position:"absolute",top:offset.top+30,left:offset.left+50}).show();return;}}}
var need_id=$('#need_id').val();if(false===global_nliv){var url;if($('#edit_title').text()=='Untitled search'){generateTitle('post_job_title');}}
hideAllCallouts();offset=$("#post_job").offset();if(global_job_started===true&&$('count_all').text!==''){if(document.getElementById('post_job_title').value!==''){document.getElementById('edit_job_title').value=document.getElementById('post_job_title').value;}else{document.getElementById('edit_job_title').value=$('#edit_title').text();}
$("#postjob_edit").show();$("#postjob_vendors").hide();$("#postjob_no_vendors").hide();}else{$("#postjob_edit").hide();}
$("div.postjob").css({position:"absolute",top:offset.top-10,left:offset.left-50}).toggle("fast");$('#post_job_title').css('background','#FFFF99').focus().select();$('#edit_title_wrapper').show();return false;});$("a[id=close_postjob]").click(function(){$("div.postjob").hide("fast");return false;});$("#send_message").click(function(){if($('#edit_title').text()=='Untitled search'&&global_nliv===false){generateTitle('send_message_title');}else{document.getElementById('send_message_title').value=$('#edit_title').text();}
hideAllCallouts();var offset=$("#send_message").offset();$("div.sendmessage").css({position:"absolute",top:offset.top-10,left:offset.left-50}).toggle("fast");$('#send_message_title').css('background','#FFFF99').focus().select();$('#edit_title_wrapper').show();return false;});$("#send_message_ptc").click(function(){var checked_entities=getCheckedEntities();document.location.href="/translation-center/my/workspace/messages?msg_sp_mode=compose&msg_eids_cs="+checked_entities;return false;});$("a[id=close_sendmsg_panel]").click(function(){$("div.sendmessage").hide("fast");return false;});$("#batchop_link").click(function(){hideAllCallouts();var offset=$("#batchop_link").offset();$("div.batch").css({position:"absolute",top:offset.top-50,left:offset.left-200}).toggle("fast");return false;});$("a[id=close_batch_panel]").click(function(){$("div.batch").hide("fast");return false;});});function updateSearch(){$("#update_search").remove();global_ignore_cache=true;$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=clearNeedCache&need_id='+$('#need_id').val(),success:function(){getMatches(global_sort_by,global_sort_order);}});}
function copyRequirements(v){if(v===false){url='/connect/find?copy_need_from='+$('#need_id').val();window.location=url;return false;}}
function hideAllCallouts(){$("div.sendmessage").hide();$("div.batch").hide();$("div.contact_title").hide();$("div.candidate_title").hide();$("div.postjob").hide();}
function toggleCustomizeVendors(){var offset=$("#customize_vendor_link").offset();$("#customize_vendors").css({position:"absolute",top:offset.top+20,left:offset.left-100}).toggle("fast");}
function saveCustomizedControl(control_id,checked){$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:{action:'saveCustomizedControl',name:control_id.substr(9),value:checked}});}
function saveCustomizedVendors(){var vendor_type;vendor_type=global_match_vendors;switch(vendor_type){case'all':updateVendor('all');break;case'mine':updateVendor('mine',global_vendorcat_id);break;case'notmine':updateVendor('notmine');break;}}
function saveNshow(){var nshow=document.getElementById('nshow').value;global_nshow=nshow;$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=saveNshow&nshow='+nshow});}
function savenshow_browse(){var nshow_browse=document.getElementById('nshow_browse').value;global_nshow=nshow_browse;$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=savenshow_browse&nshow_browse='+nshow_browse});}
function saveProfileDetails(){var expand_profile_details=document.getElementById('expand_profile_details').checked;global_expand_profile_details=expand_profile_details;$.ajax({type:'POST',url:'/ajax/ajax_pfe_find.php',data:'action=saveProfileDetails&expand_profile_details='+expand_profile_details});}
function defaultLanguagePair(row_id){var current_source=document.getElementById(row_id+'_source_lang').value;var current_target=document.getElementById(row_id+'_target_lang').value;if(current_source===''){$('#'+row_id+'_source_lang').selectOptions('eng');updateCount(row_id);}else if(current_target===''){$('#'+row_id+'_target_lang').selectOptions('eng');updateCount(row_id);}}
function changeSelectedLangPair(row_id,source,target){if(!$('#'+row_id+'_source_lang').containsOption(source)||!$('#'+row_id+'_target_lang').containsOption(target)){$('#'+row_id+'_source_lang').addOption(source,source,true);$('#'+row_id+'_target_lang').addOption(target,target,true);showAllLangs(row_id);}else{$('#'+row_id+'_source_lang').selectOptions(source);$('#'+row_id+'_target_lang').selectOptions(target);}
$('#language_pair').click();updateCount(row_id);}
function changeSelectedDiscCounterId(row_id,disc_id){$('#'+row_id+'_disc_all').selectOptions(disc_id);$('#disc_spec').click();updateCount(row_id);}
function changeSelectedYrsExp(row_id,years){$('#'+row_id+'_yrs_experience').selectOptions(years);$('#yrs_experience').click();updateCount(row_id);}
function changeSelectedAvailability(row_id,from,to,include){$('#'+row_id+'_availability_avail_from').val(from);$('#'+row_id+'_availability_avail_to').val(to);$('#availability').click();updateCount(row_id);}
function changeSelectedCATTool(row_id,cat_tool){$('#'+row_id+'_cat_tool').selectOptions(cat_tool);$('#cat_tool').click();updateCount(row_id);}
function changeSelectedCredential(row_id,credential_id){$('#'+row_id+'_credential').selectOptions(credential_id);$('#credential').click();updateCount(row_id);}
function changeSelectedAssociation(row_id,association_id){$('#'+row_id+'_association').selectOptions(association_id);$('#association').click();updateCount(row_id);}
function changeKeywords(row_id,text){document.getElementById(row_id+'_text').value=text;$('#text').click();updateCount(row_id);}
function changeSelectedNativeLang(row_id,lang){$('#'+row_id+'_native_lang').selectOptions(lang);$('#native_lang').click();updateCount(row_id);}
function errorMessage(err_msg,action){var table=document.getElementById('table_results');var rows=table.rows;var err_message,row;while(rows.length>1){table.deleteRow(rows.length-1);}
$('.pfe_pager').empty();row=table.insertRow(table.rows.length);err_message=document.createElement("TD");var textnode=document.createTextNode("");err_message.appendChild(textnode);err_message.innerHTML='<br/>'+err_msg+'  ProZ.com staff have been notified.<br/><br/><span class="link" onClick=\"'+action+'">Click here</span> to recover from this error and try again.<br/><br/>';err_message.className='error_small';err_message.colSpan='6';row.appendChild(err_message);table.appendChild(row);}
function logError(crit_id,err_msg,action){var need_id=$('#need_id').val();var reqset_id=document.getElementById("reqset_id").value;$.ajax({type:"POST",url:"/ajax/ajax_pfe_find.php",data:"action=logError&need_id="+need_id+"&crit_id="+crit_id+"&reqset_id="+reqset_id+"&err_msg="+err_msg+"&attempted_action="+action});}
function countCandidates(count){if(count>0){$('#candidates_link').show();}else{$('#candidates_link').hide();}
$('#candidate_count').html(count);}
function nameNeedContact(id,position){global_entity_id=id;document.getElementById('contact_title').value=$('#edit_title').text();var need_id=$('#need_id').val();if($('#edit_title').text()=='Untitled search'){$("div.contact_title").css({position:"absolute",top:position.top+15,left:position.left});$("div.postjob").hide();$("div.sendmessage").hide();$("div.batch").hide();$("div.candidate_title").hide();$("div.contact_title").toggle("fast");generateTitle('contact_title');return false;}else{window.location='/employers/need/'+need_id+'/candidates/?cand_action[compose_msg]=1&msg_eids[]='+id;}}
function generateTitle(target){var need_id=$('#need_id').val();$.getJSON('/ajax/ajax_pfe_find.php','action=generateTitle&need_id='+need_id,function(json){if(json.title!==''){if(typeof(target)==="undefined"){$('#edit_title').text(json.title);document.getElementById('post_job_title').value=json.title;document.getElementById('edit_job_title').value=json.title;document.getElementById('send_message_title').value=json.title;document.getElementById('contact_title').value=json.title;document.getElementById('candidate_title').value=json.title;}else{document.getElementById(target).value=json.title;}}});}
function addToPipeline(){var entities=getCheckedEntities();var retval='';for(var i=0;i<entities.length;i++){addCandidate(entities[i],'pipeline');}
return;}
function updateWordCount(){if(isNaN(parseInt($('#matches_repetitions').val(),10))){$('#matches_repetitions').val(0);}
if(isNaN(parseInt($('#matches_100').val(),10))){$('#matches_100').val(0);}
if(isNaN(parseInt($('#matches_95').val(),10))){$('#matches_95').val(0);}
if(isNaN(parseInt($('#matches_85').val(),10))){$('#matches_85').val(0);}
if(isNaN(parseInt($('#matches_75').val(),10))){$('#matches_75').val(0);}
if(isNaN(parseInt($('#matches_50').val(),10))){$('#matches_50').val(0);}
if(isNaN(parseInt($('#matches_none').val(),10))){$('#matches_none').val(0);}
var sum=parseInt($('#matches_repetitions').val(),10)+
parseInt($('#matches_100').val(),10)+
parseInt($('#matches_95').val(),10)+
parseInt($('#matches_85').val(),10)+
parseInt($('#matches_75').val(),10)+
parseInt($('#matches_50').val(),10)+
parseInt($('#matches_none').val(),10);if(isNaN(sum)){sum=0;}
$('#volume').val(sum);}
function addCandidate(entity_id,position){global_entity_id=entity_id;var need_id=$('#need_id').val();document.getElementById('candidate_title').value=$('#edit_title').text();if($('#edit_title').text()=='Untitled search'&&position!=='pipeline'){var offset=$("#post_job").offset();$("div.candidate_title").css({position:"absolute",top:position.top+15,left:position.left});$("div.postjob").hide();$("div.sendmessage").hide();$("div.batch").hide();$("div.contact_title").hide();$("div.candidate_title").toggle("fast");return false;}else{$('#add_to_candidates_'+entity_id).text('...');$.ajax({type:'GET',dataType:'json',url:'/ajax/ajax_pfe_find',data:'action=addCandidate&eid_to_add='+entity_id+'&need_id='+need_id,success:function(json){$('#candidate_controls_'+entity_id).html('<div class="icon-remove-user dir-menu"><span class="link" id="remove_from_candidates_'+entity_id+'" onclick="removeCandidate(\''+entity_id+'\');">Remove from candidates</span></div>');$('#candidate_label_'+entity_id).show();countCandidates(json.candidateCount);}});}}
function removeCandidate(entity_id){var need_id=$('#need_id').val();$('#remove_from_candidates_'+entity_id).text('...');$.ajax({type:'GET',dataType:'json',url:'/ajax/ajax_pfe_find',data:'action=removeCandidate&eid_to_remove='+entity_id+'&need_id='+need_id,success:function(json){$('#candidate_controls_'+entity_id).html('<span class="link" id="add_to_candidates_'+entity_id+'" onclick="addCandidate(\''+entity_id+'\',$(this).position());">Add to candidates</span>');$('#candidate_label_'+entity_id).hide();countCandidates(json.candidateCount);}});}
function getCheckedEntities(){var t=$('#req_builder_3')[0];var entities=[];for(var i=1;i<t.length;i++){if((t[i].id.substr(0,10)==='entity_id_')&&t[i].checked){entities.push(t[i].id.substr(10));}}
return entities;}
function getEntitiesUrl(entities){var retval='';for(var i=0;i<entities.length;i++){retval+='&msg_eids[]='+entities[i];}
return retval;}
function updateSelectedVendorCount(){var t=$('#req_builder_3')[0];var retval=0;for(var i=1;i<t.length;i++){if((t[i].id.substr(0,10)==='entity_id_')&&t[i].checked){retval++;}}
$('.selected_vendor_count').text(retval);$('#batch_count').text(retval);if(retval===0){$('.batch_controls').removeClass('link');$('.batch_controls').addClass('grayedOut');$('.individually_selected').addClass('grayedOut');$('.vm2').attr("checked","checked");$('.vm1').attr("disabled","disabled");}else{$('.batch_controls').addClass('link');$('.batch_controls').removeClass('grayedOut');$('.individually_selected').removeClass('grayedOut');$('.vm1').attr("checked","checked");$('.vm1').attr("disabled","");}
return;}
function checkAllVendors(){var t=$('#req_builder_3')[0];for(var i=1;i<t.length;i++){if(t[i].id.substr(0,10)==='entity_id_'){t[i].checked=true;}}
document.getElementById('toggle_selected_vendors').checked=true;updateSelectedVendorCount();}
function checkNotContactedVendors(){var t=$('#req_builder_3')[0];for(var i=1;i<t.length;i++){if((t[i].id.substr(0,10)==='entity_id_')&&(document.getElementById('contacted_'+t[i].id.substr(10)).value!=='y')){t[i].checked=true;}}
updateSelectedVendorCount();}
function unCheckAllVendors(){var t=$('#req_builder_3')[0];for(var i=1;i<t.length;i++){if(t[i].id.substr(0,10)==='entity_id_'){t[i].checked=false;}}
document.getElementById('toggle_selected_vendors').checked=false;updateSelectedVendorCount();}
function generateResultRow(first,second,third,fourth,fifth,sixth,row_id,entity_id,is_premium){var row='<tr><td colspan="6" class="resultblankrow"><img src="/images/spacer.gif" height="9" width="1"/></td></tr>';row+='<tr>';row+='<td rowspan="6" valign="middle"><input id="entity_id_'+entity_id+'" type="checkbox" onclick="updateSelectedVendorCount();"/></td>';row+='<td class="bordercell"><img src="/images/corners/fff-dedede-ul.gif" border="0" height="5" width="5"></td>';row+='<td colspan="3" class="bordercell" style="background-image: url(/images/corners/fff-dedede-t.gif); background-repeat: repeat-x;"></td>';row+='<td class="bordercell"><img src="/images/corners/fff-dedede-ur.gif" border="0" height="5" width="5"></td>';row+='</tr>';row+='<tr>';row+='<td style="background-image: url(/images/corners/fff-dedede-l.gif);" class="repeaty"></td>';row+='<td valign="top"'+(is_premium==='y'?'class="premiumcell" ':'')+'>'+first+'</td>';row+='<td style="padding-left: 10px;" align="left" valign="top"'+(is_premium==='y'?'class="premiumcell" ':'')+'>'+second+'</td>';row+='<td align="center" valign="top"'+(is_premium==='y'?'class="premiumcell" ':'')+'>'+third+'</td>';row+='<td style="background-image: url(/images/corners/fff-dedede-r.gif);" class="repeaty"></td>';row+='</tr>';row+='<tr>';row+='<td style="background-image: url(/images/corners/fff-dedede-l.gif);" class="repeaty"></td>';row+='<td colspan="3" valign="top"'+(is_premium==='y'?'class="premiumcell" ':'')+'>'+fourth+'</td>';row+='<td style="background-image: url(/images/corners/fff-dedede-r.gif);" class="repeaty"></td>';row+='</tr>';row+='<tr>';row+='<td style="background-image: url(/images/corners/fff-dedede-l.gif);" class="repeaty"></td>';row+='<td colspan="3" valign="top">'+fifth+'</td>';row+='<td style="background-image: url(/images/corners/fff-dedede-r.gif);" class="repeaty"></td>';row+='</tr>';row+='<tr id="details_'+row_id+'">';row+='<td style="background-image: url(/images/corners/fff-dedede-l.gif);" class="repeaty"></td>';row+='<td colspan="3">'+sixth+'</td>';row+='<td style="background-image: url(/images/corners/fff-dedede-r.gif);" class="repeaty"></td>';row+='</tr>';row+='<tr>';row+='<td class="bordercell"><img src="/images/corners/fff-dedede-ll.gif" border="0" height="5" width="5"></td>';row+='<td colspan="3" class="bordercell" style="background-image: url(/images/corners/fff-dedede-b.gif); background-repeat: repeat-x;"></td>';row+='<td class="bordercell"><img src="/images/corners/fff-dedede-lr.gif" border="0" height="5" width="5"></td>';row+='</tr>';return row;}
function toggleBoolean(row_id){var need_id=$('#need_id').val();var crit_id=document.getElementById(row_id+'[crit_id]').value;$.ajax({type:"POST",url:"/ajax/ajax_pfe_find.php",data:"action=toggle_match_type&need_id="+need_id+"&crit_id="+crit_id});}
function updateCount(row_id){document.body.focus();$("#update_search").remove();var need_id=$('#need_id').val();var reqset_id=$('#reqset_id').val();var crit_id;var table=$('#requirement_controls').get();var crit=$('#'+row_id).children()[0].id.split('|')[1];if(typeof($('#source_show_more:selected').val())!=="undefined"||typeof($('#target_show_more:selected').val())!=="undefined"){showAllLangs(row_id);return false;}
$('#'+crit).addClass('requirement_name_selected');$('#expanded_'+crit+'').removeClass('expanded_section');$('#expanded_'+crit+'').addClass('expanded_section_selected');getReqLabel(crit,need_id,row_id);var thisRowError=false;if(!checkRowForError(row_id,crit)){thisRowError=true;}
global_result_sync=Math.floor(Math.random()*100000);if(!thisRowError){showSaving();$.ajax({url:'/ajax/ajax_pfe_find.php?action=saveCrit&result_sync='+global_result_sync+'&need_id='+need_id+'&reqset_id='+reqset_id+'&'+row2queryString(row_id),type:'POST',dataType:'json',error:function(){hideSaving();if(global_getMatches===null){logError(document.getElementById(row_id+'[crit_id]').value,"Error retrieving matches","updateCount");errorMessage('Sorry, an error occured when saving your criteria.','updateCount(\''+row_id+'\');');}},success:function(json){var debug=document.getElementById('debug').value;if(debug&&json.debug!==''){$('#save_benchmark').html(json.debug);}
if(json.critid!==''){if(document.getElementById(row_id+'[crit_id]')===null){crit_id=document.createElement("input");crit_id.setAttribute("type","hidden");crit_id.setAttribute("name",row_id+'[crit_id]');crit_id.setAttribute("id",row_id+'[crit_id]');crit_id.setAttribute("value",json.critid);document.forms.req_builder_3.appendChild(crit_id);}else{document.getElementById(row_id+'[crit_id]').value=json.critid;}}
if(json.report.length===0){hideSaving();updateAddAnother();updateControls();if(json.result_sync==global_result_sync){getMatches(global_sort_by,global_sort_order);}
return;}}});}
if(crit==="availability"||crit==="rates"||crit==="membership_type"||crit==="complete_profile"||crit==="resume"||crit==="wwa"||(crit==="vendor_qualification"&&global_mode!=='browse')||crit==="name"){$('#'+row_id).hide();}}
function updateVendor(vendor_type,vendorcat_id){var need_id=$('#need_id').val();if(vendor_type=='mine'){$('#vendor_type_in').attr("checked","checked");}else if(vendor_type=='notmine'){$('#vendor_type_not').attr("checked","checked");}else{vendor_type='all';$('#vendor_type_all').attr("checked","checked");}
$.ajax({type:"POST",url:"/ajax/ajax_pfe_find.php",data:'action=updateVendorFilter&need_id='+need_id+'&vendor_type='+vendor_type});global_match_vendors=vendor_type;global_vendorcat_id=vendorcat_id;document.getElementById('post_vendorcat_id').value=vendorcat_id;updateVendorControls(vendor_type);getMatches(global_sort_by,global_sort_order);}
function updateVendorControls(vendor_type){if(vendor_type==='mine'){$('#vendorcat_id_controls').show();}else{$('#vendorcat_id_controls').hide();}
$('.vendor_type').removeClass('bold').removeClass('link').addClass('link');$('#vendor_controls_'+vendor_type).addClass('bold').removeClass('link');$('.vendor_count').hide();if(vendor_type==='mine'){$('.count_vendors').show();$('.vendor_label').text("My vendors");}else if(vendor_type==='notmine'){$('.count_others').show();$('.vendor_label').text("Not my vendors");}else{$('.count_all').show();$('.vendor_label').text("All matches");}}
function getDetails(entity_id){var need_id=$('#need_id').val();var details=document.getElementById('details_content_'+entity_id);var detail_string='';$('div[id=details_content_'+entity_id+']').slideToggle("fast");if($('div[id=details_content_'+entity_id+']').css('display')==='block'&&document.getElementById('details_loaded_'+entity_id).value==='n'){$('div[id=detils_content_'+entity_id+']').html('<img src="/images/loading.gif">');$.getJSON('/ajax/ajax_pfe_find','action=candidateDetails&need_id='+need_id+'&entity_id='+entity_id,function(data){if(data.contact!==''){detail_string+='<div style="padding-top: 4px;"> '+data.contact+'</div>';}
if(data.cat!==''){detail_string+='<div style="padding-top: 4px;"><b>CAT Tools</b>: '+data.cat+'</div>';}
if(data.portfolio>0){detail_string+='<div style="padding-top: 4px;">This user has submitted <a href="/profile/'+entity_id+'?float=1" target="_new">'+data.portfolio+' sample translation(s)</a>.'+'</div>';}
if(data.num_projects>0){detail_string+='<div style="padding-top: 4px;"><b>Project history</b>: '+data.num_projects+' project';detail_string+=data.num_projects==1?'':'s';if(data.num_corroborated>0){detail_string+=', '+data.num_corroborated+' corroborated';}
detail_string+='</div>';}
if(data.credentials!==''){detail_string+='<div style="padding-top: 4px;"><b>Credentials</b>:<br/>'+data.credentials+'</div>';}
if(data.profile!==''){detail_string+='<br/>';detail_string+='<a target="_blank" href="/profile/'+data.profile+'"><div class="icon-user-details"><b>View full profile</b></div></a>';}
details.innerHTML=detail_string;document.getElementById('details_loaded_'+entity_id).value='y';});}
if(document.getElementById("details_link_"+entity_id).innerHTML==="Show More"){document.getElementById("details_link_"+entity_id).innerHTML="Show Less";document.getElementById("img_show_profile_info_down"+entity_id).style.display="none";document.getElementById("img_show_profile_info_up"+entity_id).style.display="inline";}else{document.getElementById("details_link_"+entity_id).innerHTML="More";document.getElementById("img_show_profile_info_up"+entity_id).style.display="none";document.getElementById("img_show_profile_info_down"+entity_id).style.display="inline";}
if($('#qualification_add_'+entity_id).html()!=null){update_qualification_listener();}}
function getMatches(sort_by,sort_order,start,pager){if(typeof(sort_by)==="undefined"){sort_by='kpif';}
if(typeof(sort_order)==="undefined"){sort_order='desc';}
if(sort_by=='yrsexp'&&$('#res_cols_yrsexp').attr("checked")!==true){$('#res_cols_yrsexp').click();}
if(sort_by=='rates'&&$('#res_cols_rates').attr("checked")!==true){$('#res_cols_rates').click();}
if(sort_by=='kpif'&&$('#res_cols_kudoz').attr("checked")!==true){$('#res_cols_kudoz').click();}
hideAllCallouts();document.getElementById('sort_by').value=sort_by;if(sort_by=='kudoz'||sort_by=='kpip'||sort_by=='kpif'||(global_sort_by!=='rates'&&sort_by==='rates')){sort_order='desc';}else if(sort_by==='uname'&&global_sort_by!=='uname'){sort_order='asc';}
document.getElementById('sort_order').value=sort_order;var debug=$('#debug').val();var need_id=$('#need_id').val();var url="/ajax/ajax_pfe_find.php?action=list&need_id="+need_id+"&nshow="+global_nshow+"&match_vendors="+global_match_vendors;if(global_vendorcat_id>0){url+="&vendorcat_id="+global_vendorcat_id;}
if(debug!==''){url+="&debug="+debug;}
if($('#query_generation').val()=="query_mailer"||$('#query_generation').val()=="magnetmail"){url+="&query_generation=y&query_generation_type="+$('#query_generation').val();}
if($('#res_cols_availability').is(':checked')){$('#col_availability').show();}else{$('#col_availability').hide();}
if(sort_by==='yrsexp'&&global_sort_by!=='yrsexp'){sort_order='desc';global_sort_by='yrsexp';}
if(typeof(sort_by)!=='undefined'){url+='&sort_by='+sort_by;$('.sort_controls').css("display","none");$('.sort_label').addClass('link');$('#sort_order_'+sort_by).css("display","");$('#sort_label_'+sort_by).removeClass('link');global_sort_by=sort_by;}
if(start>-1){url+='&start='+start;}
if('browse'===global_mode){url+='&private_vendors_only=true';global_ignore_cache=true;}
if(true===global_ignore_cache){global_ignore_cache=false;url+='&ignore_cache=true';}
if(sort_order!='asc'&&sort_order!='desc'){if(global_sort_order=='desc'){global_sort_order='asc';url+='&sort_order=asc';$('#sort_arrow_'+sort_by+'_down').css("display","none");$('#sort_arrow_'+sort_by+'_up').css("display","");}else{global_sort_order='desc';url+='&sort_order=desc';$('#sort_arrow_'+sort_by+'_down').css("display","");$('#sort_arrow_'+sort_by+'_up').css("display","none");}}else if(sort_order=='desc'){url+='&sort_order=desc';$('#sort_arrow_'+sort_by+'_down').css("display","");$('#sort_arrow_'+sort_by+'_up').css("display","none");}else{url+='&sort_order=asc';$('#sort_arrow_'+sort_by+'_down').css("display","none");$('#sort_arrow_'+sort_by+'_up').css("display","");}
showLoading();if(global_getMatches){global_getMatches.abort();global_getMatches=null;hideLoading();}
global_getMatches=$.ajax({url:url,type:"GET",dataType:"json",error:function(){hideLoading();if(global_getMatches===null){logError(0,"Error retrieving matches","getMatches");errorMessage('Sorry, an error occured when getting search results.','getMatches(\''+sort_by+'\,\''+sort_order+'\',\''+start+'\',\''+pager+'\');');}},success:function(json){if(json.debug!==''){$('#debug_output').html(json.debug);}
if($('#query_generation').val()=="query_mailer"||$('#query_generation').val()=="magnetmail"){if(typeof(json.generated_query)!="undefined"){$('.generated_query').show();if(json.count_all<10000){$('.generated_query').html('<b>Query</b>: <br><textarea style="width:100%;" rows="4">'+json.generated_query.replace(/^\s+|\s+$/g,"")+'</textarea>');if($('#query_generation').val()=="magnetmail"){$('.generated_query').append('<a href="'+url+'&get_csv_file=1">Save result as CSV file</a><br><br>');}}else{$('.generated_query').append('<br>Query requests that match more than 10,000 users <a href="/request">must be submitted through the development factory &raquo;</a><br><br>');}}else $('.generated_query').hide();}
var table=document.getElementById('table_results');var rows=table.rows;var err_message,row,action;while(rows.length>1){table.deleteRow(rows.length-1);}
var show_limit_msg=json.hide_limit_msg?false:true;if(json.count=='Private'){$('#postjob_no_vendors').show();$('#postjob_vendors').hide();$('#sendmessage_no_vendors').show();$('#sendmessage_vendors').hide();$('#batch_no_vendors').show();$('#batch_vendors').hide();if(json.count_all<1){$('.count_all').text('');$('.count_vendors').text('');$('.count_others').text('');}
hideLoading();$('.pfe_pager').empty();row=table.insertRow(table.rows.length);err_message=document.createElement("TD");textnode1=document.createTextNode("");err_message.appendChild(textnode1);err_message.innerHTML='<br/>&laquo;- Private information - please specify additional requirements.<br/><br/>';err_message.className='error_small';err_message.colSpan='6';row.appendChild(err_message);table.appendChild(row);global_getMatches=null;return;}else if(json.count<1){$('#postjob_no_vendors').show();$('#postjob_vendors').hide();$('#postjob_edit').hide();$('#sendmessage_no_vendors').show();$('#sendmessage_vendors').hide();$('#batch_no_vendors').show();$('#batch_vendors').hide();if(json.count_all<1){$('.count_all').text('');$('.count_vendors').text('');$('.count_others').text('');}
hideLoading();$('.pfe_pager').empty();row=table.insertRow(table.rows.length);err_message=document.createElement("TD");textnode1=document.createTextNode("");err_message.appendChild(textnode1);if(json.error==='no_requirements'){$('.count_all').text('');$('.count_vendors').text('');$('.count_others').text('');if(document.location.href.match("redirect_from=dir")!==null){err_message.innerHTML='Welcome to Connect! As a corporate member you have privileged access to use this new search tool.<br/><br/>&laquo; To get started, specify your search criteria to the left.<br><br><font size=1>To switch back to the "classic" ProZ.com directory, <a href="/directory?redirect_from=find">click here</a></font>';err_message.className='error_small';}else if(document.location.href.match("redirect_from=job")!==null){err_message.innerHTML='Welcome to Connect! As a corporate member you have privileged access to use this new job posting system.<br/><br/>&laquo; To get started with your job posting, specify the requirements that eligible candidates must meet. Then click "Post a job" above.<br><br><font size=1>To switch back to the "classic" job posting system, <a href="/?sp=jobs&sp_mode=post&redirect_from=find">click here</a></font>';err_message.className='error_small';}else{err_message.innerHTML='<br/>&laquo;- To get started, specify the requirements that eligible candidates must meet.<br/><br/>';err_message.className='error_small';}}else{err_message.innerHTML='<br/>No vendors match these requirements.<br/><br/>';if(json.count_all>0||json.count_vendors>0||json.count_others>0){$('.count_all').text(' ('+json.count_all+')');$('.count_vendors').text(' ('+json.count_vendors+')');$('.count_others').text(' ('+json.count_others+')');}else{$('.count_all').empty();$('.count_vendors').empty();$('.count_others').empty();}
err_message.className='error';}
err_message.colSpan='6';row.appendChild(err_message);table.appendChild(row);global_getMatches=null;return;}else if(json.count>10000&&'browse'!=global_mode&&show_limit_msg){$('#postjob_no_vendors').show();$('#postjob_vendors').hide();$('#postjob_edit').hide();$('#sendmessage_no_vendors').show();$('#sendmessage_vendors').hide();$('#batch_no_vendors').show();$('#batch_vendors').hide();if(json.count_all<1||json.count>10000){$('.count_all').empty();$('.count_vendors').empty();$('.count_others').empty();}
hideLoading();$('.pfe_pager').empty();row=table.insertRow(table.rows.length);err_message=document.createElement("TD");textnode1=document.createTextNode("");err_message.appendChild(textnode1);global_over_10000='yes';err_message.innerHTML='<br/>&laquo;- Over 10,000 vendors match these requirements.  Please specify additional requirements.<br/><br/>';err_message.colSpan='6';err_message.className='error_small';row.appendChild(err_message);table.appendChild(row);global_getMatches=null;return;}
global_over_10000='no';$('#postjob_no_vendors').hide();$('#postjob_vendors').show();$('#sendmessage_no_vendors').hide();$('#sendmessage_vendors').show();$('#batch_no_vendors').hide();$('#batch_vendors').show();$('.pfe_pager').html(json.pager);rows=[];var i,first,second,third,fourth,fifth,sixth,is_premium;for(i=0;i<json.entities.length;i++){public_profile_eid=json.entities[i].id;first='';if(json.entities[i].photo!==''){first+='<div style="float:right;margin:3px;border:1px solid #CFCEB5;padding:1px;cursor:pointer;">';if(public_profile_eid>0){first+='<a class="link" target="_NEW" href="/profile/'+public_profile_eid+'">';}
first+='<img src="'+json.entities[i].photo+'" width="50px" border="0" alt="profile_photo"/>';if(public_profile_eid>0){first+='</a>';}
first+='</div>';}
if(json.entities[i].pro_tag!==''){first+=json.entities[i].pro_tag;}
is_premium=json.entities[i].is_premium=='y'?'y':'n';if(json.entities[i].membershipRibbon!==''){first+=json.entities[i].membershipRibbon;}
first+='<span style="cursor:pointer;" onClick="getDetails(\''+json.entities[i].id+'\');">';if(json.entities[i].name!==''&&json.entities[i].name!==null){first+='<strong>'+json.entities[i].name+'</strong></span>';}
if(json.entities[i].agency_name!==''&&json.entities[i].agency_name!==null){if(json.entities[i].name!==''&&json.entities[i].name!==null){first+=', ';}
first+='<strong>'+json.entities[i].agency_name+'</strong>';}
if(json.entities[i].verification!==''){first+=' <a href="'+json.entities[i].verification+'" title="Identity Verified">';first+='<img border="0" width="15" height="15" alt="Identity Verified" src="/images/verified_check_small.gif"/></a>';}
first+='<br/>';if(json.entities[i].tagline!==''&&json.entities[i].tagline!==null){first+='<div style="padding-top: 4px;">'+json.entities[i].tagline+'</div>';}
first+='<div id="is_vendor_'+json.entities[i].id+'" style="padding-top: 4px;color: rgb(116, 143, 118); font-size: 12px;';if(json.entities[i].is_vendor!=='y'){first+='display: none;';}
first+='"><b>'+global_company_name+' vendor</b></div>';first+='<div style="padding-top: 4px;font-weight:700;color:#583F7F;';if(json.entities[i].candidate!=='y'){first+='display:none;';}
first+='" id="candidate_label_'+json.entities[i].id+'">Candidate (<a href="/connect/need/'+need_id+'/candidates">view all</a>)</div>';first+='<div style="padding-top:12px;">';var displayed_cv=false;var displayed_skype=false;if(json.entities[i].cv_app!==''){first+='<a class="link" target="_new" title="View CV/resume" href="'+json.entities[i].cv_app+'"><div style="display:inline;" class="icon-cv">From app</div></a>';displayed_cv=true;}
if(json.entities[i].cv_link!==''){first+='<a class="link" target="_new" title="View CV/resume" href="'+json.entities[i].cv_link+'"><div style="display:inline;padding-left:20px;" class="icon-cv"></div></a>';displayed_cv=true;}
if(json.entities[i].skype!==''){if(displayed_cv===true){first+='<div style="color:#CFCFC2;display:inline;padding:0px 5px 0px 5px;">|</div>';}
first+='<a href="skype:'+json.entities[i].skype+'?call"><div style="display:inline;padding-left:20px;" class="icon-skype"></div></a>';displayed_skype=true;}
if(typeof(json.entities[i].phone)!=="undefined"){if(displayed_skype===true){first+='<div style="color:#CFCFC2;display:inline;padding:0px 5px 0px 5px;">|</div>';}
first+='<div style="display:inline;padding-left:1px;">'+json.entities[i].phone+'</div>';}
if(typeof(json.entities[i]['contact_info'])!=='undefined'){if(json.entities[i]['contact_info']['country']!=''||json.entities[i]['contact_info']['city']!=''){first+='<div style="padding-bottom: 4px;">Location: ';}
if(json.entities[i]['contact_info']['country']!=''){first+=json.entities[i]['contact_info']['country'];}
if(json.entities[i]['contact_info']['city']!=''){if(json.entities[i]['contact_info']['country']!='')first+=', ';first+=json.entities[i]['contact_info']['city'];}
first+='</div>';}
if(typeof(json.entities[i]['local_time'])!=='undefined'){first+='<div style="padding-bottom: 4px;">Local time: '+json.entities[i]['local_time']+'</div>';}
if(public_profile_eid!==0){if(displayed_cv===true){first+='<div style="color:#CFCFC2;display:inline;padding:0px 5px 0px 5px;">|</div>';}
first+='<div style="display:inline;" class="icon-user-details">';switch(json.entities[i].account_type){case'2':first+='<a target="_NEW" title="View freelancer profile" href="/profile/'+public_profile_eid+'">';first+='View freelancer profile';first+='</a>';break;case'1':first+='<a target="_NEW" title="View company profile" href="/profile/'+public_profile_eid+'?sp_mode=corp_profile">';first+='View company profile';first+='</a>';break;case'3':first+='<a target="_NEW" title="View freelancer profile" href="/profile/'+public_profile_eid+'">';first+='Freelancer profile';first+='</a> - ';first+='<a target="_NEW" title="View company profile" href="/profile/'+public_profile_eid+'?sp_mode=corp_profile">';first+='Company profile';first+='</a>';break;default:break;}
first+='</div>';}
first+='</div>';if(json.entities[i].qualification!==''){first+='<div style="padding-top: 4px;">'+json.entities[i].qualification+'</div>';}
if(global_nliv!==true){first+='<div style="padding-top: 4px;">'+json.entities[i].notes+'</div>';}
second='';second='<table border="0" cellpadding="0" cellspacing="0" class="dir_details">';if(json.entities[i].relevant_pairs!==''){second+='<td class="lft_t">';second+='Pair:';second+='</td><td>';second+=json.entities[i].relevant_pairs;second+='</td></tr>';}
if(json.entities[i].native_langs!==''){second+='<tr>';second+='<td class="lft_t">Native:</td><td>'+json.entities[i].native_langs+'</td>';second+='</tr>';}
if(json.entities[i].job_cost!==''&&json.entities[i].job_cost!='null'){second+='<tr>';second+='<td class="lft_t">Est. cost:</td><td>'+json.entities[i].job_cost+'</td>';second+='</td></tr>';}
if(json.entities[i].rates!==''){second+='<tr>';second+='<td class="lft_t">';if(sort_by=='rates')second+='<div style="font-weight:700;">';second+='Rates:';if(sort_by=='rates')second+='</div>';second+='</td><td>';if(json.entities[i].rates=='hidden'){second+='<div style="float:left;"><span style="cursor: default;" onmouseover="this.style.cursor=\'default\'; tooltip_class = false; fixedtooltip(\'<div style=&quot;width:200px;&quot;><div class=&quot;top&quot;> </div><div class=&quot;middle&quot; align=&quot;left&quot;>This candidate has entered rates, but has chosen to keep them private.</div><div class=&quot;bottom&quot;> </div></div>\', this, event, \'200px\')" onmouseout="delayhidetip()"><img src="/images/ptc/question_mark.gif" border="0"></span></div> ';second+='<i>Rates hidden</i>';}else if(json.entities[i].rates=='hidden_non_corp'){second+='<div style="float:left;"><span style="cursor: default;" onmouseover="this.style.cursor=\'default\'; tooltip_class = false; fixedtooltip(\'<div style=&quot;width:200px;&quot;><div class=&quot;top&quot;> </div><div class=&quot;middle&quot; align=&quot;left&quot;>Average rates should be visible only to corporate members.</div><div class=&quot;bottom&quot;> </div></div>\', this, event, \'200px\')" onmouseout="delayhidetip()"><img src="/images/ptc/question_mark.gif" border="0"></span></div> ';second+='<i>Rates hidden</i>';}else{second+='<div style="float:left;"><span style="cursor: default;" onmouseover="this.style.cursor=\'default\'; tooltip_class = false; fixedtooltip(\'<div style=&quot;width:200px;&quot;><div class=&quot;top&quot;> </div><div class=&quot;middle&quot; align=&quot;left&quot;>Please note that these rates do not necessarily reflect the rates that will be negotiated on real-world projects. Currently there is no facility for users to specify detailed rates based on service type, expertise required, surcharges, minimum fees, etc., or to differentiate between rates to agencies or end customers.</div><div class=&quot;bottom&quot;> </div></div>\', this, event, \'200px\')" onmouseout="delayhidetip()"><img src="/images/ptc/question_mark.gif" border="0"></span></div> ';second+=''+json.entities[i].rates+'';}
second+='</td></tr>';}
if((json.entities[i].yrsexp!==''&&json.entities[i].yrsexp!='0')||json.entities[i].yrs_at_proz!='0'){second+='<tr><td class="lft_t">';second+='<div style="';if(sort_by=='yrsexp'){second+='font-weight:700;';}
second+='">Exp:</div>';second+='</td><td>';exp_str='';if(json.entities[i].yrsexp!==''&&json.entities[i].yrsexp!='0'){exp_str+=json.entities[i].yrsexp+' years';}
if(json.entities[i].yrs_at_proz!='0'){if(json.entities[i].yrsexp!==''&&json.entities[i].yrsexp!='0'){exp_str+=', '+json.entities[i].yrs_at_proz+' at ProZ.com';}else if(json.entities[i].yrs_at_proz!==''){exp_str+=json.entities[i].yrs_at_proz+' years at ProZ.com';}}
second+=exp_str;second+='</td></tr>'}
var displayed_kudoz_by_pair_or_field=false;if(json.entities[i].kudoz_relevant!==''||json.entities[i].kudoz_pip!==''||(json.entities[i].kudoz_all!==''&&json.entities[i].kudoz_all!='0'&&json.entities[i].kudoz_all!=null)){second+='<tr><td class="lft_t">';second+='<span class="kudoz">KudoZ: </span>';second+='</td><td>';}
if(json.entities[i].kudoz_relevant!==''){second+='<span class="kudoz"><a href="javascript:popupwin=window.open(\'/?sp=profmini&eid_s='+json.entities[i].profile+'&sp_mode=kudoz\',\'Info\',\'width=380,height=420,scrollbars=yes,resize=yes\');popupwin.focus();"><span title="PRO KudoZ points in this field and language pair.">'+json.entities[i].kudoz_relevant+'</span></a> in pair/field</div>';displayed_kudoz_by_pair_or_field=true;}
if(json.entities[i].kudoz_pip!=''){second+='<span class="kudoz"';if(sort_by=='kudoz'||sort_by=='kpif'||sort_by=='kpip'){}
second+='><a href="javascript:popupwin=window.open(\'/?sp=profmini&eid_s='+json.entities[i].profile+'&sp_mode=kudoz\',\'Info\',\'width=380,height=420,scrollbars=yes,resize=yes\');popupwin.focus();"><span title="PRO KudoZ in this language pair.">'+json.entities[i].kudoz_pip+'</span></a> in pair</span>';displayed_kudoz_by_pair_or_field=true;}
if(json.entities[i].kudoz_all!=''&&json.entities[i].kudoz_all!='0'&&json.entities[i].kudoz_all!=null&&!displayed_kudoz_by_pair_or_field){second+='<span class="kudoz"';if(sort_by=='kudoz'||sort_by=='kpif'||sort_by=='kpip'){}
second+='><a href="javascript:popupwin=window.open(\'/?sp=profmini&eid_s='+json.entities[i].profile+'&sp_mode=kudoz\',\'Info\',\'width=380,height=420,scrollbars=yes,resize=yes\');popupwin.focus();"><span title="Total PRO KudoZ points. Click for details.">'+json.entities[i].kudoz_all+'</span></a> total';second+='</span>';}
if(json.entities[i].kudoz_relevant!==''||json.entities[i].kudoz_pip!==''||(json.entities[i].kudoz_all!==''&&json.entities[i].kudoz_all!='0'&&json.entities[i].kudoz_all!=null)){second+='</td></tr>';}
if(json.entities[i].wwa_y>0){second+='<tr><td colspan="2">';second+='<div class="icon-chat">';second+='<span style="cursor: default;" onmouseover="this.style.cursor=\'default\'; tooltip_class = false; fixedtooltip(\'<div style=&quot;width:200px;&quot;><div class=&quot;top&quot;> </div><div class=&quot;middle&quot; align=&quot;left&quot;>Willingness to work again (WWA) is feedback from clients and colleagues with they have worked.</div><div class=&quot;bottom&quot;> </div></div>\', this, event, \'200px\')" onmouseout="delayhidetip()"><img src="/images/pfe2/question_mark.gif" border="0"></span>';second+=' <a href="javascript:msgWindow = window.open(\'/?sp=provider_popup&sp_mode=view&entry_maker_id='+global_corp_eid+'&eid_s='+json.entities[i].profile+'&float=y\',\'feedback\', \'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=1,width=650,height=460\');msgWindow.focus();">';second+=json.entities[i].wwa_y+' client'+(json.entities[i].wwa_y!=1?'s':'')+' willing to work again';second+='</a></div>';second+='</td></tr>';}
if(typeof(json.entities[i].completeness_percentage)!=='undefined'){second+='<tr>';second+='<td class="lft_t">Completeness:</td><td>'+json.entities[i].completeness_percentage+'</td>';second+='</tr>';}
second+='</table>';third='';if(json.entities[i].availability!==''){third+=renderCalendar(json.entities[i].availability);}
fourth='';fifth='';fifth+='<div id="dir_menu_id"><div class="dir-menu" style="padding:0px 0px 2px 5px;"><span style="display:none;" id="img_show_profile_info_up'+json.entities[i].id+'"><img hspace="3" src="/images/ptc/icon-arrow-up.gif"></span>';fifth+='<span style="display:inline" id="img_show_profile_info_down'+json.entities[i].id+'"><img hspace="3" src="/images/ptc/icon-arrow-down.gif"></span>';fifth+=' <span class="link profile_details" id="details_link_'+json.entities[i].id+'" onClick="getDetails(\''+json.entities[i].id+'\');">More</span></div>|';if(global_nliv!==true){fifth+='<div class="icon-notepad dir-menu"><a href="javascript:editNote(\''+json.entities[i].id+'\');">Add note</a></div>|';}else{fifth+='<div class="icon-notepad dir-menu"><span class="link nliv">Add note</span></div>|';}
if(true===global_nliv){fifth+='<div class="icon-mail dir-menu"><span class="link nliv">Contact</span></div> ';fifth+='| <div class="icon-heart dir-menu"><span class="link nliv">Add to my vendors</span></div> ';fifth+='| <div class="icon-add-user dir-menu"><span class="link nliv">Add to candidates</span></div>';}else{fifth+='<div class="icon-mail dir-menu"><span class="link" onClick="nameNeedContact(\''+json.entities[i].id+'\',$(this).position());">Contact</span></div>';if(json.entities[i].is_vendor!=='y'){if(true===global_connect_subscriber){fifth+='<span id="vendor_link_'+json.entities[i].id+'">|<div class="icon-heart dir-menu"><span class="link" onClick="popupwin=window.open(\'/?sp=pfe_popup&find_refresh=y&sp_mode=edit_vendor&sendToParent=true&vendor_eid='+json.entities[i].id+'\',\'edit_vendor\',\'width=800,height=600,scrollbars=yes,resize=yes,status=1\',false);popupwin.focus();">Add to vendors</span></span></div>';}}else{fifth+='|<div class="icon-edit-user dir-menu"><span class="link" onClick="popupwin=window.open(\'/?sp=pfe_popup&find_refresh=y&sp_mode=edit_vendor&entity_id='+json.entities[i].private_vendor_entity_id+'&no_vendor_db_link=1\',\'edit_vendor\',\'width=800,height=600,scrollbars=yes,resize=yes\',false);popupwin.focus();">Edit vendor</span></div>';}
fifth+='|<span id="candidate_controls_'+json.entities[i].id+'">';if(json.entities[i].candidate=='y'){fifth+='<div class="icon-remove-user dir-menu"><span class="link" id="remove_from_candidates_'+json.entities[i].id+'" onclick="removeCandidate(\''+json.entities[i].id+'\');">Remove from candidates</span></div>';}else{fifth+='<div class="icon-add-user dir-menu"><span class="link" id="add_to_candidates_'+json.entities[i].id+'" onclick="addCandidate(\''+json.entities[i].id+'\',$(this).position());">Add to candidates</span></div>';}}
fifth+='</span>';if(typeof(json.entities[i].decline_link)!=='undefined'&&json.entities[i].decline_link!==''){fifth+=' | '+json.entities[i].decline_link;}
if(json.entities[i].pro_tag_review!==''){if(json.entities[i].pro_tag_review==='can_review'){fifth+=' | <div class="icon-pro-small dir-menu"><a target="_blank" href="/?sp=pro_peers&from=connect_directory&user_id='+json.entities[i].id+'">Review this user</a></div>';}else if(json.entities[i].pro_tag_review==='already_reviewed'){fifth+=' | <div class="icon-pro-small dir-menu">Already reviewed</div>';}}
if(json.entities[i].times_contacted>0){fifth+='<input type="hidden" value="y" id="contacted_'+json.entities[i].id+'"/>';}else{fifth+='<input type="hidden" value="n" id="contacted_'+json.entities[i].id+'"/>';}
fifth+='</div></div>';sixth='<div id="details_content_'+json.entities[i].id+'" class="details_content"><img src="/images/wikiwords/loading.gif" alt="loading"/></div>';sixth+='<input type="hidden" value="n" id="details_loaded_'+json.entities[i].id+'"/>';$("#table_results").append(generateResultRow(first,second,third,fourth,fifth,sixth,i,json.entities[i].id,is_premium));}
if(json.count_all==='>10k'&&json.count_others==='>10k'){$('.count_others').html('');$('.count_all').html('');}else{$('.count_others').html(' ('+json.count_others+')');$('.count_all').html(' ('+json.count_all+')');}
if('browse'===global_mode){$('.count_vendors').html(' ('+number_format(json.count_vendors,0,'.',',')+' out of '+number_format($('#total_vendors').val(),0,'.',',')+')');}else{$('.count_vendors').html(' ('+number_format(json.count_vendors,0,'.',',')+')');}
if(global_expand_profile_details){showProfileDetails();}
if(true===global_nliv){$(".nliv").click(function(event){bindNliv(event);});}
hideLoading();global_getMatches=null;}});}
function bindNliv(event){var tPosX=$(window).width()/2-150;var tPosY=event.pageY-150;$("#nliv_login").css({position:"absolute",top:tPosY,left:tPosX}).show();}
function markAsVendor(entity_id){$('#vendor_link_'+entity_id).hide();$('#is_vendor_'+entity_id).show();}
function row2queryString(row){return $('#req_builder_3 [name^="'+row+'"]').serialize().replace(/%5B/g,'[').replace(/%5D/g,']');}
function updateAddAnother(){var table=document.getElementById("requirement_controls");var counter=0;var row_id,crit,lang_exception;while(counter<table.rows.length){lang_exception=false;crit=table.rows[counter].cells[0].id.split('|');row_id=table.rows[counter].id;if(row_id!==''){crit=crit[1];if(crit=='lang_service'){lang_exception=(document.getElementById(row_id+'_service_id').value==='')?true:false;}
$('#'+row_id+'_add_more').hide();if(checkRowForError(row_id,crit)&&!lang_exception&&!in_array(crit,['entity_statistics','just_one_native','exclude_admin','pro_tag','yrs_at_proz','endorse_conduct','contest_winner','min_rate','vendor_qualification','yrs_experience','account_type','resume','complete_profile','wwa','membership_type','text','vendors','vendor_type','availability','payment','company_size','standards_registry','years_in_business','corp_service','pro_peer_opinions','profile_last_updated','conferences','site_activity'])){$('#'+getRowOfLastCrit(crit)+'_add_more').show();}}
counter++;}}
function getRowOfLastCrit(crit_type){var table=document.getElementById("requirement_controls");var counter=0;var row_id,crit;var retval=0;while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|');row_id=table.rows[counter].id;crit=crit[1];if(crit===crit_type){retval=counter;}
counter++;}
retval=table.rows[retval].id;return retval;}
function clearReq(crit_type){var need_id=$('#need_id').val();$('#'+crit_type+'_label').empty();document.getElementById(crit_type).className="requirement_name";if(crit_type==='language_pair'){updateNativeLanguageLabel();$('#requirement_controls td[id $= "|language_pair_all" ]').parent().remove();}
$('#requirement_controls td[id $= "|'+crit_type+'" ]').parent().remove();showSaving();$.ajax({type:"POST",url:"/ajax/ajax_pfe_find.php",data:"action=delReq&need_id="+need_id+"&crit_type="+crit_type});hideSaving();addRow("XXXXX"+crit_type,true);}
function clearRow(row_id){var table=document.getElementById("requirement_controls");var crit_type=$('#'+row_id).children()[0].id.split('|')[1];if(crit_type==='language_pair_all'){crit_type='language_pair';}
var crit_id=document.getElementById(row_id+'[crit_id]').value;var need_id=$('#need_id').val();showSaving();$.ajax({type:"POST",url:"/ajax/ajax_pfe_find.php",data:"action=delCrit&need_id="+need_id+"&crit_id="+crit_id});document.getElementById("requirement_controls").deleteRow(document.getElementById(row_id).rowIndex);var counter=0;var num_crit=0;var crit;while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|')[1];if(crit==='language_pair_all'){crit='language_pair';}
if(crit===crit_type){num_crit++;}
counter++;}
updateAddAnother();hideSaving();action='action=getReqLabel&crit_type='+crit_type+'&need_id='+need_id;$.getJSON('/ajax/ajax_pfe_find',action,function(data){$('#'+crit_type+'_label').html((data.label!==''?' &raquo; '+data.label:''));});if(num_crit===0){addRow("XXXXX"+crit_type,true);}else{getMatches(global_sort_by,global_sort_order);updateControls();}}
function addRow(content,hide_criteria){var table=document.getElementById("requirement_controls");var crit_type=content.substring(5);if(crit_type==='language_pair_all'){content='crit_language_pair';crit_type='language_pair';}
var counter=0;var target=0;var first_instance=-1;var last_instance;var insert_after=-1;var everythingIsFine=true;var crit;var row_id;var existing_match_type='any';var parent_crit_type=-1;showLoading();document.body.style.cursor='wait';while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|');crit=crit[1];if(crit==='language_pair'&&crit_type==='native_lang'){if(document.getElementById(table.rows[counter].id+"_target_lang").value){default_value=document.getElementById(table.rows[counter].id+"_target_lang").value;}}
if(crit===crit_type){if(first_instance===-1){existing_match_type=document.getElementById(table.rows[counter].id+'[match_type]').value;first_instance=counter;}
insert_after=counter+1;}
if(table.rows[counter].cells[0].id==crit_type){parent_crit_type=counter+1;}
counter++;}
if(insert_after==-1){insert_after=parent_crit_type;}
row_id=new Date();row_id="row_"+row_id.getTime();$.getJSON('/ajax/ajax_pfe_find','action=critGetEditHTML&crit='+crit_type+'&row_id='+row_id+'&match_type='+existing_match_type,function(data){var remove_icon='<img src="/images/pfe2/greyscale_12.gif" alt="delete" border=0/>';var remove_link='<a title="Remove this requirement" style="text-decoration:none; color:red; text-align:center; vertical-align:middle; cursor:pointer;" href="javascript:;" onclick="deleteRow(this)">"+remove_icon+"</a>';var default_value=null;var counter=0;var target=0;var row;var critForm;var textnode3;row=table.insertRow(table.rows.length);row.id=row_id;critForm=document.createElement("TD");textnode3=document.createTextNode("crit_"+crit_type);critForm.appendChild(textnode3);critForm.innerHTML=data.html;critForm.id="form_"+row_id+"|"+crit_type;row.appendChild(critForm);if(insert_after==-1){insert_after=parent_crit_type;while(counter<table.rows.length){if(table.rows[counter].cells[0].id==crit_type){insert_after=counter+1;}
counter++;}}
table.insertBefore(row,table.rows[insert_after]);document.body.style.cursor='auto';if(hide_criteria===true){$('#'+crit_type).click().removeClass('requirement_name_selected');}
hideLoading();updateAddAnother();updateControls();getMatches(global_sort_by,global_sort_order);});}
function toggle_box(id){var visibility,arrow_visibility;var target=document.getElementById(id);if(target.style.display=="none"){visibility='';arrow_visibility='none';$('#'+id+'_label').removeClass('emphasized');}else{visibility='none';arrow_visibility='';$('#'+id+'_label').addClass('emphasized');}
target.style.display=visibility;document.getElementById(id+'_more').style.display=arrow_visibility;document.getElementById(id+'_arrow').style.display=arrow_visibility;}
function toggle_visibility(crit_type,tag){var counter=0;var visibility;var arrow_visibility,crit;var table=document.getElementById("requirement_controls");while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|');crit=crit[1];if(crit===crit_type){if(tag==='th'){if(table.rows[counter].style.display==="none"){visibility='';arrow_visibility='none';$('#'+crit).removeClass('emphasized');$("#req_tag_"+crit+"").removeClass('dir_tab_off');$("#req_tag_"+crit+"").addClass('dir_tab_on');}else{visibility='none';arrow_visibility='';$('#'+crit).addClass('emphasized');$("#req_tag_"+crit+"").removeClass('dir_tab_on');$("#req_tag_"+crit+"").addClass('dir_tab_off');}}else{if(table.rows[counter].style.display==="none"){visibility='none';arrow_visibility='';$('#'+crit).addClass('emphasized');$("#req_tag_"+crit+"").removeClass('dir_tab_off');$("#req_tag_"+crit+"").addClass('dir_tab_on');}else{visibility='';arrow_visibility='none';$('#'+crit).removeClass('emphasized');$("#req_tag_"+crit+"").removeClass('dir_tab_on');$("#req_tag_"+crit+"").addClass('dir_tab_off');}}
table.rows[counter].style.display=visibility;$("#arrow_d_"+crit).css("display",arrow_visibility);$("#arrow_u_"+crit).css("display",visibility);}
counter++;}}
function toggle_cost_visibility(type){var arrow_visibility;if(document.getElementById(type).style.display==="none"){visibility='';arrow_visibility='none';$('#label_'+type).removeClass('emphasized');}else{visibility='none';arrow_visibility='';$('#label_'+type).addClass('emphasized');}
document.getElementById(type).style.display=visibility;document.getElementById('arrow_'+type).style.display=arrow_visibility;}
function language_pair_errorCheck(row_id){var source=document.getElementById(row_id+'_source_lang');var target=document.getElementById(row_id+'_target_lang');if((source.value&&target.value)||(!source.value&&!target.value)){return true;}else{return false;}}
function availability_errorCheck(row_id){var availability_avail_from=document.getElementById(row_id+'_availability_avail_from');var availability_avail_to=document.getElementById(row_id+'_availability_avail_to');if(availability_avail_from.value&&availability_avail_to.value){if(availability_avail_from.value==='dd/mm/yy'&&availability_avail_to.value==='dd/mm/yy'){return false;}else if(availability_avail_from.value==='dd/mm/yy'&&availability_avail_to.value!=='dd/mm/yy'){return false;}else{return true;}}else if(availability_avail_from.value!=='dd/mm/yy'){return true;}else{return false;}}
function cat_tool_errorCheck(row_id){if($('#'+row_id+'_cat_tool').val()===''){return false;}else{return true;}}
function name_errorCheck(row_id){if($('#'+row_id+'_name').val()===''){return false;}else{return true;}}
function credential_errorCheck(row_id){if($('#'+row_id+'_credential').val()===''){return false;}else{return true;}}
function disc_spec_errorCheck(row_id){if($('#'+row_id+'_disc_all').val()===''){return false;}else{return true;}}
function native_lang_errorCheck(row_id){if($('#'+row_id+'_native_lang').val()===''){return false;}else{return true;}}
function checkRowForError(row_id,crit_type){var retval=true;switch(crit_type){case'language_pair':retval=language_pair_errorCheck(row_id);break;case'availability':retval=availability_errorCheck(row_id);break;case'cat_tool':break;case'name':retval=name_errorCheck(row_id);break;case'credential':break;case'disc_spec':break;case'native_lang':break;default:break;}
return retval;}
function onChangeCountryCodeCrit(row_id,country,region,city,distance){var loading_html='<img src=\"/images/wikiwords/loading.gif\"><font size=1>Loading...</font>';if(country!==''){$('#'+row_id+'_geo_country_code').selectOptions(country);}
disableDistanceOp(row_id);var cc=$('#'+row_id+'_geo_country_code').val();if(cc=='us'||cc=='ca'){$('#'+row_id+'_geo_span_region_select').html(loading_html);$('.'+row_id+'_geo_region_row').show();if(cc=='us'){$('#'+row_id+'_geo_region_label').html('State:');}else if(cc=='ca'){$('#'+row_id+'_geo_region_label').html('Province:');}}else{$('.'+row_id+'_geo_region_row').hide();$('#'+row_id+'_geo_region_id').val('');}
$('#'+row_id+'_geo_span_city_select').html(loading_html);$.ajax({type:'GET',dataType:'json',url:'/ajax/ajax_geo.php',data:'op=get_country_data&form_type=search&row_id='+row_id+'&country_code='+cc,success:function(json){if(json.country_code==='us'||json.country_code==='ca'){$('#'+row_id+'_geo_span_region_select').html(json.region_select_html);$('.'+row_id+'_geo_region_row').show();}else{$('.'+row_id+'_geo_region_row').hide();}
if(json.city_select_html){$('#'+row_id+'_geo_span_city_label').css('color','black');$('#'+row_id+'_geo_span_city_select').html(json.city_select_html);}else{$('#'+row_id+'_geo_span_city_label').css('color','gray');if(!json.country_code){$('#'+row_id+'_geo_span_city_select').html('<i style="color:gray;">(Select a country first)</i>');}else if(json.country_code==='us'){$('#'+row_id+'_geo_span_city_select').html('<i style="color:gray;">(Select a state first)</i>');}else if(json.country_code==='ca'){$('#'+row_id+'_geo_span_city_select').html('<i style="color:gray;">(Select a province first)</i>');}else{$('#'+row_id+'_geo_span_city_select').html('<i style="color:gray;">(No cities listed in this country)</i>');}}
if(region!==''){$('#'+row_id+'_geo_region_id').selectOptions(region);onChangeRegionIdCrit(row_id,city,distance,true);}else if(city!==''){$('#'+row_id+'_geo_city_id').selectOptions(city);onChangeCityIdCrit(row_id);if(distance!==''){$('#'+row_id+'_geo_distance').selectOptions(distance);}
updateCount(row_id);}else{updateCount(row_id);}}});}
function onChangeRegionIdCrit(row_id,city,distance,save){var selected_cc=$('#'+row_id+'_geo_country_code').val();if(selected_cc==="us"||selected_cc==="ca"){disableDistanceOp(row_id);$('#'+row_id+'_geo_span_city_select').html('<img src=\"/images/wikiwords/loading.gif\"><font size=1>Loading...</font>');$.ajax({type:'GET',dataType:'json',url:'/ajax/ajax_geo.php',data:'op=get_region_data&row_id='+row_id+'&form_type=search&region_id='+$('#'+row_id+'_geo_region_id').val(),success:function(json){$('#'+row_id+'_geo_span_city_label').css('color','black');$('#'+row_id+'_geo_span_city_select').html(json.city_select_html);if(city!==''){$('#'+row_id+'_geo_city_id').selectOptions(city);onChangeCityIdCrit(row_id);if(distance!==''){$('#'+row_id+'_geo_distance').selectOptions(distance);}
updateCount(row_id);}else{if(save===true){updateCount(row_id);}}}});}}
function onChangeCityIdCrit(row_id){if($('#'+row_id+'_geo_city_id').val()===''){disableDistanceOp(row_id);}else{enableDistanceOp(row_id);}}
function disableDistanceOp(row_id){$('#'+row_id+'_geo_distance_label').css('color','gray');$('#'+row_id+'_geo_distance_select').html('<i style="color:gray;">(Select a city first)</i>');}
function enableDistanceOp(row_id){$('#'+row_id+'_geo_distance_label').css('color','black');$('#'+row_id+'_geo_distance_select').html('<select name="'+row_id+'[geo_distance]" onChange="updateCount(\''+row_id+'\');" id="'+row_id+'_geo_distance" ><option value=0></option><option value=10>Within 10 miles</option><option value=30>Within 30 miles</option><option value=50>Within 50 miles</option><option value=100>Within 100 miles</option></select>');}
function onChangeCATTool(sel,row){var software_id=sel.options[sel.selectedIndex].value;if(software_id==3){document.getElementById(row+"_other_cat_tool").disabled=false;document.getElementById(row+"_other_cat_tool_label").color='black';document.getElementById(row+"_other_cat_tool").focus();document.getElementById(row+"_sdl_trados_cert").style.display='none';document.getElementById(row+"_sdlx_cert").style.display='none';}else if(software_id==1){document.getElementById(row+"_sdl_trados_cert").style.display='block';document.getElementById(row+"_sdlx_cert").style.display='none';document.getElementById(row+"_other_cat_tool").disabled=true;document.getElementById(row+"_other_cat_tool_label").color='gray';}else if(software_id==9){document.getElementById(row+"_sdlx_cert").style.display='block';document.getElementById(row+"_sdl_trados_cert").style.display='none';document.getElementById(row+"_other_cat_tool").disabled=true;document.getElementById(row+"_other_cat_tool_label").color='gray';}else{document.getElementById(row+"_sdl_trados_cert").style.display='none';document.getElementById(row+"_sdlx_cert").style.display='none';document.getElementById(row+"_other_cat_tool").disabled=true;document.getElementById(row+"_other_cat_tool_label").color='gray';}}
function onChangeSoftwareId(sel,row){var software_id=sel.options[sel.selectedIndex].value;if(software_id==14){$("#"+row+"_other_software").removeAttr('disabled').focus();document.getElementById(row+"_other_software_label").color='black';}else{$("#"+row+"_other_software").attr("disabled","disabled").val("");document.getElementById(row+"_other_software_label").color='gray';}}
function updateBoolean(row_id){var table=document.getElementById("requirement_controls");var crit_type=table.rows[row_id].cells[0].id.split('|')[1];var source_boolean=document.getElementById(row_id+'[match_type]');var target_value;if(source_boolean.value==='any'){target_value='all';}else{target_value='any';}
if(crit_type=='location'){target_value='any';}
source_boolean.value=target_value;var counter=0;var targetId,target,crit;while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|');crit=crit[1];if(crit_type===crit){targetId=table.rows[counter].id+'[match_type]';target=document.getElementById(targetId);if(target){target.value=target_value;if(target_value=='any'){document.getElementById('match_type_text_'+table.rows[counter].id).innerHTML='<span style="cursor: pointer; color:#bbb;" onclick="updateBoolean(\''+table.rows[counter].id+'\');">AND /</span> <b>OR</b>';document.getElementById(crit+'_label').innerHTML=document.getElementById(crit+'_label').innerHTML.replace(/ AND /g,' OR ');}else{document.getElementById('match_type_text_'+table.rows[counter].id).innerHTML='<b>AND</b> / <span style="cursor: pointer; color:#bbb;" onclick="updateBoolean(\''+table.rows[counter].id+'\');">OR</span>';document.getElementById(crit+'_label').innerHTML=document.getElementById(crit+'_label').innerHTML.replace(/ OR /g,' AND ');}}
if(crit_type=='location'){document.getElementById('match_type_text_'+table.rows[counter].id).innerHTML='<b>OR</b>';target.value='any';}}
counter++;}
toggleBoolean(row_id);getMatches(global_sort_by,global_sort_order);updateAddAnother();}
function countCritType(crit_type){var table=document.getElementById("requirement_controls");var counter=0;var critCount=0;var crit;while(counter<table.rows.length){crit=table.rows[counter].cells[0].id.split('|')[1];if(crit_type.toUpperCase()===crit.toUpperCase()){critCount++;}
counter++;}
return critCount;}
function showAllLangs(row_id){var crit_id=document.getElementById(row_id+'[crit_id]').value;var need_id=$('#need_id').val();var current_source=$('#'+row_id+'_source_lang').val();var current_target=$('#'+row_id+'_target_lang').val();var current_native=$('#'+row_id+'_native_lang').val();var current_emphasis=$('#'+row_id+'_emphasis').val();var action='action=critGetEditHTML&crit=language_pair&row_id='+row_id+'&language_pair_all=true&crit_id='+crit_id;if(current_source!==''){action+='&source='+current_source;}
if(current_target!==''){action+='&target='+current_target;}
if(current_native!==''){action+='&native='+current_native;}
action+='&emphasis='+current_emphasis;$.getJSON('/ajax/ajax_pfe_find',action,function(data){document.getElementById(row_id).cells[0].innerHTML=data.html;updateAddAnother();updateControls();});}
function updateControls(){var table=document.getElementById("requirement_controls");var crit,controls,lastrow;var counter=0;while(counter<table.rows.length){if(document.getElementById(table.rows[counter].id+'_boolean_controls')!==null){crit=table.rows[counter].cells[0].id.split('|')[1];document.getElementById(table.rows[counter].id+'_boolean_controls').style.display='';document.getElementById(table.rows[counter].id+'_clear').style.display='none';lastrow=getRowOfLastCrit(crit);document.getElementById(table.rows[lastrow].id+'_boolean_controls').style.display='none';if(crit!=='membership_type'){document.getElementById(table.rows[lastrow].id+'_clear').style.display='';}else{if(true!==global_nliv&&document.getElementById(table.rows[counter].id+'[membership]').checked){document.getElementById(table.rows[lastrow].id+'_clear').style.display='';}}}
counter++;}}
function showLoading(){global_loading_count++;$('.loading').show();}
function hideLoading(){global_loading_count--;if(global_loading_count<=0){$('.loading').hide();global_loading_count=0;}}
function showSaving(){global_saving_count++;$('.saving').show();}
function hideSaving(){global_saving_count--;if(global_saving_count<=0){$('.saving').hide();global_saving_count=0;}}
function expandNotes(eid){$("#notes_full_"+eid).show();$("#notes_excerpt_"+eid).hide();}
function contractNotes(eid){$("#notes_full_"+eid).hide();$("#notes_excerpt_"+eid).show();}
function editNote(eid_s,note_id){var id="note_edit_"+eid_s;$("#"+id).show().draggable();$("#note_edit_content_"+eid_s).load("/ajax/ajax_pfe_notes",{op:"edit",note_id:(typeof(note_id)!="undefined"?note_id:""),corp_eid:global_corp_eid,notee_id:eid_s});}
function hideNotesBox(eid_s){$("#note_edit_"+eid_s).hide();}
function saveNote(eid_s){$("#note_"+eid_s).load("/ajax/ajax_pfe_notes",{op:"save",note_id:$("#edit_note_id_"+eid_s).val(),corp_eid:global_corp_eid,notee_id:eid_s,note_text:$("#note_text_"+eid_s).val(),excerpt_len:75},hideNotesBox(eid_s));}
function delNote(eid_s,note_id){$("#note_"+eid_s).load("/ajax/ajax_pfe_notes",{op:"del",note_id:note_id,corp_eid:global_corp_eid,notee_id:eid_s,excerpt_len:75});}
function onChangeToOthers(sel,row,id,btn){var order_row=sel.options[sel.selectedIndex].text;if(order_row=="Other"){document.getElementById(row+"_"+id).disabled=false;document.getElementById(row+"_"+id).value="";document.getElementById(row+"_"+id).focus();document.getElementById(btn).disabled=false;}else{document.getElementById(row+"_"+id).value="";document.getElementById(row+"_"+id).disabled=true;document.getElementById(btn).disabled=true;}}
function isValidMinRate(row_id){if(/^[+]?[0-9]*(\.[0-9]+)?$/.test($('#'+row_id+'_min_rate').val())){$('#'+row_id+'_submit').removeAttr('disabled');$('#'+row_id+'_error').html('');}else{$('#'+row_id+'_error').html('Invalid offered rate.');$('#'+row_id+'_submit').attr('disabled','disabled');return false;}}
function isValidRates(row,rates_id){var lowval=document.getElementById(row+"_rates_low").value;var highval=document.getElementById(row+"_rates_high").value;if(/^[+]?[0-9]*(\.[0-9]+)?$/.test(lowval)&&/^[+]?[0-9]*(\.[0-9]+)?$/.test(highval)){document.getElementById('rates_btn').disabled=false;document.getElementById('rates_error').innerHTML='';}else{document.getElementById('rates_error').innerHTML=' <b><font color=red>Error: invalid range</font></b>';document.getElementById('rates_btn').disabled=true;return false;}
if((highval===0||lowval===0)){document.getElementById('rates_btn').disabled=true;return false;}
if((highval>=lowval)){document.getElementById('rates_btn').disabled=false;document.getElementById('rates_error').innerHTML='';}else{document.getElementById('rates_error').innerHTML=' <b><font color=red>Error: low rates >= high rates</font></b>';document.getElementById('rates_btn').disabled=true;return false;}}
function isValidName(row_id){if($('#'+row_id+'_name').val().length>3){$('#'+row_id+'_name_btn').removeAttr('disabled');}else{$('#'+row_id+'_name_btn').attr('disabled','disabled');}}
function isValidText(row_id){if($('#'+row_id+'_text').val().length>3){$('#'+row_id+'_text_btn').removeAttr('disabled');}else{$('#'+row_id+'_text_btn').attr('disabled','disabled');}}
function renderCalendar(availability){var string='<table class="cal"><tbody>';string+='<tr><th colspan="7" class="cal_title">Availability</th></tr>';string+='<tr align="center"><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>';var calendar_hidden=false;var day;availability=availability.split(",");for(var n=0;n<availability.length;n++){if(n%7===0){string+='<tr>';}
day=availability[n].split("|");if(day[1]==='H'){calendar_hidden=true;}
string+='<td class="'+day[1]+'">'+day[0]+'</td>';if((n+1)%7===0){string+='</tr>';}}
string+='</tbody></table>';if(calendar_hidden===true){string='<div style="border:1px dotted black;background:#D0D0D0;white-space:no-wrap;">calendar not public</div>';}
return string;}
function getReqLabel(crit,need_id,row_id){action='action=getReqLabel&crit_type='+crit+'&need_id='+need_id+'&'+row2queryString(row_id);$.getJSON('/ajax/ajax_pfe_find',action,function(data){$('#'+crit+'_label').html((data.label!==''?' <span style="color:#83A0AF;">&raquo;</span> <span style="font-size:14px;"><b>'+data.label:'</b></span>'));});}
function updateNativeLanguageLabel(){var language_pair_native_langs=[];var language_pair_boolean='';var source='';var target='';var native_lang;var row_id='';$("td[id$='|language_pair']").each(function(i){row_id=this.id.split('|')[0];if($('#'+row_id+'_native_lang').attr('checked')){source=$("select[id$='_source_lang'] :selected",this);target=$("select[id$='_target_lang'] :selected",this);if(source.val()!==''&&target.val()!==''){language_pair_boolean=$("input[id$='[match_type]']",this).val();language_pair_native_langs[target.val()]=target.text();}}});var native_lang_native_langs=[];var native_lang_boolean='';$("td[id$='|native_lang']").each(function(i){native_lang=$("select[id$='_native_lang'] :selected",this);if(native_lang.val()!==''){native_lang_boolean=$("input[id$='[match_type]']",this).val();native_lang_native_langs[native_lang.val()]=native_lang.text();}});var label='';var language_pair_iso=[];var native_lang_iso=[];var combined_iso=[];for(iso in language_pair_native_langs){language_pair_iso.push(language_pair_native_langs[iso]);combined_iso.push(language_pair_native_langs[iso]);}
for(iso in native_lang_native_langs){native_lang_iso.push(native_lang_native_langs[iso]);combined_iso.push(native_lang_native_langs[iso]);}
if(native_lang_iso.length===0){if(language_pair_iso.length===1){label+=language_pair_iso[0];}else if(language_pair_iso.length>1){if(language_pair_boolean=='any'){label+=language_pair_iso.join(' OR ');}else{label+=language_pair_iso.join(' AND ');}}}else if(language_pair_iso.length===0){if(native_lang_iso.length===1){label+=native_lang_iso[0];}else if(native_lang_iso.length>1){if(native_lang_boolean=='any'){label+=native_lang_iso.join(' OR ');}else{label+=native_lang_iso.join(' AND ');}}}else if(language_pair_iso.length>0&&native_lang_iso.length>0){if(language_pair_iso.length==1){language_pair_boolean='all';}
if(native_lang_iso.length==1){native_lang_boolean='all';}
if(native_lang_boolean==language_pair_boolean&&native_lang_boolean=='all'){label+=combined_iso.join(' AND ');}else{if(language_pair_iso.length!==1){label+='(';}
if(language_pair_boolean=='any'){label+=language_pair_iso.join(' OR ');}else{label+=language_pair_iso.join(' AND ');}
if(language_pair_iso.length!==1){label+=')';}
label+=' AND ';if(native_lang_iso.length!==1){label+='(';}
if(native_lang_boolean=='any'){label+=native_lang_iso.join(' OR ');}else{label+=native_lang_iso.join(' AND ');}
if(native_lang_iso.length!==1){label+=')';}}}
if(label!==''){$('#native_lang_label').html(' - '+label);$('#native_lang').addClass('requirement_name_selected');}else{$('#native_lang_label').html('');$('#native_lang').removeClass('requirement_name_selected');}}
function toggleProfileDetails(){$('.profile_details').map(function(){var entity_id=this.id.substr(13);if('Show'==$('#profile_details_label').html()){if('none'==$('#details_content_'+entity_id).css('display')){$('#details_link_'+entity_id).click();}}else{if('block'==$('#details_content_'+entity_id).css('display')){$('#details_link_'+entity_id).click();}}});if('Show'==$('#profile_details_label').html()){$('#profile_details_label').html('Hide');}else{$('#profile_details_label').html('Show');}}
function showProfileDetails(){$('.profile_details').map(function(){var entity_id=this.id.substr(13);$('#details_link_'+entity_id).click();});$('#profile_details_label').html('Hide');}
function refreshMatches(){popupwin.close();window.setTimeout('getMatches(global_sort_by,global_sort_order)',30);return false;}
function in_array(needle,haystack,strict){var found=false,key,strict=!!strict;for(key in haystack){if((strict&&haystack[key]===needle)||(!strict&&haystack[key]===needle)){found=true;break;}}
return found;}
function number_format(number,decimals,dec_point,thousands_sep){var i,j,kw,kd,km;if(isNaN(decimals=Math.abs(decimals))){decimals=2;}
if(dec_point===undefined){dec_point=",";}
if(thousands_sep===undefined){thousands_sep=".";}
i=parseInt(number=(+number||0).toFixed(decimals))+"";if((j=i.length)>3){j=j%3;}else{j=0;}
km=(j?i.substr(0,j)+thousands_sep:"");kw=i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+thousands_sep);kd=(decimals?dec_point+Math.abs(number-i).toFixed(decimals).replace(/-/,0).slice(2):"");return km+kw+kd;}
function reset_requirements(ptc){var need_id=$('#need_id').val();var confirmation=confirm("Reset all requirements for this job/search?");if(confirmation){if(ptc){window.location.href='/translation-center/find-providers/translators?reset_requirements=y&need_id='+need_id+'';}else{window.location.href='/connect/find/'+need_id+'?reset_requirements=y';}}}
function findPageSendFile(){var checked_entities=getCheckedEntities();if(checked_entities===""){alert("To send a file, please select the recipients.");}else{if(global_mode!=='browse'){toggleFileSendWidget(file_send_widget_id,{"to_eids":checked_entities},{top:20,left:-200});}else{toggleFileSendWidget(file_send_widget_id,{"to_eids":checked_entities,"using_vendor_browse":"yes"},{top:20,left:-300});}}}
function idvPopup(entity_id,entity_name,verified_by,verified_by_name,date,verification_method){idvWindow=window.open("/?sp=item/idv_popup&entity_id="+entity_id,"idvWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1,width=275,height=200");idvWindow.focus();}
