function emptybox() {
	if ($('#txtnewrhctitle').val() == "Title") {
		$('#txtnewrhctitle').val('');
		$('#txtnewrhctitle').css('color', '#000');
	}
}

function defaultbox() {
	if ($('#txtnewrhctitle').val() == "") {
		$('#txtnewrhctitle').val('Title');
		$('#txtnewrhctitle').css('color', '#8f8f8f');
	}
}

function clear_rhc() {
	$('#txtnewrhctitle').val('');
	$('#txtnewrhctext').val('');
}

function preview_rhc(title, text) {
	var count = $('#hdncntrhc').val();
	count = parseInt(count) + 1;
	$('#hdncntrhc').val(count);

	if (title == "") {
		var title = $('#txtnewrhctitle').val();
		var text = $('#txtnewrhctext').val();
	}

	var html = "<input type='hidden' name='hdntitle"+count+"' id='hdntitle"+count+"' value='"+title+"'>";
	html += "<input type='hidden' name='hdntext"+count+"' id='hdntext"+count+"' value='"+text+"'>";
	html += "<div class='shade' id='rhc"+count+"'><div id='rhc_menu'><h2>"+title+"</h2></div>";
	html += "<div id='rhc_box'>"+text+"</div></div>";

	$('#shownewrhc').append(html);
	clear_rhc();
}

function edit_rhc(rhc_id) {
	$('#vwrhctitle'+rhc_id).hide();
	$('#hdnrhctitle'+rhc_id).show();

	$('#vwrhctext'+rhc_id).hide();
	$('#hdnrhctext'+rhc_id).show();

	$('#vwaction'+rhc_id).hide();
	$('#hdnaction'+rhc_id).show();
}

function cancel_rhc(rhc_id) {
	$('#txtrhctitle'+rhc_id).val($('#vwrhctitle'+rhc_id).html());
	$('#txtrhctext'+rhc_id).val($('#vwrhctext'+rhc_id).html());

	$('#vwrhctitle'+rhc_id).show();
	$('#hdnrhctitle'+rhc_id).hide();

	$('#vwrhctext'+rhc_id).show();
	$('#hdnrhctext'+rhc_id).hide();

	$('#vwaction'+rhc_id).show();
	$('#hdnaction'+rhc_id).hide();
}

function del_rhc(rhc_id) {
	var cnfrm = confirm("You are about to delete the RHC. Continue?");
	if (cnfrm) {
		$.get('/data/json.php?f=rhc_del&p1='+rhc_id, function(data) {
			$('#rhc'+rhc_id).hide();
		});
	}
}

function set_rhc(rhc_id) {
	var title = $('#txtrhctitle'+rhc_id).val();
	var text = $('#txtrhctext'+rhc_id).val();
//	$.get('/data/json.php?f=rhc_set&p1='+rhc_id+'&p2='+title+'&p3='+text, function(data) {
//	$.post('/admin/fn_rhc.php', {rhc_id:rhc_id, arrTitle:title, arrText:text }, function(data) {
	$.post('/data/json.php?f=rhc_set', {rhc_id:rhc_id, arrTitle:title, arrText:text }, function(data) {
		$('#vwrhctitle'+rhc_id).html($('#txtrhctitle'+rhc_id).val());
	        $('#vwrhctext'+rhc_id).html($('#txtrhctext'+rhc_id).val());
		cancel_rhc(rhc_id);
	});


}
