<!--#include file="header.asp"-->
<!--#include file="class_md5.asp"-->


<%
Dim msg, uSubject, uBody

%>
<!--#include file="navlinks.asp"-->
<%
Select Case lcase(Request.ServerVariables("REQUEST_METHOD"))
	Case "post"
		If not CBool(Sess_Array(31)) then
			msg = "<div class='titles-error'>" & strText_InvalidRequestSession & "</div>"
		Else
			Sess_Array(31) = Empty
			enEmail = sq(Replace(Request.Form("resemail"), ";", ""))
			Email = CryptText(enEmail, key, True)
			set rs = objConn.Execute("SELECT nick FROM " & tablUPfx & "User WHERE email = '" & enEmail & "';")
			If not rs.EOF then
				userNick = rs(0)
				rs.close
				newpass = RandomNumber
				Set objMD5 = New MD5
				objMD5.Text = newpass
				newenpass = objMD5.HEXMD5
				objConn.Execute("UPDATE " & tablUPfx & "User SET pass = '" & newenpass & "' WHERE email = '" & enEmail & "';")
				Call getTemplate("Send_Password", Email, newpass, userNick, Empty, Empty)
				Call sendEmail(Email, notify_email, uSubject, uBody)
				msg = "<div class='titles-mid'>" & strText_PasswordSent & "<span class='titles'>" & Email & "</span><br><br><a href='user_logon.asp'>" & strText_Logon & "</a></div>"
			Else
				rs.close
				msg = "<div class='titles-mid'>" & strText_AccountNotFound & " <span class='titles'>" & Email & "</span> " & strText_AccountNotFound1 & "<br><a href='sendpass.asp'>" & strText_TryAgain & "</a></div>"
			End If
		End If
	Case Else
		Sess_Array(31) = 1
%>
<script language="Javascript" src="en.js"></script>
<div align="center" class="titles-mid"><%= strText_TypeEmailReset %>&quot;<%= web_name%>&quot;<br><%= strText_TypeEmailReset1 %></div><br>
<div align="center">
<form method="post" action="sendpass.asp" name="userlogon" onsubmit="if(!ulogon()){return false;}else{var email=encode64(document.userlogon.email.value);document.userlogon.email.value='';document.userlogon.resemail.value=email;}">
<input type="text" name="email" size="20" class="forms">
<input type="hidden" name="resemail">
<input type="submit" value="<%= strText_EmailPassword %>" class="buttons" name="FP">
</forms>
</div>

<%	
End Select
%>

<%= msg %>
<script language="javascript">
<!--
function ulogon(){
var iemail=document.userlogon.email.value.toLowerCase();
iemail=iemail.replace(/\s*/g,"");
document.userlogon.email.value = iemail;
var ePat=/^([\w-\.]+)@([\w-]+)\.([\w-\.]+)$/g;var matchEmail=iemail.match(ePat);
if (iemail == "" | matchEmail == null) {alert("    -- <%= strText_Emailformatisinvalid %>     \n");return false;}return true;
}
//-->
</script>

<!--#include file="footer.asp"-->
