<%@LANGUAGE="VBSCRIPT"%>


<!--#include file="incs/genericconstants.inc" -->
<!--#include file ="incs/dataaccess/conn.inc"-->
<!--#include file ="incs/genericfunctions.inc"-->

<%



success=0
vid=request("vid")

friendsemail = trim(request("friendsemail"))
yourname = trim(request("yourname"))
comments = trim(request("comments"))

	


errorsoccured=0


		yournameerror=0
		friendsemailerror=0

if request("Submit") ="Submit" then

	
		if yourname ="" then yournameerror=1:errorsoccured=1
		if friendsemail ="" then  friendsemailerror=1:errorsoccured=1

		
		if errorsoccured=0 then
		
		'**************************************
		LineSplit = vbcrlf
		
strBodyContent = strBodyContent & "Hello"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "This is a message from "&yourname&" sent via the Carte Blanche Villas Website. "
strBodyContent = strBodyContent & LineSplit

if comments ="" then

strBodyContent = strBodyContent & yourname &" thinks that you may be interested in this property."
strBodyContent = strBodyContent & LineSplit
else

strBodyContent = strBodyContent & yourname &" thinks that you may be interested in this property and sends"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "the following comments:"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "-------------------------------------------"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & comments
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "-------------------------------------------"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & LineSplit

end if


strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & trim(website_address)&"/showproperty.asp?vid="&vid
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "Regards."
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "_________________________________" 
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "Carte Blanche Villas"
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "27 Albert Square," 
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "London SW8 1DA" 
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "Tel: +44 (0)20 77 359923" 
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "Email: info@carteblanchevillas.com" 
strBodyContent = strBodyContent & LineSplit
strBodyContent = strBodyContent & "Website: http://www.carteblanchevillas.com"
strBodyContent = strBodyContent & LineSplit

		'**************************************

		'//  Commented out by R Lloyd, changed CDONTS object to ASPMail

		'Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
		'objCDOMail.From = from_email
		'objCDOMail.To = friendsemail
		'objCDOMail.Subject = "Carte Blanche Villas: Recommendation from "&Yourname
		'objCDOMail.Body = strBodyContent
		'objCDOMail.MailFormat = 0 ' CdoMailFormatMime
		'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High)

		'objCDOMail.Send
		'Set objCDOMail = Nothing
   
		'**************************************

		Dim Mailer

		Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
	
		Mailer.Encoding = 1
		Mailer.Wordwrap = True
  		Mailer.FromName = "Carte Blanche Villas"
 		Mailer.FromAddress = from_email
  		Mailer.RemoteHost = "mail.brwebsites.com"
 		Mailer.AddRecipient "", friendsemail
  		Mailer.Subject = "Carte Blanche Villas: Recommendation from "&Yourname
	
		Mailer.BodyText = strBodyContent
	
  		Mailer.SendMail

		Set Mailer = Nothing

		
		
		'**************************************
		
		
		
		success=1
		end if


end if




%>

<html>
<STYLE type="text/css">
<!--
  input,select { font: Verdana; font-size: 8pt; }
 TEXTAREA { COLOR: #000000; FONT-FAMILY: 
Verdana, MS Sans Serif, Arial,Helvetica; FONT-SIZE: 11px } 
-->
</style>
<head>
<title><%=villareference%> Email to Friend</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%if success=0 then%>
<SCRIPT language=JavaScript src="validate.js"></script>
<%end if%>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#0000FF" alink="#0000FF" onload="window.focus();<%if success=0 then%>UpdateDayStart('thisForm');UpdateDayEnd();<%end if%>document.tform.firstname.focus();">
<div align="center">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr bgcolor="264D94" valign="middle"> 
      <td height="22"> 
        <div align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Email 
          villa details to a friend</b></font></div>
      </td>
    </tr>
  </table>
  <form name="tform" method="post" action="emailtofriend.asp">
    <table border="0" cellspacing="0" cellpadding="1">
      <%if success=1 then%> 
      <tr> 
        <td colspan="3"><font face="Arial, Helvetica, sans-serif" size="2">Thankyou 
          <%=firstname%> <br>
          Click <a href="javascript:window.close();">here</a> to close this window.</font></td>
      </tr>
      <%else%> 
      <tr> 
        <td width="115">&nbsp;</td>
        <td colspan="2"> <font face="Arial, Helvetica, sans-serif" size="2"> 
          <input type="hidden" name="vid" value="<%=vid%>">
          <br>
          <%=villalocation%> </font></td>
      </tr>
      <%if errorsoccured= 1 then%> 
      <tr> 
        <td width="115">&nbsp;</td>
        <td colspan="2"><font face="Arial, Helvetica, sans-serif" size="2" color="#FF0000">Please 
          check fields marked red!</font></td>
      </tr>
      <%end if%> 
      <tr> 
        <td width="115" align="right"><b><font face="Arial, Helvetica, sans-serif" size="2" <%if yournameerror=1 then%>color="#ff0000" <%end if%>>Your 
          Name&nbsp;&nbsp;</font></b></td>
        <td colspan="2"> 
          <input type="text" name="yourname" size="36" maxlength="250" value="<%=yourname%>">
        </td>
      </tr>
      <tr> 
        <td width="115" align="right" valign="top" nowrap><b><font face="Arial, Helvetica, sans-serif" size="2" >Your 
          Comments&nbsp;&nbsp;</font></b></td>
        <td colspan="2"> 
          <textarea name="comments" wrap="VIRTUAL" cols="30" rows="5"><%=comments%></textarea>
        </td>
      </tr>
      <tr> 
        <td width="115" align="right" valign="top">
          <div align="right"> 
            <p><b><font face="Arial, Helvetica, sans-serif" size="2" <%if friendsemailerror=1 then%>color="#ff0000" <%end if%>>Friends 
              Email&nbsp;&nbsp;<br>
              </font></b><b><font face="Arial, Helvetica, sans-serif" size="2" <%if friendsemailerror=1 then%>color="#ff0000" <%end if%>> 
              Address&nbsp;&nbsp;</font></b></p>
            </div>
        </td>
        <td colspan="2" valign="top"> 
          <input type="text" name="friendsemail" size="36" maxlength="250" value="<%=friendsemail%>">
        </td>
      </tr>
      <tr> 
        <td width="115" align="right" valign="top"><b></b></td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr align="center"> 
        <td colspan="3" valign="top"><b></b> 
          <input type="submit" name="Submit" value="Submit">
        </td>
      </tr>
      <%end if%> 
    </table>
</form>
</div>
</body>
</html>