function exposeOtherOptions(){if($("#spID1").hasClass("ui-icon-circle-plus")){$("#spID1").removeClass("ui-icon-circle-plus");$("#spID1").addClass("ui-icon-circle-minus");$("#choices").removeClass("hideIt");$("#choices").show();$("#searchButton").show()}else{$("#spID1").removeClass("ui-icon-circle-minus");$("#spID1").addClass("ui-icon-circle-plus");$("#choices").addClass("hideIt");$("#choices").hide();$("#searchButton").hide()}}function ClearCriteria(){$("#curCriteria_lastName").val("");$("#curCriteria_firstName").val("");$("#curCriteria_town").val("");$("#curCriteria_zipcode").val("");$("#curCriteria_county").val("");$("#newPats").attr("checked",false);$("#bCertified").attr("checked",false);$("#curCriteria_selState").val("all");$('input[name="curCriteria.gender"]')[0].checked=true;$("#curCriteria_selProvLang").val("all");$("#curCriteria_selPracticeDrop").val("all");$("#curCriteria_selInsuranceDrop").val("all");$("#curCriteria_selSpecDrop").val("all");$("#ourResults").html("")}function ParseForJson(r,q){var a="";thePage=r;var j="10",m=$("#itemPerPage").val();if(fieldHasValue(m))j=m;var i=$("#curCriteria_lastName").val();i=jQuery.trim(i);var h=$("#curCriteria_firstName").val();h=jQuery.trim(h);var f=$("#curCriteria_town").val();f=jQuery.trim(f);var g=$("#curCriteria_zipcode").val();g=jQuery.trim(g);var c=$("#curCriteria_county").val();c=jQuery.trim(c);var k="";if($("#newPats").attr("checked"))k="Y";var b=null;b=$("input:radio[name=curCriteria.gender]:checked").val();if(b=="undefined")b="N";var n=$("#curCriteria_selProvLang").val(),d=$("#curCriteria_selPracticeDrop").val(),o=$("#curCriteria_selInsuranceDrop").val(),e=$("#curCriteria_selSpecDrop").val(),l="";if($("#bCertified").attr("checked"))l="Y";var p=$("#curCriteria_selState").val();d=EscapeAmpersand(d);e=EscapeAmpersand(e);a="lname="+i+"&fname="+h+"&thePage="+thePage;a+="&userPageSize="+j+"&cityBox="+f+"&zipBox="+g;a+="&countyBox="+c+"&newPats="+k+"&genderButton="+b;a+="&langDrop="+n+"&insDrop="+o+"&pracDrop="+d;a+="&specDrop="+e+"&boardCert="+l+"&state="+p;if(q==1){a="lname="+encodeURIComponent(i)+"&fname="+encodeURIComponent(h)+"&thePage="+thePage;a+="&userPageSize="+j+"&cityBox="+encodeURIComponent(f)+"&zipBox="+encodeURIComponent(g);a+="&countyBox="+encodeURIComponent(c)+"&newPats="+encodeURIComponent(k)+"&genderButton="+encodeURIComponent(b);a+="&langDrop="+encodeURIComponent(n)+"&insDrop="+encodeURIComponent(o)+"&pracDrop="+encodeURIComponent(d);a+="&specDrop="+encodeURIComponent(e)+"&boardCert="+encodeURIComponent(l)+"&state="+encodeURIComponent(p)}return a}function EscapeAmpersand(a){var b=a;if(fieldHasValue(a))b=a.replace("&","amp#38");return b}function GoSubmit(a){thePage=a;var b="10",c=$("#itemPerPage").val();if(fieldHasValue(c))b=c;$MyResultsPanel="#MyResultsPanel";$ListForGridURL="/Home/ListForGrid";var e=ParseForJson(a,0),d=ParseForJson(a,1);$.ajax({type:"POST",url:"/Home/ListForGrid",data:e,success:function(f){var l=f.curResultsData,m=f.iMess,h=0,c,a,j;if(f.itotPage>0){c="<b><div class='resultHeader'>"+m+"</div>&nbsp;&nbsp;";c+="<a href='/Home/printToPdf?"+d+"' >";c+="<img src='/images/bifPrint1.jpg'  alt='' title='Create Printable PDF of Search Result' /></a></b><br /><br />";c+=buildPerPageOption(b)+buildNavigator(thePage,f.itotPage)+"<br /><table class='resTab'>"}else c="<b><div class='resultHeader'> ---no providers found for this search---- </div>&nbsp;&nbsp;";for(var n in l){a=l[h];iCol1="<div class='docNameHead'>"+titleCaseSimpleWord(a.last_name)+", "+titleCaseSimpleWord(a.first_name)+"  "+safeUpperCaseTrim(a.qualification)+"</div><br /> <br />";if(fieldHasValue(a.front_filename)){tmpAr=a.front_filename.split("\\");j="http://www.vermontmanagedcare.org/physicianphoto/"+tmpAr[tmpAr.length-1];iCol1+="<img width='80' height='100' src='"+j+"' alt='' /><br />"}iCol1+=safeUpperCaseTrim(a.company)+"<br />"+safeUpperCaseTrim(a.address1)+" <br /> ";ibuffer="";var e=jQuery.trim(a.address1);e=e.replace(" ","+")+",+";if(fieldHasValue(a.address2))iCol1+=safeUpperCaseTrim(a.address2)+" <br />";if(fieldHasValue(a.city)){iCol1+=safeUpperCaseTrim(a.city)+", ";ibuffer="<br />";e+=jQuery.trim(a.city).replace(" ","+")+",+"}if(fieldHasValue(a.state)){iCol1+=safeUpperCase(a.state)+", ";ibuffer="<br />";e+=a.state+"+"}if(fieldHasValue(a.zip)){iCol1+=a.zip.substring(0,5);ibuffer="<br />";e+=a.zip.substring(0,5)+"+"}iCol1+=ibuffer;iCol1+="Ph: "+phoneFormat(a.phone);iCol1+="<br /><a href='/home/Details?provID="+jQuery.trim(a.lookup_key)+"&company="+encodeURIComponent(jQuery.trim(a.group_name))+"' target='_blank'  >Details </a>";iCol1+="&nbsp;&nbsp;<a target='_blank' href='http://maps.google.com/maps?f=d&hl=en&geocode=&q="+e+"' >Map</a><br />";iCol2="";if(a.sex=="M")iCol2="Gender:  Male <br />";if(a.sex=="F")iCol2="Gender:  Female <br />";var k="Accepting New Patients: Yes <br />";if(fieldHasValue(a.new_patients)&&fieldHasValue(a.PCP))if(a.new_patients=="N"&&(a.PCP=="Y"||a.PCP=="B"))k="Accepting New Patients: No <br />";iCol2+=k;var i="Age Restrictions: none <br /> ";if(fieldHasValue(a.age_limit))if(a.age_limit=="Y"&&fieldHasValue(a.age_limit_description))i="Age Restrictions: "+a.age_limit_description+"<br />";iCol2+=i+"<br />";var g="Board Certified: No <br />";if(fieldHasValue(a.boardCertList)){g=a.boardCertList.replace(new RegExp(",","g"),", ");g="Board Certified: "+titleCaseSimpleWord(g)+"<br /><br />"}iCol2+=g;if(fieldHasValue(a.specList))iCol2+="Practicing Specialty: "+titleCaseSimpleWord(a.specList)+" <br />";c+="<tr class='fullRow'>";c+="<td class='leftRow'>"+iCol1+"</td>";c+="<td class='rightRow'>"+iCol2+"</td>";c+="</tr>";h=h+1}if(f.itotPage>0)c+=" </table> "+buildNavigator(thePage,f.itotPage)+"<br />";$("#ourResults").html("");$("#ourResults").html(c)},error:function(){$("#ourResults").html("");$("#ourResults").html("Error performing provider search <br/> Contact web master at VMC")}})}function fieldHasValue(a){return a==null?false:a=="undefined"?false:jQuery.trim(a)==""?false:true}function safeUpperCase(a){return a==null?"":a=="undefined"?"":jQuery.trim(a)==""?"":a.toUpperCase()}function safeUpperCaseTrim(a){return a==null?"":a=="undefined"?"":jQuery.trim(a)==""?"":jQuery.trim(a).toUpperCase()}function phoneFormat(a){if(a==null)return"";thPhone1=jQuery.trim(a);ires="";if(thPhone1.length>3)ires+="("+thPhone1.substring(0,3)+") ";if(thPhone1.length>6)ires+=thPhone1.substring(3,6)+"-";if(thPhone1.length>9)ires+=thPhone1.substring(6,10);return ires}function titleCaseSimpleWord(d){var c="",a="";if(d!=null){c=d.toLowerCase();if(c.length>1){var b=c.split(" ");for(i=0;i<b.length;i++)if(b[i].length>1)a+=b[i].charAt(0).toUpperCase()+b[i].substr(1)+" ";else a+=b[i].toUpperCase();a=jQuery.trim(a);return a}else return c.toUpperCase()}else return""}function buildPerPageOption(b){var a="<div class='navigaTor'>Providers Per Page:&nbsp;&nbsp;<select id='itemPerPage'>";if(b==5)a+="<option value='5' selected = 'true' >5</option> ";else a+="<option value='5'>5</option> ";if(b==10)a+="<option value='10' selected = 'true' >10</option> ";else a+="<option value='10'>10</option> ";if(b==20)a+="<option value='20' selected = 'true' >20</option> ";else a+="<option value='20'>20</option> ";if(b==30)a+="<option value='30' selected = 'true' >30</option> ";else a+="<option value='30'>30</option> ";a+="</select></div><br/> <br />";return a}function buildNavigator(a,e){var d="",f="",g="",j="",h="",c=6,l=c-2,k=c-3,b="";if(e>c-1){f="<a href='#' onclick='GoSubmit(1)'>First</a>";g="<a href='#' onclick='GoSubmit("+e+")'>Last</a>"}if(a>1)j="<a href='#' onclick='GoSubmit("+(a-1)+")'> Prev </a>&nbsp;&nbsp;";if(a<e)h="<a href='#' onclick='GoSubmit("+(a+1)+")'> Next </a>&nbsp;&nbsp;";if(a<c)for(i=1;i<=Math.min(c,e);i++){b="";if(i==a)b="ui-state-highlight";d+="<a href='#' class='"+b+"' onclick='GoSubmit("+i+")'>"+i+"</a>&nbsp;&nbsp;"}else for(i=a-l;i<=Math.min(a+k,e);i++){b="";if(i==a)b="ui-state-highlight";d+="<a href='#' class='"+b+"' onclick='GoSubmit("+i+")'>"+i+"</a>&nbsp;&nbsp;"}d="<div class='navigaTor'> "+f+"&nbsp;&nbsp;"+j+"&nbsp;&nbsp;"+d+"&nbsp;&nbsp;"+h+"&nbsp;&nbsp;"+g+"</div>";return d}function toFacility(){var a="/home/facilitySearch";window.location=a}function mapIt(f,d,c,e){alert("mapIt:  addr1 is "+f+", city is "+d+", state is "+c+", zip is "+e);var a="http://maps.google.com/maps/api/geocode/json?address=",b=jQuery.trim(f);a+=b.replace(" ","+");if(fieldHasValue(d)){b=jQuery.trim(d);a+=","+b.replace(" ","+")}if(fieldHasValue(c))a+=jQuery.trim(c);if(fieldHasValue(e))a+=jQuery.trim(e);a+="sensor=false";$.getJson(a,function(a){if(a.status=="OK"){result=a.results[0].geometry.location;lat=a.results[0].geometry.location.lat;lon=a.results[0].geometry.location.lon;alert("lat is "+lat+", and lon is "+lon)}});a="http://maps.google.com/maps/api/staticmap?center=";b=jQuery.trim(f);a+=b.replace(" ","+");if(fieldHasValue(d)){b=jQuery.trim(d);a+=","+b.replace(" ","+")}if(fieldHasValue(c))a+=jQuery.trim(c);if(fieldHasValue(e))a+=jQuery.trim(e);a+="&zoom=14&size=512x512&maptype=roadmap&markers=color:blue&sensor=false";alert("mapURL is "+a);return a}function GoFacSubmit(){var a="",b="",c=$("input:radio[name=searchDrive]:checked").val();if(c=="T"){b="NOTSELECTED";a=$("#selFacDrop").val();jQuery.trim(a)}else if(c=="N"){a="NOTSELECTED";b=$("#selFacNameDrop").val();jQuery.trim(a)}var e=location.href,d=ParseForFacJson();$.ajax({type:"POST",url:"/Home/ListFacilitiesGrid",data:"selFacDrop="+a+"&selFacNameDrop="+b,success:function(g){var i=g.iRes,j=g.iMess,c="<b><div class='resultHeader resultFacHeader'>"+j+"</div>&nbsp;&nbsp";c+="<a href='/home/printFacilityToPdf?"+d+"' >";c+="<img src='/images/bifPrint1.jpg'/> </a>   </b><table class='resTab'>";var a,f=0,h="",b="";for(var k in i){b="";a=i[f];if(fieldHasValue(a.groupDesc))h="<div class='docNameHead'>"+a.groupDesc+"</div>";if(fieldHasValue(a.groupAddr)){b+=safeUpperCaseTrim(a.groupAddr)+"<br />";var e=jQuery.trim(a.groupAddr);e=e.replace(" ","+")+",+"}if(fieldHasValue(a.groupCity)){b+=safeUpperCaseTrim(a.groupCity);e+=jQuery.trim(a.groupCity).replace(" ","+")+",+"}if(fieldHasValue(a.groupState)){b+=", "+safeUpperCaseTrim(a.groupState);e+=a.groupState+"+"}if(fieldHasValue(a.groupZip)){b+=" "+a.groupZip+"<br />";e+=a.groupZip.substring(0,5)+"+"}if(fieldHasValue(a.groupPhone))b+="Ph:  "+phoneFormat(a.groupPhone)+"<br />";if(fieldHasValue(a.groupFax))b+="Fax:  "+phoneFormat(a.groupFax)+"<br />";b+="<a href='#' ";b+="onclick=\"mapIt('";b+=safeUpperCaseTrim(a.groupAddr)+"','";b+=safeUpperCaseTrim(a.groupCity)+"','";b+=safeUpperCaseTrim(a.groupState)+"','";b+=a.groupZip.substring(0,5);b+="')\">Show Map</a>&nbsp;&nbsp;&nbsp;&nbsp";b+="<a target='_blank' href='http://maps.google.com/maps?f=d&hl=en&geocode=&q="+e+"' >Get Directions</a><br />";c+="<tr class='fullRow'>";c+="<td colspan='2' class=''>"+h+"<br /> "+b+" <br /> </td>";c+="</tr>";f=f+1}c+=" </table> ";$("#ourResults").html("");$("#ourResults").html(c)},error:function(){alert(" Error displaying the Groups in the Facility Search - Call IS support!!")}})}function toProviders(){var a="/home/doctorSearch";window.location=a}function mapIt(i,e,d,f){var a=i;if(fieldHasValue(e))a+=","+e;if(fieldHasValue(d))a+=","+d;if(fieldHasValue(f))a+=","+f;$(".docNameHead").prev();var c,b,j,h=new google.maps.LatLng(41.659,-4.714),g={zoom:16,center:h,mapTypeId:google.maps.MapTypeId.ROADMAP};c=new google.maps.Map(document.getElementById("map_canvas"),g);b=new google.maps.Geocoder;b&&b.geocode({address:a},function(a,b){if(b==google.maps.GeocoderStatus.OK){c.setCenter(a[0].geometry.location);var d=new google.maps.Marker({map:c,position:a[0].geometry.location})}else alert("Geocode was not successful for the following reason: "+b)})}function ParseForFacJson(){var c="",b="",a="",d=$("input:radio[name=searchDrive]:checked").val();if(d=="T"){a="NOTSELECTED";b=$("#selFacDrop").val()}else if(d=="N"){b="NOTSELECTED";a=$("#selFacNameDrop").val()}c="selFacDrop="+b+"&selFacNameDrop="+a;return c}
