<%@ language=vbscript %>
<%option explicit%>
<!--#include virtual="/inc/config.asp" -->
<!--#include virtual="/inc/functions.asp" -->
<%
dim id_agenzia
id_agenzia = request("tc")

if id_agenzia = "" then
	dim strQ, path
	strQ = Request.ServerVariables("QUERY_STRING")
	
	id_agenzia = mid(strQ, instr(strQ, "tc=")+3, len(strQ))

End If 	
	

'### Apre la connessione
Dim Conn, RS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open strConn
set RS = conn.execute("SELECT * from agenzie WHERE status = 1 AND agenzia_gold >= 1 AND id_agenzia = " & id_agenzia)

if not RS.EOF then

Dim vcardText

vcardText = vcardText &	"BEGIN:VCARD" & VBCRLF
vcardText = vcardText &	"VERSION:2.1" & VBCRLF
vcardText = vcardText & "N:;" & RS("nominativo") & VBCRLF
vcardText = vcardText & "FN:" & RS("nominativo") & VBCRLF
vcardText = vcardText & "ORG:" & RS("nominativo") & VBCRLF
vcardText = vcardText & "TEL;WORK;VOICE:" & RS("telefono1") & VBCRLF
vcardText = vcardText & "TEL;WORK;FAX:" & RS("fax") & VBCRLF
vcardText = vcardText & "ADR;WORK:;;" & RS("indirizzo") & ";" & RS("citta") & ";" & RS("provincia") & ";" & RS("cap") & ";Italia" & VBCRLF
if RS("homepage") <> "" then 
	vcardText = vcardText & "URL;WORK:" & RS("homepage") & VBCRLF
else	
	vcardText = vcardText & "URL;WORK:" & "http://www.trova-casa.net/agenzia.asp?agenzia=TC-" & RS("id_agenzia") & VBCRLF
End If
vcardText = vcardText & "NOTE;ENCODING=QUOTED-PRINTABLE:" & "Ci trovi su Trova-Casa.net all'indirizzo:=0D=0Ahttp://www.trova-casa.net/agenzia.asp?agenzia=3DTC-" & RS("id_agenzia") & "=0D=0A=0D=0A=0D=0A" & RS("descrizione") & VBCRLF
'vcardText = vcardText & "PHOTO;VALUE=URL;TYPE=GIF:http://www.trova-casa.net/img/trova-casa.gif" & VBCRLF
vcardText = vcardText & "EMAIL;PREF;INTERNET:" & RS("mail") & VBCRLF
vcardText = vcardText & "END:VCARD" & VBCRLF
End If

rs.close
set rs = nothing

conn.close
set conn = nothing

Response.ContentType = "text/plain"
Response.Write(vcardText)



%>