		var UserStatusWindow = new Ajax(scriptUrl, {
//			prgsMsg : "Загрузка...",
			update: 'auth_content',
			method: 'get',
			data: {'script_id':222, 'lang': 'ru'},
			onComplete: function(text) {
//				alert(text);
				var auth_form = $('auth_form');
				if (auth_form) {
					auth_form.addEvent('submit', function(e){
						if (e) new Event(e).stop();
						this.send({
							prgsMsg : "Загрузка...",
							onComplete: function(text){
								var tmp, loc, err;
								if (text.test(/<result>1<\/result>/i)) {
									tmp = text.match(/<location[^>]*>(.*?)<\/location>/im);
									loc = $type(tmp) =='array' ? tmp[1] || "" : "";
									window.location = loc;
								} else {
									// tmp = text.match(/<error[^>]*>(.*?)<\/error>/i);
									tmp = text.match(/<error[^>]*>(<!\[CDATA\[)?(.*?)(\]\]>)?<\/error>/im);
//									alert(tmp);
									err = $type(tmp) =='array' ? tmp[2] || "" : "";
//									alert(err)
									$('__auth_error').setHTML(err);
								}


							}
						});
					})
				}

				var exitCtrl = $('logoff');
				if (exitCtrl) {
					exitCtrl.addEvent('click', function(e) {
						if (e) new Event(e).stop();
//						alert(this)
						var url = this.getProperty('href');
					
						new Ajax(url, {
							prgsMsg : "Загрузка...",
							method: 'get',
							onComplete: function(){
								window.location = '/';
							}
						}).request();
					});
				}

			}
		});


window.addEvent('domready', function() {
	dbug.enable();
	nsPrgsBar.enable(nsConfig.prgsBar);//disable();

	//new nsForm(nsConfig.authForm);

	if ($('reg_form')) {
		$extend(nsConfig.regForm.send.data, {
			is_site : 1
		});

		regForm = new nsForm(nsConfig.regForm);
		regForm.initForm();
	}

	var auth_content = $('auth_content');
	if (auth_content) {
		UserStatusWindow.request();
	}
});
