function mi_confirm(meldung)
{
    return confirm(meldung);
} // end

function mi_popup(strURL, strName, strParameter) {
	objNewWindow= window.open(strURL, strName, strParameter);
}

function mi_select_checkboxes(strKey) {
	var toCheck = 'input['+strKey+']';
	alle = document.getElementsByTagName("input");
	for (var i = 0; i < alle.length; ++i) {	
		name = String(alle[i].getAttribute('name'));
		teil = name.substr(0, toCheck.length);
		type = alle[i].getAttribute('type');
		if (type == 'checkbox' && teil == toCheck) {
			/* alle[i].setAttribute('checked','checked'); */
			alle[i].checked = true;
		}
	}	
}

function mi_unselect_checkboxes(strKey) {
	var toCheck = 'input['+strKey+']';
	alle = document.getElementsByTagName("input");
	for (var i = 0; i < alle.length; ++i) {
		name = String(alle[i].getAttribute('name'));
		teil = name.substr(0, toCheck.length);
		type = alle[i].getAttribute('type');
		if (type == 'checkbox' && teil == toCheck) {
			// alle[i].removeAttribute('checked','');
			alle[i].checked = false;
		}
	}	
}

/*
function ALTswitch_tab(intTabreiter) {
	tabreiter = document.getElementById('mi_tabreiter' + intTabreiter);
	inhalt = document.getElementById('mi_tabreiter_content' + strIdContent);
	if (tabreiter != null && inhalt != null) {
		// alle_tabs = document.getElementsByName('mi_tabreiter');
		// for (var i = 0; i < alle_tabs.length; ++i) {
		for (var i = 0; i < anzahl_tabreiter; ++i) {
			alert(i);
			
		
			classname = alle_tabs[i].getAttribute('class');
			
			if (classname == 'tab_aktiv') {
				alle_tabs[i].setAttribute("class", "tab_inaktiv");
				alle_tabs[i].style.border = "1px solid #CCC";
				alle_tabs[i].style.color = "#AAA";
				alle_tabs[i].style.backgroundColor = "#EEE";
				
				// alert('get:' + alle_tabs[i].getAttribute('class'));
			}
			
		}
		alle_container = document.getElementsByName('tabcontainer');
		for (var i = 0; i < alle_container.length; ++i) {
			classname = alle_container[i].getAttribute('class');
			if (classname == 'show_content') {
				alle_container[i].setAttribute("class", "hide_content");
				// alert('get:' + alle_tabs[i].getAttribute('class'));
			}
		}
	
	}	
}
*/

function switch_tab(intTabreiter) {

	for (var i = 0; i < anzahl_tabreiter; ++i) {
		objTab = document.getElementById('mi_tabreiter'+i);
		objInhalt = document.getElementById('mi_tabreiter_content'+i);
		if (i == intTabreiter) {
			aktiviere_tab(objTab, objInhalt);			
		} else {
			deaktiviere_tab(objTab, objInhalt);
		}
	}
	
}

function aktiviere_tab(objTab, objInhalt) {
		if (objTab != null) {
			objTab.style.backgroundColor = "white";
			objTab.style.border = "1px solid #CCC";
			objTab.style.borderBottom = "1px solid white";
		}
		if (objInhalt != null) {
			objInhalt.style.visibility = "visible";
			objInhalt.style.display = "block";
		}				
}

function deaktiviere_tab(objTab, objInhalt) {
		if (objTab != null) {
			objTab.style.backgroundColor = "#EEE";
			objTab.style.border = "1px solid #CCC";			
		}
		if (objInhalt != null) {
			objInhalt.style.visibility = "hidden";
			objInhalt.style.display = "none";
		}	
}

/*
* Färbt eine angeklickte Tabellenzeile mit der Farbe
*/
objMem = null;
strMemFarbe = '';
function mi_zeilefaerben(objZeile, strNeueFarbe) {

/*
	for(i=0;i<arrMem.length;i++) {
		arrMem[i].style.backgroundColor = strMemFarbe;
	}
*/
	if(objMem != null) {
		objMem.style.backgroundColor = strMemFarbe;
	}

/*
	for(i=0;i<objZeile.childNodes.length;i++) {
		if (objZeile.childNodes[i]!= null && objZeile.childNodes[i].nodeName == 'TD') {			
			objZeile.childNodes[i].style.backgroundColor = farbe;
		}
	}
*/
	objMem = objZeile;
	strMemFarbe = objZeile.style.backgroundColor;
	objZeile.style.backgroundColor = strNeueFarbe;
	
}

/*
* Wenn das Datumsfeld für ein Jahr nur 2stellig eingeben wird, wird mit dem aktuellen Jahrtausend ergänzt
* Ich nehme hierbei mal an, dass meine Scripte das Jahr 2099 nicht überleben werden... 
*/
function mi_datumsfeld_ergaenze_jahr(objFeld) {
	if (objFeld != null) {
		jahr = objFeld.value;		
		if (jahr.length == 1) {
			jahr = '200' + jahr;
			
		}		
		if (jahr.length == 2) {
			jahr = '20' + jahr;
			
		}
		objFeld.value = jahr;
	}
}

function mi_datumsfeld_ergaenze_null(objFeld) {
	if (objFeld != null) {
		if (objFeld.value.length == 1) {
			objFeld.value = '0' + objFeld.value;
		}
	}
}

// Funktion die ein Element mit einer bestimten ID versteckt oder anzeigt
// boolShow = true: Element wird angezeigt, false sonst

function mi_show_element(strId, boolShow) {
	objElement = document.getElementById(strId);
	if (objElement != null) {
		if (boolShow) {
		    objElement.style.visibility = 'visible';
			objElement.style.display = 'block';			
		} else {
		    objElement.style.visibility = 'hidden';
			objElement.style.display = 'none';		
		}
	}
}

/**
 * Wie mi_show_element überprüft aber ob das Element
 * gerade an ist und schaltet es dann aus und umgekehrt
 */
function mi_switch(strId) {
	objElement = document.getElementById(strId);
	if (objElement != null) {
		if (objElement.style.visibility == 'hidden') {
			mi_show_element(strId, true);
		} else {
			mi_show_element(strId, false);
		}
	}	
}


function mi_reset_textfield(strId) {
	objElement = document.getElementById(strId);
	if (objElement != null) {
		objElement.value = '';
	}
}

function mi_reset_calfields(strTag, strMonat, strJahr) {	
	mi_reset_textfield(strTag);
	mi_reset_textfield(strMonat);
	mi_reset_textfield(strJahr);
}

/**
 * mi_display_help:
 * Textlinks werden bei Mousover getriggert, so dass ein Hilfepopup zu einem Feld
 * erscheint. Dieses Popup wird rechts neben dem Link positioniert, mit dem Inhalt
 * gefüllt und dargestellt. 
 */
function mi_display_help(strId, objAnchor) {
	xajax_display_help(strId);
	var pos = Position.get(objAnchor);
	x = pos.left +100;
	y = pos.top - 30;
	if (y <= 0) y = 10;
	Position.set('DIVHelp',x, y);
	// window.setTimeout("xajax_display_help('"+strId+"')", 500);
	mi_show_element('DIVHelp', true);
}

function mi_display_entry(strId, objAnchor) {
	var pos = Position.get(objAnchor);
	x = pos.left +100;
	y = pos.top - 30;
	if (y <= 0) y = 10;
	Position.set('DIVEntry',x, y);
	mi_show_element('DIVEntry', true);
	xajax_display_entry(strId);
}

function mi_open_dialog(strId, objAnchor) {
	
	objElement = document.getElementById(strId);
	if (objElement != null) {
		objElement.style.position = 'absolute';
	}	
	var pos = Position.get(objAnchor);
	// var pos = Position.getCenter(window);
	// x = pos.left+ 100;
	// y = pos.top - 150;
	x = pos.left;
	y = pos.top;
	Position.set(strId,x, y);
	mi_show_element(strId, true);
}

function mi_delete_entry(strId, objAnchor) {
	meldung = "Der Eintrag wird unwiderruflich gelöscht. Weiter?";
	if (!confirm(meldung)) {
		return false;
	} else {
		xajax_delete_entry(strId);
	}
}

function mi_openwindow_pdf(strLink) {
	window.open(strLink, "viewpdf", "width=700,height=600,left=10,top=10,scrollbars=no,resizable=yes")
}

function mi_closeSavemessage(strId) {
	mi_show_element(strId, false);
}
function mi_clear_innerHTML(strId) {
	objElement = document.getElementById(strId);
	if (objElement != null) {
		objElement.innerHTML = '';
	}
}

function call_yui_calendar() {
	YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","DIVYUICalendarPopup");
	YAHOO.example.calendar.cal1.render(); 
}





