$('#hosting').ajaxForm({
	dataType: 'json',
	success: function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "Продолжить",
					}]
				);

			if(i == 's')
				location.href = home+'hosting/id/'+data['id'];
		});

		loading(0);
	}
});

$('#extend').ajaxForm({
	dataType: 'json',
	success: function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "Продолжить",
					}]
				);

			if(i == 's')
				location.reload();
		});

		loading(0);
	}
});

$('#tarif').ajaxForm({
	dataType: 'json',
	success: function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "Продолжить",
					}]
				);

			if(i == 's')
				location.reload();
		});

		loading(0);
	}
});

$('#hdd_addon').ajaxForm({
	dataType: 'json',
	success: function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "Продолжить",
					}]
				);

			if(i == 's')
				location.reload();
		});

		loading(0);
	}
});

function upd_price()
{
	$.getJSON(home+'services/section/hosting/id/'+$('#tarifs').val()+'/time/'+$('#time').val()+'/get/price', function(arr)
	{
		$('#sum').html(arr['sum']);
	});
}

function change_data()
{
	$.getJSON(home+'services/section/hosting/id/'+$('#tarifs').val()+'/get/data', function(arr)
	{
		$.each(arr, function(id, val)
		{
			$('#'+id).html(val);
		});
	});
}

function change_passwd(id)
{
	if(confirm('Вы уверены?'))
	{
		$.getJSON(home+'hosting/id/'+id+'/section/action/action/passwd', function(arr)
		{
			$.each(arr, function(i, val)
			{
				if(i == 'e')
					bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
						[{
							"label" : "Продолжить",
						}]
					);

				if(i == 's')
					location.reload();
			});
		});
	}
}

function change_tarif(id)
{
	if($('#tarifs').val() == 0)
		$('#info_tarif_change').html('');
	else
		$.getJSON(home+'hosting/id/'+id+'/section/action/plan/'+$('#tarifs').val()+'/action/tarif', function(arr)
		{
			$('#info_tarif_change').html(' <b>Сервер будет арендован до</b>: '+arr['info']);
		});
}

function upd_hdd(id)
{
	$.getJSON(home+'hosting/id/'+id+'/section/action/hdd/'+$('#hdd').val()+'/action/hdd_addon', function(arr)
	{
		$('#info_hdd').html(arr['sum']);
	});
}

function upd_extend(id)
{
	$.getJSON(home+'hosting/id/'+id+'/section/action/time/'+$('#time').val()+'/action/extend', function(arr)
	{
		$('#info_extend').html(arr['sum']);
	});
}