function close_modal(){
	$$('.modal_container')[0].hide();
	$$('.modal_container')[0].update();
	return false;
}

function logout(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->logoutUser'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$("myzenit_div").update();
			window.location = '/';
			//eval(response.responseText);
		}).bind(this)
	});	
	return false;
}

function show_auth(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderAuthForm'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function show_pass_reminder(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderPasswReminder'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].hide();
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function show_user_registration(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderUserRegisterForm'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].hide();
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function show_user_cabinet(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderUserCabinet'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].hide();
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function show_edit_form(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderUserEditForm'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].hide();
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function show_good_register_form(){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->renderGoodRegisterForm'},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			$$('.modal_container')[0].hide();
			$$('.modal_container')[0].update(response.responseText);
			$$('.modal_container')[0].show();				   
			//$$('.modal_container')[0].show();				   
			//if($("ajax_return")) { $("ajax_return").update(response.responseText);}
		}).bind(this)
	});	
	return false;
}

function render_town_list(id){
	if(id=='none'){
		$('register_town_list').hide();
		$('register_town_list').update('выберите город');
		$('register_town_list').show();
		}else{
			new Ajax.Request('/index.php', {
				method: 'post',
				parameters: {"function":'cabinet->renderTownsList', "obl_id":id},
				onCreate : (function(){}).bind(this),
				onComplete : (function(response){
					$('register_town_list').hide();
					$('register_town_list').update(response.responseText);
					$('register_town_list').show();	
				}).bind(this)
			});	}
	return false;
}

function render_category_list(id){
	if(id=='none'){
		$('register_category_list').hide();
		$('register_category_list').update('выберите ТМ');
		$('register_category_list').show();
		}else{
			new Ajax.Request('/index.php', {
				method: 'post',
				parameters: {"function":'cabinet->renderCatList', "cat_id":id},
				onCreate : (function(){}).bind(this),
				onComplete : (function(response){
					$('register_category_list').hide();
					$('register_category_list').update(response.responseText);
					$('register_category_list').show();	
				}).bind(this)
			});	}
	return false;
}

function render_goods_list(id){
	if(id=='none'){
		$('register_good_list').hide();
		$('register_good_list').update('выберите ТМ');
		$('register_good_list').show();
		}else{
			new Ajax.Request('/index.php', {
				method: 'post',
				parameters: {"function":'cabinet->renderGoodList', "cat_id":id},
				onCreate : (function(){}).bind(this),
				onComplete : (function(response){
					$('register_good_list').hide();
					$('register_good_list').update(response.responseText);
					$('register_good_list').show();	
				}).bind(this)
			});	}
	return false;
}

function formWind(text)
{
    var newWind = window.open("", "newwin", "width=500, height=500, top=50, left=50, status=no, location=no, toolbar=no, menubar=no");
    newWind.document.write(text);
}

function render_skidka(id){
	new Ajax.Request('/index.php', {
		method: 'post',
		parameters: {"function":'cabinet->giveSkidka', "id":id},
		onCreate : (function(){}).bind(this),
		onComplete : (function(response){
			formWind(response.responseText);
			$(id).hide();
			$(id).update('скидка получена');
			$(id).show();	
		}).bind(this)
	});	
	return false;
}
