var IE = false;

if (window.ActiveXObject) {
	IE = true;
}

function trim(s) {
	while (s.substring(0,1) == ' ') {
    	s = s.substring(1,s.length);
  	}
  	
  	while (s.substring(s.length-1,s.length) == ' ') {
    	s = s.substring(0,s.length-1);
  	}
  	return s;
}

function makeHttpRequest(url, callback_function, return_xml) {

    var http_request = false;

    if (window.XMLHttpRequest) {            // Mozilla, Safari,...
        
        http_request = new XMLHttpRequest();
        
        if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {      // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Unfortunatelly you browser doesn\'t support this feature.');
        return false;
    }
    
    http_request.onreadystatechange = function() {

        try {
    		// alert(http_request.readyState);
            if (http_request.readyState == 4) {
			        	
                if (http_request.status == 200) {
                    if (return_xml) {                	
                        eval(callback_function + '(http_request.responseXML)');
                    } else {
                        eval(callback_function + '(http_request.responseText)');
                    }
                } else {
                    // RG, 27.02.2009: Alert-Meldungen sollten später in die Log-Datei rein:
                    // DH, 12.03.2009: JavaScript (AJAX) Fehler können in keine Datei gespeichert werden
                    // und vor allem nicht auf dem Server.
                    //alert('There was a problem with the request.(Code: ' + http_request.status + ')');
                }
            }
        } catch (e) {
            
        }
    }
    
    http_request.open('GET', url, true);
    http_request.send(null);
}


function absLeft(el) {
    return (el.offsetParent)? 
        el.offsetLeft + absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el) {
    return (el.offsetParent)? 
        el.offsetTop + absTop(el.offsetParent) : el.offsetTop;
}       

function hideField(field) {
    document.getElementById(field).style.visibility = "hidden";
}   

function showField(field) {
    document.getElementById(field).style.visibility = "visible";
}   

function submitForm() {
    document.getElementById('hm').submit();
    return true;
}

function submitForm2() {
    document.getElementById('hm2').submit();
}

var userwindow;
    
function showWindow(url, title, width, height) {
    
	width    = parseInt(width);
    height   = parseInt(height);
    var left = (screen.availWidth - width) / 2;
    var top  = (screen.availHeight - height) / 2;

	var windowOptions = "width="+width+",height="+height+",left="+left+",top="+top+"dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes";
    	
    if (typeof(userwindow) == "object") {
    	userwindow.close();
    }
    	
    userwindow = window.open(url, title, windowOptions);
    userwindow.focus();
}



	
