/**
 * specific.js
 *
 * Author: Jarett Creason
 * Date: April 2008
 *
 * Specific javascript functions used on various pages
 * for specific kinds of actions
 */


// make the contentId info passed in into editable stuff
function contentMakeEditable(cid) {
	// make the editable stuff show
	if(YAHOO.util.Dom.hasClass('ContentTitleText'+cid, 'shownBlock')) {
		YAHOO.util.Dom.replaceClass('ContentTitleText'+cid, 'shownBlock', 'hidden');
		YAHOO.util.Dom.replaceClass('ContentTitleEdit'+cid, 'hidden', 'shownBlock');
		YAHOO.util.Dom.replaceClass('ContentText'+cid, 'shownBlock', 'hidden');
		YAHOO.util.Dom.replaceClass('ContentEdit'+cid, 'hidden', 'shownBlock');
		YAHOO.util.Dom.replaceClass('editLink'+cid, 'shownInline', 'hidden');
		YAHOO.util.Dom.replaceClass('restoreLink'+cid, 'hidden', 'shownInline');

	// restore to only text
	} else {
		YAHOO.util.Dom.replaceClass('ContentTitleText'+cid, 'hidden', 'shownBlock');
		YAHOO.util.Dom.replaceClass('ContentTitleEdit'+cid, 'shownBlock', 'hidden');
		YAHOO.util.Dom.replaceClass('ContentText'+cid, 'hidden', 'shownBlock');
		YAHOO.util.Dom.replaceClass('ContentEdit'+cid, 'shownBlock', 'hidden');
		YAHOO.util.Dom.replaceClass('editLink'+cid, 'hidden', 'shownInline');
		YAHOO.util.Dom.replaceClass('restoreLink'+cid, 'shownInline', 'hidden');
	}
}

// submit the changes to the content
function contentUpdate(formName, contentUpdBtn) {
	contentUpdBtn.disabled;

	document.forms[formName].elements['doFunction'].value = 'updateContent';

	// set the form, so that it automatically sends in the 
	// POST data from the passed in form
	YAHOO.util.Connect.setForm(formName); 

	// modifyContentCallback is located in javascript/generalAjax.js
	YAHOO.util.Connect.asyncRequest('POST', 'formPosts/contentActions.php', modifyContentCallback); 
}

// used from common_functions.php on almost every page with normal content
// confirm whether the user wants to really delete the content from the page
function contentConfirmDelete(formName) {

	// if they confirm the delete, use AJAX and submit the form
	if (confirm('Are you sure you want to delete this content?')) {
		// set the form's 'doFunction' hidden variable
		document.forms[formName].elements['doFunction'].value = 'deleteContent';

		// set the form, so that it automatically sends in the 
		// POST data from the passed in form
		YAHOO.util.Connect.setForm(formName); 

		// modifyContentCallback is located in javascript/generalAjax.js
		YAHOO.util.Connect.asyncRequest('POST', 'formPosts/contentActions.php', modifyContentCallback); 
	}
}

