function preloadImages() 
// preload images function to accelerate the image loading
{
   if (document.images) {
      for (var i = 0; i < preloadImages.arguments.length; i++) {
         (new Image()).src = preloadImages.arguments[i];
         //alert( preloadImages.arguments[i] + ' loaded...' );
      }
   }
}

function init_js_button( graphics_dir, btn_id, btn_height ) 
// js button update the images function 
{
	add_opt = '';
	document.getElementById( 'btn_mod_a_l_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_left_part_7x'   + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_a_m_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_middle_part_4x' + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_a_r_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_right_part_7x'  + btn_height + add_opt + '.gif)';

	add_opt = '_mark';
	document.getElementById( 'btn_mod_b_l_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_left_part_7x'   + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_b_m_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_middle_part_4x' + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_b_r_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_right_part_7x'  + btn_height + add_opt + '.gif)';
	
	update_js_button( graphics_dir, btn_id, btn_height, true );
	update_js_button( graphics_dir, btn_id, btn_height, false );
}
function update_js_button_old( graphics_dir, btn_id, btn_height, mouse_over ) 
// js button update the images function 
{
	if (mouse_over) add_opt = "_mark"; else add_opt = "";
	
	document.getElementById( 'btn_mod_a_l_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_left_part_7x'   + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_a_m_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_middle_part_4x' + btn_height + add_opt + '.gif)';
	document.getElementById( 'btn_mod_a_r_' + btn_id ).style.backgroundImage = 'url( ' + graphics_dir + 'btn_empty_right_part_7x'  + btn_height + add_opt + '.gif)';
}

function update_js_button( graphics_dir, btn_id, btn_height, mouse_over ) 
// js button update the images function 
{
	if (mouse_over) {
		document.getElementById( 'btn_mod_a_' + btn_id ).style.display = 'none';
		document.getElementById( 'btn_mod_b_' + btn_id ).style.display = '';
	} else {
		document.getElementById( 'btn_mod_b_' + btn_id ).style.display = 'none';
		document.getElementById( 'btn_mod_a_' + btn_id ).style.display = '';
	}
}

function update_element_content(element_id, new_content)
// browser-indepent update of element-content
{
	if(document.getElementById)
		document.getElementById(element_id).innerHTML = new_content;
	else if(document.all)
		document.all.element_id.innerHTML = new_content;
	else if(document.layers) {
  		document.element_id.document.open();
  		document.element_id.document.write(new_content);
  		document.element_id.document.close();
	}
	
}

function number_format_js(  number, laenge, sep, th_sep ) 
// Formatiert eine Nummer PHP-like		
{
  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  return arr_int[0]+sep+arr_int[1];
}

function efn_format_to_amount( flt_amount, decimals ) {
	return number_format_js( (Math.round(flt_amount * Math.pow( 10, decimals )) / Math.pow( 10, decimals )), decimals, ',','.' );
}
function efn_format_to_euro( flt_amount, decimals ) {
	return number_format_js( (Math.round(flt_amount * Math.pow( 10, decimals )) / Math.pow( 10, decimals )), decimals, ',','.' ) + ' &euro;';
}

function keyPressed_set_chkbox( field_id_chkbox )
// set correspondet checkbox
{
	document.getElementById(field_id_chkbox).checked = true;
}

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 