jQuery(".editIcon").live('click', function() {
    jQuery(this).parent().children('.popBox').toggle();
});
jQuery(".autoClose").live('click', function() {
    jQuery(this).parent().hide();
});

jQuery("#submitHeaderContent").live('click', function() {
    jQuery.post("/updatesetting.php",
        { settingname: 'headercontent', settingvalue : jQuery("#headercontentinput").val(), textarea : 1 },
        function(data) {
            jQuery("#headerRightContent").hide();
            jQuery("#headercontentoutput").html(data);
        });
});

jQuery(document).ready(function () {
	// NEWSLETTER SIGNUP BOX
	jQuery(".newsletterSignup").click(function() {
		jQuery("#message").toggle('slow');
		jQuery("#newsletterBox").toggle('slow');
	});

	jQuery(".toggletools").click(function() {
		jQuery(".toolbox").toggle('fast');
	});

	// write editable box for any editable content areas
	jQuery(".editable").prepend(function() {
		thiscontent = jQuery(this).children(".content").html();
		settingname = jQuery(this).attr("id");

		return '<form method="post" action="/">'+
		'<input type="hidden" name="settingname" value="' + settingname + '" />' +
		'<input type="hidden" name="edit" value="1" />' +
		'<input type="hidden" name="pg" value="index" />' +
		'<div class="editIcon"><img src="/images/icon_edit.png" border="0" width="20"></div>'+
		'<div class="popBox">' +
			'<div class="autoClose">x</div>' +
			'<textarea class="cms_editor_mini" name="content">' + thiscontent +'</textarea><br />' +
			'<input type="submit" name="submit" value="Save">' +
		'</div></form>';
	});
	
	// Allow deleting of menu photos
	jQuery("#removemenuphoto").click(function() {
		thisbox = jQuery(this);
		itemid = thisbox.parent().children(".menuphoto").attr("id");
		jQuery(this).fastConfirm({
			position: "right",
			questionText: "Are you sure you want<br /> to delete this photo?",
			onProceed: function(trigger) {
				// delete photo and clear from display
			    jQuery.get("/deletemenuphoto.php",
			        { menuitemid: itemid},
			        function(data) {
						// clear out current photo
						thisbox.parent().children(".menuphoto").html("");
						thisbox.hide();
			        }
				);
			},
			onCancel: function(trigger) {
				// just close
			}
		});
	});
//jQuery(this).(".content").html()
});

