function toogle_check(id){
	if($(id)) $(id).checked = $(id).checked == true ? false : true;
}

function initLogin(lang){
	if($('forgot_pass'))
		Event.observe($('forgot_pass'), 'click', function() {
			Lightview.show({
				href: 'http://' + document.domain.toString() + '/forgotpass/'+lang,
				rel: 'ajax',
				options: {
					autosize: true,
					topclose: true,
					ajax: {
						onComplete: function(resp){
							$('forgot_email').value = $F('email');
							Event.observe($('send'), 'click', function() {
								if(checkEmail($('forgot_email'))){
									new Ajax.Request('/forgotpass/'+lang+'/send_confirm', {
										method: 'post',
										requestHeaders: {Accept: 'application/json'},
										parameters: {
											email: $F('forgot_email')
										},
										onSuccess: function(resp) {
											var json = resp.responseText.evalJSON(true);
											if(json.error) alert(json.error);
											else{
												/******************/
												Lightview.show({
													href: 'http://' + document.domain.toString() + '/forgotpass/'+lang+'/sent_confirm',
													rel: 'ajax',
													options: {
														autosize: true,
														topclose: true,
														ajax: {
															onComplete: function(resp){
															}
														}
													}
												});
												/******************/
											}
										}
									});
								}
								else $('forgot_email').addClassName('error_input');
							});
						}
					}
				}
			});
		});
}		

function checkEmail(o) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (!filter.test(o.value) ? false : true);
}
