
/**
 * login.  
 * 
 */
function login( options, servReq, dt, hs ) {
	showLoadingIndicator();
	if (options) {
		hideLoadingIndicator();
		if (options.error > 0) {
			alert ('Ошибка!  ' + options.error_desc);
		} else {
//alert ('make remove_focus_select!!!!  options.tableForm = ' + options.caseFieldForm );
			$('lnUserMenu').innerHTML = options.logindForm;
		}
		return;
	}
	var userLogin = $('userLogin').value;
	var userPwd = $('userPwd').value;
	var captchaValue = $('captchaValueLigin').value;

	if ((userLogin == '') ) {
		alert ( err_login_field ); 
		hideLoadingIndicator();
		return false;
	}
	if ( (userPwd == '') ) {
		alert ( err_pwd_field ); 
		hideLoadingIndicator();
		return false;
	}
	if ( (captchaValue == '')) {
		alert ( err_captcha_value ); 
		hideLoadingIndicator();
		return false;
	}
//alert ('login captchaValueLigin = ' + captchaValue)
	var requestServ = servReq+'/tools.php';
	var requestParam = 'prc=ln&&dt=' + dt  + '&hs='+ hs + '&ul='+ userLogin + '&up='+ userPwd+ '&uc='+ captchaValue;
//alert ('make  ' + requestServ + '?' +  requestParam);
	SendRequestByAjax( requestServ, requestParam, login);
}

function user_bye( options, servReq, dt, hs ) {
	showLoadingIndicator();
	if (options) {
		hideLoadingIndicator();
		if (options.error > 0) {
			alert ('Ошибка!  ' + options.error_desc);
		} else {
//alert ('make remove_focus_select!!!!  options.tableForm = ' + options.caseFieldForm );
			$('lnUserMenu').innerHTML = options.logindForm;
		}
		return;
	}
	var requestServ = servReq+'/tools.php';
	var requestParam = 'prc=be&&dt=' + dt  + '&hs='+ hs;
//alert ('make  ' + requestServ + '?' +  requestParam);
	SendRequestByAjax( requestServ, requestParam, user_bye);
}


function registration( options, servReq, ui, dt, hs ) {
	showLoadingIndicator();
	if (options) {
		hideLoadingIndicator();
		if (options.error > 0) {
			alert (err_all + options.error_desc);
		} else {
			$('info_bar').innerHTML = options.UserRegForm;		
			showForm(700, 450);
		}
		return false;
	}
	var requestServ = servReq+'/tools.php';
	var requestParam = 'prc=ur&ui=' + ui + '&dt='+ dt + '&hs='+ hs;
	SendRequestByAjax( requestServ, requestParam, registration);
}
// rememberUser('http://<!--{$serv}-->', '<!--{$self}-->', <!--{$userModel->id}-->, '<!--{$dt}-->', '<!--{$hs}-->');
function rememberUser( options, servReq, ui, dt, hs ) {
	showLoadingIndicator();
	if (options) {
		hideLoadingIndicator();
		if (options.error > 0) {
			alert (err_all + options.error_desc);
		} else {
//			$('info_bar').innerHTML = options.UserRegForm;
//			showForm(700, 450);
			alert (remember_user_succes);
			hideDiv('info_bar');
		}
		return false;
	}
	var dataArray = new Array();
	dataArray[0]  = $('edUserLogin').value;
	if (dataArray[0] == '') { 
		alert ( err_login_field );
		hideLoadingIndicator();
		return false;
	}
	
	dataArray[1]  = $('edUserPasswd').value;
	if (dataArray[1] == '') { 
		alert ( err_pwd_field );
		hideLoadingIndicator();
		return false;
	}
	var edUserPasswd2  = $('edUserPasswd2').value;
	if (dataArray[1] != edUserPasswd2) { 
		alert ( err_pwd2_field );
		hideLoadingIndicator();
		return false;
	}
	
	dataArray[2]  = $('edUserName').value;
	if (dataArray[2] == '') { 
		alert ( err_user_name_field );
		hideLoadingIndicator();
		return false;
	}
	dataArray[3]  = $('edUserAddress').value;

	dataArray[4]  = $('edUserEmail').value;
	if ((dataArray[4] == '') || (!isValidEmail (dataArray[4])) ) { 
		alert ( err_e_mail_field );
		hideLoadingIndicator();
		return false;
	}
	dataArray[5]  = $('edUserPhon').value;
	dataArray[6]  = $('edUserMobil').value;
	
	dataArray[7]  = $('captchaValueReg').value;
	if (dataArray[7] == '') { 
		alert ( err_captcha_value );
		hideLoadingIndicator();
		return false;
	}

	var dArray = Json.toString(dataArray);
	var requestServ = servReq+'/tools.php';
	var requestParam = 'prc=us&ui=' + ui + '&dt='+ dt + '&hs='+ hs + '&da=' + dArray;
	SendRequestByAjax( requestServ, requestParam, rememberUser);
}


