function init_branding()
{
	$('#branding-save').off('click');
	$('#branding-save').click(function(event){
		event.preventDefault();
		branding_save();
	});
	
	get_branding();
}

function get_branding()
{
	var datastr = get_ajax_datastr("admin", "branding", "get");
	ajax_call(datastr, ajax_branding_get, null);
}


function branding_save()
{
	$('#branding-error').html('');
	var emdata = $('#branding-form').serialize();
	var datastr = get_ajax_datastr("admin", "branding", "set");
	datastr += "&" + emdata;
	ajax_call(datastr, ajax_branding_save, null);
}

/////////////////////////////////////////////////////////////////////////////////////////

function ajax_branding_get(x, jqXHR, textStatus, params)
{
	if(x != null) {
		$('#branding-error').html('');
		if(x.status == 'ok') {
			var branding = x.data;
			for (var key in branding) {
				 if(branding.hasOwnProperty(key)) {
					if(branding[key] !== false)
						$('#'+key).val(branding[key]);
				 }
			}
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////

function ajax_branding_save(x, jqXHR, textStatus, params)
{
	if(x != null) {
		if(x.status == 'ok') {
			$('#branding-error').html('ok');
		}
	}
}