// Div AN/AUS Schalten
function toggle_layer(id,close_id) {
  if (document.getElementById)  {
    if (document.getElementById(id).style.display == "none") {
       document.getElementById(id).style.display = 'block';
	  } else {
	     document.getElementById(id).style.display = 'none';
    }
    if (document.getElementById(close_id).style.display == "block") {
       document.getElementById(close_id).style.display = 'none';
	  }
 
  }
}
// Div AN/AUS Schalten
function toggle_layer_date(id,close_id,close_id1) {
  if (document.getElementById)  {
    if (document.getElementById(id).style.display == "none") {
       document.getElementById(id).style.display = 'block';
	  } else {
	     document.getElementById(id).style.display = 'none';
    }
    if (document.getElementById(close_id).style.display == "block") {
       document.getElementById(close_id).style.display = 'none';
	  }
    if (document.getElementById(close_id1).style.display == "block") {
       document.getElementById(close_id1).style.display = 'none';
	  } 
  }
}

// Alle Checkboxen auswählen
function Check_All (field_status, f, field_name) {
  var change_to;
  if (field_status.checked == true) {
    change_to = true;
  } else {
    change_to = false;
  }
  for (var i=0; i< f.elements.length; i++) {
    var field = f.elements[i];
    if (field.type == "checkbox" && field.name.substr(0, field_name.length) == field_name) {
      field.checked = change_to;
    }
  }
}

// Aktion bestätigen
function form_confirm(option,theform,error_text) {
	if (confirm(error_text)) {

	  if (option == 'del') {
  		document.forms[theform].action='?option=del';
	  }

		document.forms[theform].submit();
	}	else{
		return false
	}
}
/**
 * enables highlight and marking of rows in data tables
 *
 */
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

function PMA_markRowsInit() {
    // for every table row ...
	var rows = document.getElementsByTagName('tr');
	for ( var i = 0; i < rows.length; i++ ) {
	    // ... with the class 'odd' or 'even' ...
		if ( 'odd' != rows[i].className && 'even' != rows[i].className ) {
		    continue;
		}
	    // ... add event listeners ...
        // ... to highlight the row on mouseover ...
	    if ( navigator.appName == 'Microsoft Internet Explorer' ) {
	        // but only for IE, other browsers are handled by :hover in css
			rows[i].onmouseover = function() {
			    this.className += ' hover';
			}
			rows[i].onmouseout = function() {
			    this.className = this.className.replace( ' hover', '' );
			}
	    }
        // ... and to mark the row on click ...
		rows[i].onmousedown = function() {
		    var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
		        return;
		    }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
			    this.className += ' marked';
            } else {
			    this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
		}

		// ... and disable label ...
		var labeltag = rows[i].getElementsByTagName('label')[0];
		if ( labeltag ) {
		    labeltag.onclick = function() {
		        return false;
		    }
	    }
	    // .. and checkbox clicks
		var checkbox = rows[i].getElementsByTagName('input')[0];
		if ( checkbox ) {
		    checkbox.onclick = function() {
		        // opera does not recognize return false;
		        this.checked = ! this.checked;
		    }
	    }
	}
}


// Add the selected items from the source to destination list
	function addSrcToDestList(scr,dest)
	{

		destList = document.getElementById(dest);
		srcList = document.getElementById(scr);

		var len = destList.length;
		for(var i = 0; i < srcList.length; i++)
		{
			if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
			//Check if this value already exist in the destList or not
			//if not then add it otherwise do not add it.
			var found = false;
			for(var count = 0; count < len; count++)
			{
				if (destList.options[count] != null)
				{
					if (srcList.options[i].text == destList.options[count].text)
					{
						found = true;
						break;
	      			}
	   			}
			}
			if (found != true)
			{
				destList.options[len] = new Option(srcList.options[i].text,srcList.options[i].value);

				len++;
				srcList.options[i]= null;
				addSrcToDestList(scr,dest);
	        }
      	}
   	}
}

// Add the selected items from the destination to source list
	function addSrcToSrcList(dest,scr)
	{

		destList = document.getElementById(dest);
		srcList = document.getElementById(scr);
		var len = srcList.length;
		for(var i = 0; i < destList.length; i++)
		{
			if ((destList.options[i] != null) && (destList.options[i].selected)) {
			//Check if this value already exist in the destList or not
			//if not then add it otherwise do not add it.
			var found = false;
			for(var count = 0; count < len; count++)
			{
				if (srcList.options[count] != null)
				{
					if (destList.options[i].text == srcList.options[count].text)
					{
						found = true;
						break;
	      			}
	   			}
			}
			if (found != true)
			{
				srcList.options[len] = new Option(destList.options[i].text,destList.options[i].value);
				len++;
				destList.options[i]= null;
				addSrcToSrcList(dest,scr);

	        }
      	}
   	}
}

function FensterOeffnen (Adresse) {
  Fenster1 = window.open(Adresse, "Drucken", "width=800,height=400,left=100,top=100,toolbar=no, status=no, menubar=no, scrollbars=yes, resizable=yes");
  Fenster1.focus();
}