// Die Funktion openChild wird zum Oeffnen von Childwindows per JavaScript eingesetzt.
// Uebegabe Parameter sind:
//
// childUrl (string) - die URL des zu Oeffnenden Fensters
// childName (string) - der Name des Fensters
// childWidth (integer) - die Breite
// childHeight (integer) - die Hoehe
// childStatus (integer) - die Statuszeile wird angezeigt
// childScrollbars (yes/no) -  es kann Scrollbars geben
// childLocation (yes/no) - die Adresszeile wird angezeigt
// childTollbar (yes/no) - die Toolbar wird angezeigt
// childMenubar (yes/no) - die Menubar wird angezeigt

// das Fenster wird in der Mitte des Bildschirms geoeffnet

function openChild(childUrl,childName,childWidth,childHeight,childStatus,childScrollbars,childLocation,childTollbar,childMenubar) {
	var newChild = null;
	if (childWidth>0) {
		childPosLeft = Math.floor((screen.width - childWidth) / 2);
		childPosTop = Math.floor((screen.height - childHeight) / 2);
		newChild = window.open(childUrl,childName,'width='+childWidth+',height='+childHeight+',innerwidth='+childWidth+',innerheight='+ childHeight+',top='+childPosTop+',left='+childPosLeft+',status='+childStatus+',scrollbars='+childScrollbars+',location='+childLocation+',toolbar='+childTollbar+',menubar='+childMenubar);
	} else {
		newChild = window.open(childUrl,childName);
	}
	if (newChild != null)
		newChild.window.focus();
		
		return newChild;
}

function getElementsByClass(searchClass,node,tag) {
 	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;

	//var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var Suche = /(greyout)/g;

    for (i = 0, j = 0; i < elsLen; i++) {

        if (Suche.test(els[i].className)) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function greyout(f, n) {
    var myEls = getElementsByClass('greyout',document.getElementById('overlay'+n));

    for (i=0; i<myEls.length; i++) {
        if (f.checked) {
            myEls[i].style.opacity=1;
            myEls[i].style.MozOpacity=1;
            myEls[i].style.filter='alpha(opacity=100)';
        }else{
            myEls[i].style.opacity=0.3;
            myEls[i].style.MozOpacity=0.3;
            myEls[i].style.filter='alpha(opacity=30)';
        }
    }
    return true;
}


function checkall() {
    var allLen = document.getElementsByName('checkboxspecial').length;

    for(i=0; i<allLen; i++) {
        greyout(document.getElementsByName('checkboxspecial')[i], i);
    }
}

function hideErrorBox(ptForm)
{
/********************************
Blendet die Fehlerbox aus
---------------------------------
LDI, 17.11.05 init
********************************/
	if (document.getElementById(ptForm+ ":errorBox"))
	{
		document.getElementById(ptForm+":errorBox").style.display="none";
	}		
		
}

function disableButton()
{
	var loInput = document.getElementsByTagName("input");
	
	for (var i=0;i<loInput.length;i++)
	{
		if (loInput[i].type=="submit")
		{
			if(loInput[i].id.indexOf("cmdLogout")==-1)
			{
				loInput[i].disabled="true";
			}
		}
	}
}

function clearEingabe(ptFeld)
{
	var loInputs = document.getElementsByTagName("input");
	
	for (var i=0;i<loInputs.length;i++)
	{
		if (loInputs[i].id.indexOf(ptFeld) > -1)
		{
			loInputs[i].value="";
		}
	}
}


/**
 * Legt einen Layer über die aktuelle Eingabemaske zur Vermeidung von Doppelkicks
 * @return
 */
function FreezeScreen() {
    var outerPane = document.getElementById('pane');
    if (outerPane) {
  	  outerPane.className = 'FreezePaneOn';
    }
    
    return true;
 }
