Function ConvertUrlToLink(sVal)
 
    Set RegEx = New RegExp  
 
          RegEx.IgnoreCase = True  
          RegEx.Global = True  
          RegEx.Pattern = "(\bhttp://[^ ]+\b)" 
          sVal = RegEx.Replace(sVal, "<a href='$1'>$1</a>")  
 
          Set RegEx = Nothing        
 
      ConvertURLToLink = sVal

End Function
Function FormatText1(sVal)
   
   sVal = Trim(sVal)
   sVal = Replace(sVal,"<","&lt;")
 
   sVal = Replace(sVal,". ",".&nbsp;")
   sVal = Replace(sVal,"  ","&nbsp;&nbsp;")
   
   sVal = Replace(sVal,vbcrlf," <br>" & vbcrlf)
   sVal = Replace(sVal,"&lt;ul>","<ul>")
   sVal = Replace(sVal,"&lt;/ul>","</ul>")
   sVal = Replace(sVal,"&lt;li>","<li>")

   sVal = Replace(sVal,"&lt;strong>","<strong>")
   sVal = Replace(sVal,"&lt;/strong>","</strong>")
   sVal = Replace(sVal,"&lt;em>","<em>")
   sVal = Replace(sVal,"&lt;/em>","</em>")

   sVal = ConvertURLToLink(sVal)
  
   FormatText1 = sVal 
End Function

cleaned_pgid = ""
cleaned_pgid = Replace(Request("pgid"), "'", "")
if len(cleaned_pgid)>0 and not isNumeric(cleaned_pgid) then response.end


ajg_sQry = "SELECT colleagues.colleagueid, colleagues.firstname, colleagues.middlename, colleagues.lastname, colleagues.title, "&_
" colleagues.displayonwebsite, colleagues.directofficephone, colleagues.displayemailaddress, colleagues.imagename, "&_
" colleagues.displayrank, colleagues.bio, colleagues.officeid, practicegroupmembers.bio AS Expr1, "&_
" practicegroupmembers.practicegroupid"&_
" FROM colleagues LEFT OUTER JOIN"&_
" practicegroupmembers ON colleagues.colleagueid = practicegroupmembers.colleagueid"&_
" WHERE (practicegroupmembers.practicegroupid = "&cleaned_pgid&") AND (colleagues.colleagueid = "&cleaned_colid&") AND (colleagues.displayonwebsite = 1)"

'ajg_sQry = "SELECT colleagueid, firstname, middlename, lastname, title, "&_
'" displayonwebsite, directofficephone, displayemailaddress, "&_
'" imagename, displayrank, bio, officeid"&_
'" FROM colleagues"&_
'" WHERE colleagueid = "&cleaned_colid&" AND displayonwebsite = 1 ORDER BY displayrank"
ag_get_one_record ajg_sQry,42,iicnet

ajg_sQry = "SELECT officeid, officename, officeurl, officephone, officefax, "&_
" officeemail, officeaddress1, officeaddress2, officecity, webcity, "&_
" officestate, officezip, officecountry, generalinformation, "&_
" tz_id"&_
" FROM offices WHERE offices.officeid="&ag_recordfield(42,11)
ag_get_one_record ajg_sQry,40,iicnet

Response.write "<table cellpadding=0 cellspacing=0 border=0 width='700'>"

address_string = ""
if len(ag_recordfield(40,6))>0 then address_string = address_string&ag_recordfield(40,6)
if len(ag_recordfield(40,7))>0 then address_string = address_string&"<br />"&ag_recordfield(40,7)
if len(ag_recordfield(40,8))>0 then address_string = address_string&"<br />"&ag_recordfield(40,8)
if len(ag_recordfield(40,10))>0 then address_string = address_string&", "&ag_recordfield(40,10)
if len(ag_recordfield(40,11))>0 then address_string = address_string&"<br />"&ag_recordfield(40,11)
if len(ag_recordfield(40,12))>0 then address_string = address_string&"<br />"&ag_recordfield(40,12)
if len(ag_recordfield(40,3))>0 then address_string = address_string&"<br />Ph "&ag_recordfield(40,3)
if len(ag_recordfield(40,4))>0 then address_string = address_string&"<br />Fx "&ag_recordfield(40,4)
if len(ag_recordfield(40,5))>0 then address_string = address_string&"<br /><a href='mailto:"&ag_recordfield(40,5)&"'>"&ag_recordfield(40,5)&"</a>"
if len(ag_recordfield(40,2))>0 then address_string = address_string&"<br /><a href='http://"&ag_recordfield(40,2)&"' target='_top'>"&ag_recordfield(40,2)&"</a>"

colleague_string0 = ""
colleagueemail0 = ""

if len(ag_recordfield(42,6)) > 0 then ag_recordfield(42,6) = ag_recordfield(42,6) else ag_recordfield(42,6) = ag_recordfield(40,3)
if len(ag_recordfield(42,6))>0 then colleague_string0 = colleague_string0&"Ph "&ag_recordfield(42,6)
if len(ag_recordfield(42,7))>0 then colleagueemail0 = colleagueemail0&"<br /><a href='mailto:"&ag_recordfield(42,7)&"'>"&ag_recordfield(42,7)&"</a>"

if len(ag_recordfield(42,2))> 0 then sp1=" " else sp1=""

Response.write "<tr>"
Response.write "<td valign='bottom' style='font-family: Arial, Helvetica, sans-serif;color: #000066;font-size: 16;' nowrap>IIC Partners<br />Professional Profile</td>"
Response.write "<td></td>"
Response.write "<td colspan='5' style='font-family: Arial, Helvetica, sans-serif;color: #000066;font-size: 14;' nowrap valign='bottom'><span style='font-size: 20;'>"&ag_recordfield(42,1)&sp1&ag_recordfield(42,2)&" "&ag_recordfield(42,3)&"</span><br />"&ag_recordfield(40,1)&", "&ag_recordfield(40,9)&"</td>"
Response.write "</tr>"

Response.write "<tr><td height='10'></td></tr>"

Response.write "<tr>"
Response.write "<td valign='top' nowrap class='body0'><b>Contact</b><br>"&colleague_string0&colleagueemail0&"<br /><br /><b>Office</b><br>"&address_string&"</td>"
Response.write "<td width='30px'><img src='img/trans.gif' width='30px' height='3px' /></td>"
if len(ag_recordfield(42,12))>0 then
	bio = FormatText1(ag_recordfield(42,12))
else
	if len(ag_recordfield(42,10))>0 then bio = FormatText1(ag_recordfield(42,10)) else bio=""
end if

Response.write "<td valign='top' width='100%'><span class='body0'><img src='http://iicnet.iicpartners.com/img/colleague/"&ag_recordfield(42,8)&"' border='0' align='left' style='margin-left:0px; margin-right:10px;margin-top:0px;margin-bottom:5px' width='90px'>"&bio&"</span></td>"
Response.write "<td width='40px'><img src='img/trans.gif' width='40px' height='3px' /></td>"
Response.write "<td valign='top' class='body0'>&nbsp;</td>"
Response.write "</tr>"
Response.write "</table>"
