
/**
 * Shows a confirm dialog with a given confirm text.
 * 
 * @param form
 * @param confirm_text
 * @param action_path
 * @returns {Boolean}
 */
function handleConfirmDialog(form, confirm_text, action_path, param_text) {
	$message = getLanguageItem(confirm_text);
	
	if(confirm($message + (param_text != null ? param_text : ""))) {	
		if(action_path != null) {
			form.attr("action", action_path);
		}
		return true;
	}
	return false;
}

function getLanguageItem($lang_item_alias) {
	$language_item = "";
	try {
		$j.ajax({
		  type: "POST", async: false, url: "../framework/ajax/language_support.php",  data: "lang_entry="+$lang_item_alias,
		  success: function(data){
		    $language_item=data;
		  }
		});	
	} catch (e) {/* do nothing, request comes from frontend site */}
	
	if($language_item == "") {
	try {
		$j.ajax({
		  type: "POST", async: false, url: "framework/ajax/language_support.php",  data: "lang_entry="+$lang_item_alias,
		  success: function(data){
			$language_item=data;
		  }
		});	
	} catch (e) {/* do nothing, request comes from admin site */}
	}
	return $language_item;
}

/**
 * Hides a couple of elements for a page. fields: input-field, label-field,
 * help-icon, line-break for element.
 * 
 * @param $name
 * @param $help_entry
 */
function hideElements($name, $help_entry) {
	$j('#' + $name).hide("fast");
	$j('#' + $name + '_label').hide("fast");
	$j('#' + $name + '_br').hide("fast");
	$j('#' + $name + '_hr').hide("fast");
	$j('#' + $name + '_additive').hide("fast");
	if ($help_entry != null) {
		$j('#help_icon_' + $help_entry).hide("fast");
	}
}

/**
 * Shows a couple of elements for a page. fields: input-field, label-field,
 * help-icon, line-break for element.
 * 
 * @param $name
 * @param $help_entry
 */
function showElements($name, $help_entry) {	
	$j('#' + $name).show("fast");
	$j('#' + $name + '_label').show("fast");
	$j('#' + $name + '_br').show("fast");
	$j('#' + $name + '_hr').show("fast");
	$j('#' + $name + '_additive').show("fast");
	if ($help_entry != null) {
		$j('#help_icon_' + $help_entry).show("fast");
	}	
}

