/**
 * window for the overlay of delete confirmations or so.
 *
 * @var object
 */
var overlayWindow = null;

/**
 * displays the overflay image with the delete confirmatio
 *
 * @param url -> which url should be opened
 */
function doAjaxDeleteConfirmation(url) {
	if (overlayWindow.visible()) {
		overlayWindow.hide();
	}

	new Ajax.Request(url, {
		method:     'POST',
		parameters: 'bisajax=1',
		onCreate:   function() {overlayWindow.show();},
		onFailure:  function() {overlayWindow.hide();},
		onSuccess: function(oResponse) {
			if (oResponse.status != 200) {
				overlayWindow.hide();
				return true;
			} else {
				overlayWindow.innerHTML = oResponse.responseText;
				return false;
			}
		}
	});
}//end - function doAjaxDeleteConfirmation(url)

function init() {
	var aElements = $$('.dynamic');
	overlayWindow = $('Overlay');

	for (i = 0; i < aElements.length; i++) {
		$(aElements[i]).style.display = 'block';
	}
}

/**
 * select or deselected the other checkboxes of oCheckbox.up('form') relative
 * to the status of ocheckbox itself.
 *
 * @param object Checkbox
 */
function selectAll(oCheckbox) {
	oForm = $(oCheckbox).up('form');

	try {
		for (i = 0; oForm.elements.length; i++) {//for-loop for every checkbox of the form
			//change the status of the other checkboxes
			var oElement = oForm.elements[i];
			if ((oElement.type == 'checkbox') && (oElement != oCheckbox) && (oElement.name != "")) {
				oForm.elements[i].checked = (oCheckbox.checked) ? true : false;
			}
		}//end - for-loop for every checkbox of the form
	} catch (Exception) {

	}
}//end - function selectAll(oCheckbox)

/**
* function NonUTF8ToGerman(str)
*
* Changes every german special char into its html entity.
*
* @param str -> to checking string
* @return string
*/
function NonUTF8ToGerman(str) {
  for(var i = 0; i<str.length;i++) {
    str = str.replace(/ä/g,"&auml;");
    str = str.replace(/Ä/g,"&Auml;");
    str = str.replace(/ö/g,"&ouml;");
    str = str.replace(/Ö/g,"&Ouml;");
    str = str.replace(/ß/g,"&szlig;");
    str = str.replace(/ü/g,"&uuml;");
    str = str.replace(/Ü/g,"&Uuml;");
  }
  return str;
}//end - function NonUTF8ToGerman(str)

/**
* Restliche Sonderzeichen in HEX umwandeln
*
* @param string str
* @return string str
*/
function ReplaceSpecialMarks(str) {
  for(var i = 0; i<str.length;i++) {
    str = str.replace("!","%21");
    str = str.replace("(","%28");
    str = str.replace(")","%29");
    str = str.replace("*","%2A");
    str = str.replace("'","%27");
  }
  return(str);
}
