function close_prepage()
{
	$('prepage').hide();
	$('userEmail').focus();
}
function password_forgotten()
{
	var size = this.getPageSize();

	$('prepage').show();
	$('prepage').setStyle({'height':size[1]+'px'});
	$('pwl_mail').value = '';
	$('pwl_mail').focus();
}

function requestLostPassword(path_http, lang)
{
	var mailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,7}$/;

	pwlStatus('OK_INIT', lang);

	if (mailRegex.test($('pwl_mail').value) != false)
	{
		pwlStatus('OK_SENDING', lang);

		new Ajax.Request(path_http + 'pwd_lost.php',
		{
			method: 'post',
			postBody: 'mail='+$('pwl_mail').value+'&lang='+lang,
			onSuccess: function(r)
			{
				//alert(r.responseText);
				pwlStatus(r.responseText, lang);
			}
		});
	}
	else
	{
		pwlStatus('ERR_INVALID_MAIL', lang);
	}
}

function pwlStatus(code, lang)
{
	var msg = '';

	$('pwl_info').setStyle({color:'#ff0000'});

	switch(code)
	{
		case 'ERR_INVALID_MAIL':
			msg = (lang == 'de') ? 'Bitte geben Sie eine gültige Email ein.' : 'Plese enter a valid email.';
			break;

		case 'ERR_INVALID_USER':
			msg = (lang == 'de') ? 'Ungültiger Benutzer! Bitte wenden Sie sich an den Support.' : 'Invalid user! Please refer to the support.';
			break;

		case 'ERR_SENDING_MAIL':
			msg = (lang == 'de') ? 'Beim Senden der Email ist ein Fehler aufgetreten! Bitten wenden Sie sich an den Support.' : 'An error occured while sending your email! Please refer to the support.';
			break;

		case 'ERR_INVALID_REQUEST':
			msg = (lang == 'de') ? 'Prozessfehler! Bitten wenden Sie sich an den Support.' : 'Processing error! Please refer to the support.';
			break;

		case 'OK_INIT':
			$('pwl_info').hide();
			break;

		case 'OK_SENDING':
			$('pwl_info').setStyle({color:'#3e3e40'});
			msg = (lang == 'de') ? 'Sende Daten ...' : 'Sending data ...';
			break;

		case 'OK_MAIL_SENT':
			$('pwl_info').setStyle({color:'#3e3e40'});
			var txt_de = 'Es wurde soeben eine Email an '+$('pwl_mail').value+' gesendet, die weitere Informationen enthält, wie Sie Ihr Passwort zurücksetzen können.';
			var txt_en = 'An email has been sent to '+$('pwl_mail').value+' including further information to reset your password.';

			msg = (lang == 'de') ? txt_de : txt_en;
			break;
	}

	$('pwl_space_line').show();
	$('pwl_info').update(msg);
	$('pwl_info').show();
}

function getPageSize()
{
	var x_scroll, y_scroll;
	var window_width, window_height;
	var page_width, page_height;

	if (window.innerHeight && window.scrollMaxY)
	{
		x_scroll = document.body.scrollWidth;
		y_scroll = window.innerHeight + window.scrollMaxY;
	}
	else if(window.top.document.body.scrollHeight > window.top.document.body.offsetHeight)
	{ // all but Explorer Mac
		x_scroll = document.body.scrollWidth;
		y_scroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		x_scroll = window.top.document.body.offsetWidth;
		y_scroll = window.top.document.body.offsetHeight;
	}
	if (self.innerHeight)
	{	// all except Explorer
		window_width = self.innerWidth;
		window_height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		window_width = document.documentElement.clientWidth;
		window_height = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		window_width = document.body.clientWidth;
		window_height = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(y_scroll < window_height)
	{
		page_height = window_height;
	}
	else
	{
		page_height = y_scroll;
	}

	// for small pages with total width less then width of the viewport
	if(x_scroll < window_width)
	{
		page_width = window_width;
	}
	else
	{
		page_width = x_scroll;
	}

	arr_page_size = new Array(page_width,page_height,window_width,window_height)
	return arr_page_size;
}
