//<?php//
/**
 * ajax.js - AJAX Callback functions
 *
 * This file contains AJAX Callback functions
 *
 * @filesource
 */
 
/**
 * function refresh_drop_down_cb()
 *
 * This functions refreshes the the specified drop down
 *
 * - drop_down HTML markup of the new drop down
 * - id HTML element id in which the drop_down resides
 * - opener Boolean, true - if the drop_down exists in the opening window, false - if the drop_down exists in the current window
 * @param string Delimited as drop_down§id§opener
 * @see refreshDropDown()
 */
function refresh_drop_down_cb(args){
	
	var array = args.split("§");
	
	var drop_down = array[0];
	var id = array[1];
	var opener = array[2];
	
	if(opener = 'true'){
		window.opener.document.getElementById(id).innerHTML = drop_down;
	}else{
		document.getElementById(id).innerHTML = drop_down;
	}
}

/**
 * function inline_module_form()
 *
 * This function displays an inline form field for adding or editing an element
 *
 * @param string ID of the HTML element that is being affected by the adding/editing action
 * @param string Name of the module that the inline module is to affect
 * @param string The value of the action as either 'add','edit', or 'delete'
 * @see inlineModuleForm()
 */
function inline_module_form(name,module,action){
	show_progress(module);
	//
	selected_id = document.getElementById(name).value;
	//
	x_inlineModuleForm(module,selected_id,action,inline_module_form_cb);
}

/**
 * function inline_module_form_cb()
 *
 * This function replaces the HTML of the element specified as the placeholder of the inline module
 *
 * @param array An array return from inlineModuleForm(). 
 * [0] ID of the HTML element that is being affected by the adding/editing action
 * [1] Name of the module that the inline module is to affect
 * [2] The new HTML
 * @see inlineModuleForm()
 */
function inline_module_form_cb(args){
	name = args[0];
	module = args[1];
	html = args[2];
	//
	if(html == 'delete'){
		x_saveInlineModuleForm(module,'','','delete',save_inline_module_form_cb);
	}else{
		document.getElementById(module + '_div_in_place').innerHTML = html;
	}
}

/**
 * function save_inline_module_form()
 *
 * This function saves the added/edited value from the inline module
 *
 * @param string ID of the HTML element that is being affected by the adding/editing action
 * @param string Name of the module that the inline module is to affect
 * @param integer The ID value of the selected item being edited
 * @param string The value of the action as either 'add','edit', or 'delete'
 * @see saveInlineModuleForm()
 */
function save_inline_module_form(name,module,selected_id,value,action){
	show_progress(module);
	//
	x_saveInlineModuleForm(module,selected_id,value,action,save_inline_module_form_cb);
}

/**
 * function save_inline_module_form_cb()
 *
 * This function displays the HTML of the updated inline module
 *
 * @param array An array return from saveInlineModuleForm(). 
 * [0] ID of the HTML element that is being affected by the adding/editing action
 * [1] Name of the module that the inline module is to affect
 * [2] The new HTML
 * [3] The status of the save operation
 * @see saveInlineModuleForm()
 */
function save_inline_module_form_cb(args){
	name = args[0];
	module = args[1];
	html = args[2];
	status = args[3];
	//
	document.getElementById(module + '_div').innerHTML = html;
	//
	hide_progress(module);
}

/**
 * function show_progress()
 *
 * This function displays the progress animation gif in the specified HTML element
 * @param string Name of the module that the progress animation is for
 */
function show_progress(module){
	document.getElementById(module + '_div_in_place').innerHTML = '<img src="/admin/images/progress.gif" />';	
}

/**
 * function hide_progress()
 *
 * This function hides the progress animation gif in the specified HTML element
 * @param string Name of the module that the progress animation is for
 */
function hide_progress(module){
	document.getElementById(module + '_div_in_place').innerHTML = '';	
}

function set_search_keyword_cb($args){
	//do nothing	
}
//?>//