/*<![CDATA[*/
/**
 * lostpassword.class.js
 *
 * Copyright (c) 2007    die.interaktiven GmbH & Co. KG
 *                       Agentur für digitale Medien
 *                       Eisenmarkt 1
 *                       35578 Wetzlar
 *                       Germany
 *
 *                       Fon: +49 (0)64 41 / 39 86 19 - 0
 *                       Fax: +49 (0)64 41 / 39 86 19 - 9
 *                       Web: www.die-interaktiven.de
 *
 * Alle Rechte vorbehalten. Unberechtigte Kopie und Weiter-
 * verwendung nicht gestattet.
 *
 */

var Lostpassword = Class.create();

Lostpassword.prototype = Object.extend(Lostpassword.prototype, Frontend.prototype);

Lostpassword.prototype = Object.extend(Lostpassword.prototype, {

	initialize: function(instanceName)
	{
		this.instanceName = instanceName;
		
		this.serverResponse = null;
		
		this.sendUri = '/user/lostpassword/';

		this.checkEmail = null;
		
	},
	
	doSend: function(sFormName)
	{
	
		var sEmail = trim($('i-email').getValue());

		if(!(sEmail.length > 5))
		{
			alert('Dein E-Mail Adresse ist nicht korrekt.');
			
			return;
		}
		
		if(!this.checkEmail)
		{
			alert('Bitte eine korrekte E-Mail Adresse eingeben.');
			
			return;
		}

		var data = 'email=' + encodeURIComponent(sEmail) + '&t='+(new Date()).getTime();
		
		
		if(this.request(this.sendUri, data))
		{
			if(this.serverResponse.status == 'true')
			{
				alert(this.serverResponse.statusMessage);
				
				myPopupBox.closeit();
			}
			else
			{
				alert(this.serverResponse.statusMessage);
			}
		}
		else
		{
			alert(this.serverResponse.statusMessage);
		}
			
	},
	
	checkData: function(pField, mode)
	{

		if(typeof mode == 'undefined')
		{
			var mode = 'show';
		}
		
		if(trim(pField.value) != '')
		{
			var checkStatus = null;
			
			if(pField.name == 'email')
			{
				if(checkEmail(pField.value))
				{
					checkStatus = true;
					
					this.checkEmail = true;
				}
				else
				{
					checkStatus = false;
					
					this.checkEmail = false;
				}
			}
			}
			else
			{
				if(trim(pField.value) != '')
				{
					checkStatus = true;
				}
			}
			
			if(mode == 'show')
			{
				if(checkStatus == true)
				{
					bCloseConfirm = true;
					
					if($('img-'+pField.id))
					{
						$('img-'+pField.id).replace('<img src="/pages/images/icon-ok.gif" width="16" height="16" alt="Symbol: OK" title="Deine Eingabe ist ok" id="img-'+pField.id+'"/>');
					}
					else
					{
						new Insertion.After(pField, '<img src="/pages/images/icon-ok.gif" width="16" height="16" alt="Symbol: OK" title="Deine Eingabe ist ok" id="img-'+pField.id+'"/>');
					}
				}
				else if(checkStatus == false)
				{
					bCloseConfirm = true;
					
					if($('img-'+pField.id))
					{
						$('img-'+pField.id).replace('<img src="/pages/images/icon-error.gif" width="16" height="16" alt="Symbol: Fehler" title="Deine Eingabe ist fehlerhaft" id="img-'+pField.id+'"/>');
					}
					else
					{
						new Insertion.After(pField, '<img src="/pages/images/icon-error.gif" width="16" height="16" alt="Symbol: Fehler" title="Deine Eingabe ist fehlerhaft" id="img-'+pField.id+'"/>');
					}
				}
				else
				{
				
				}
			}
			else
			{
				return checkStatus;
			}
			
		}
	}
	
	
);
/*]]>*/