function openWin( url, width, height, windowName ) {
    openWin( url, width, height, "yes", windowName );
}

function scrollToMe(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	window.scrollTo(0, posy);
}

/**
	Opens a windows with specified parameters.
	
	@param url
	@param width
	@param height
	@param scrollbars yes, no. Default is yes.
	@param windowName
	*/
function openWin( url, width, height, scrollbars, windowName ) {
    if ( !windowName ) {
        windowName="newWindow";
    }
    var newWindow = open( url, windowName, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrollbars+",resizable=yes,copyhistory=no,width=" + width + ",height=" + height );
    newWindow.focus();
}

function openHelpWin( urlAnker ) {
    helpWin = open( urlAnker, "helpWindow", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500" );
    helpWin.focus();
}

function isNumber( text ) {
    if ( text.length < 1 ) {
    	return false;
   	}
    for ( var i=0; i < text.length; i++ ) {
    	var character = text.charAt( i );
        if ( ( character < '0' || character > '9' ) && character != '.' && character != ',' ) {
            return false;
        }
    }
    return true;
}

function isInteger( text ) {
    if ( text.length < 1 ) {
    	return false;
   	}
    for ( var i=0; i < text.length; i++ ) {
    	var character = text.charAt( i );
        if ( character < '0' || character > '9'  ) {
            return false;
        }
    }
    return true;
}

function setDocumentElementVisibility( thisDocument, name, visibility ) {
	if( thisDocument != null && thisDocument.getElementById( name ) != null ) {
		thisDocument.getElementById( name ).style.display = visibility;
	}
}

/**
	Opens a progress bar message in specified document's body.
	
	@param document The message will be centered in this document's body and its location will be reset, if url is specified.
	@param message Message to display above image
	@param image Image to display beneath message
	@param url new location of document. Leave empty if the location shall not be reset.
	*/
function showProgress( document, message, image, url ) {
    var progressDiv = document.createElement( "div" );
    var dropShadow = document.createElement( "div" );
    progressDiv.id = "ProgressWindow";
    progressDiv.className = "Progress";
    dropShadow.className = "DropShadow";
    dropShadow.id = "ProgressWindowShadow";
    
    var progressText = document.createElement( "p" );
    progressText.appendChild( document.createTextNode( message ) );
    progressDiv.appendChild( progressText );

    var progressImage = document.createElement( "img" );
    progressImage.className = "Progress";
    progressImage.src = image;

    progressDiv.appendChild( progressImage );

	// creates a temporary body element to write div to... gulp
	if( !document.body ) {
		document.write( '<body/>') ;
	}
    // IE only finds them this way:
    var styleWidth = getStyle( "DIV.Progress", "width" );	
    var	styleHeight = getStyle( "DIV.Progress", "height" );	
	
    if( typeof styleWidth == 'undefined' ) {
    	// Firefox only like this:
		styleWidth = getStyle( "div.Progress", "width" );
    }
    if( typeof styleHeight == 'undefined' ) {
    	// Firefox only like this:
		styleHeight = getStyle( "div.Progress", "height" );
    }
    
    var centeredLeft = Math.round( ( document.body.clientWidth - parseInt( styleWidth ) ) / 2 );
    var centeredTop = Math.round( ( document.body.clientHeight - parseInt( styleHeight ) ) / 2 );
    
    progressDiv.style.top = centeredTop + 'px';
    progressDiv.style.left = centeredLeft + 'px';
    dropShadow.style.top = centeredTop + 10 + 'px';
    dropShadow.style.left= centeredLeft + 10 + 'px';
    
    
    document.body.appendChild( dropShadow );
    document.body.appendChild( progressDiv );
    
	if( url ) {
	    document.location.href = url;
	}
}

function hideProgress( document ) {
	var progressWindow = document.getElementById( 'ProgressWindow' );
	if( progressWindow ) {
		progressWindow.style.display = 'none';
	}
	var shadow = document.getElementById( 'ProgressWindowShadow' );
	if( shadow ) {
		shadow.style.display = 'none';
    }
}

/**
Gets the specified property of the specified style class, e.g. the "border" value of the "DIV.Message" class.

@param styleClass style class to find
@param property style property to get 
*/
function getStyle( styleClass, property ) {
var cssRules;
if (document.all) {
	cssRules = 'rules';
}
else if (document.getElementById) {
	cssRules = 'cssRules';
}
for (var S = 0; S < document.styleSheets.length; S++) {
	for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
		var currentRule = document.styleSheets[S][cssRules][R];
		if (currentRule.selectorText == styleClass) {
			return document.styleSheets[S][cssRules][R].style[property];
		}
	}
}
}

/**
* Determine if a reference is defined
*/
function referenceDefined(o) {return (typeof o!="undefined");};

/**
* Determine if an object or class string contains a given class.
*/
function hasStyleClass(o,name) {
return new RegExp("(^|\\s)"+name+"(\\s|$)").test(o.className);
};

/**
* Add a class to an object.
*/
function addStyleClass(o,name) {
	if(hasStyleClass(o,"table-sorted-desc-hover") || hasStyleClass(o,"table-sorted-asc-hover")) {
		removeStyleClass(o,"table-sorted-desc-hover");
		removeStyleClass(o,"table-sorted-asc-hover");
	}
	var c = o.className || "";
	if (referenceDefined(c) && !hasStyleClass(o,name)) {
		o.className += (c?" ":"") + name;
		//o.className = name + (c?" ":"") + o.className;
	}
};

function addStyleClassIfNotActive(o,name) {
	if(!hasStyleClass(o,"table-sorted-desc") && !hasStyleClass(o,"table-sorted-asc")) {
		addStyleClass(o,name);
	}
};

/**
* Remove a class from an object
*/
function removeStyleClass(o,name) {
var c = o.className || "";
o.className = c.replace(new RegExp("(^|\\s)"+name+"(\\s|$)"),"$1");
};

/**
* Get style property from specified element 
*/
function getElementStyle(element,property) {
if (window.getComputedStyle)
	return window.getComputedStyle(element,null).getPropertyValue(property);
if (element.currentStyle)
    return element.currentStyle[property];
return null;
}

// Bilder anzeigen mit "Zoom"-Funktion

var zaehler = 50;
function aufmachen(breite,ID) {
 if (zaehler < breite) {
  document.getElementById(ID).style.display="inline";
  document.getElementById(ID).style.width=zaehler+"px";
  zaehler += 10; 
  window.setTimeout("aufmachen("+breite+",'"+ID+"')",0);
 }
 else {
  document.getElementById("beschreibung-"+ID).style.display="block";
 }
}

function zumachen(ID) {
 document.getElementById(ID).style.display="none";
 document.getElementById("beschreibung-"+ID).style.display="none";
 zaehler = 50;
}