var Load = {
    send:true,
    imageFile:function(object) {
        var lIF_Values = new Array();
        var lIF_onProcess = false;
        var lIF_inProgress = null;
        var lIF_loaded   = null;
        var lIF_pS       = null;
        var lIF_pI       = null;
        var callback     = null;
        var returnparams = null;
        
        if(typeof object == 'string') 
            lIF_Values.push(object);
        else 
            for(var i = 0 ; i < object.length ; i++) lIF_Values.push(object[i]);

        function loadSingleImage () {            
            var imgFile = new Image(); 
                imgFile.onload = function () {                
                    if(lIF_Values.length > 1) { 
                        lIF_Values.shift();
                        window.setTimeout(loadSingleImage,25);
                    } else {
                        if(lIF_pS) Element.unlink(lIF_pS);
                        
                        if(callback) callback.call(callback,object,(returnparams)?returnparams:null);
                    } 
                    imgFile.onload = function () {}; //war so bei der Lightbox2 gemacht                    
                }   
            imgFile.src = lIF_Values[0];
        }
                                
        this.initLoad = function (preloadlayer,cb,rp) {
            returnparams = rp;
            callback     = cb;
            lIF_pS       = preloadlayer;
            loadSingleImage();
        }
    },
    ajaxContent:function (configFile) {    
        var config       = configFile;
        var callback     = null;
        var lAC_pS       = null;
        var returnparams = null;
        var http_request = null;
        
    	function addPostParams(paramsObj) {
            var postParams = null;
            
            for(key in paramsObj) {
        		if(!postParams) 
        			postParams = key+"="+encodeURIComponent(paramsObj[key]);
        		else 
        			postParams += "&"+key+"="+encodeURIComponent(paramsObj[key]);
            }    			
    		return (postParams)?postParams:'';
    	}
    	       
    	function addGetParams (paramsObj) {
            var getParams = null;
        
            for(key in paramsObj) {
        		if(!getParams) 
        			getParams = "?"+key+"="+encodeURIComponent(paramsObj[key]);
        		else 
        			getParams += "&"+key+"="+encodeURIComponent(paramsObj[key]);
            }            
    		return (getParams)?getParams:'';
    	}
    	
    	function getAjaxContent() {    	
    		if(window.XMLHttpRequest) 	
    			http_request = new XMLHttpRequest();
    		else 
    			http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        
    		if(config.method == 'POST') {
    			http_request.open(config.method,config.path,true);
                http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
				http_request.setRequestHeader("accept-charset","UTF-8;");
                http_request.send(addPostParams(config.params));
            } else {
                var getParams = addGetParams(config.params);
                
                /*
                                            * IE Fix:
                                             * Der Internet Explorer cacht die Datei und läd sie neu so das die HTTP XML Request nie 
                                             * ausgeführt wird. Somit noch einen Timestamp mit anhängen so das die Seite jedesmal
                                             * neu geladenwird
                                             */
                if(navigator.appName == 'Microsoft Internet Explorer') {  
                    var t = new Date();                        
                    if(getParams || config.path.match(/\?/gi)) {
                        getParams += '&'+Element.generateId(10)+'='+t.getTime();
                    } else {
                        getParams += '?'+Element.generateId(10)+'='+t.getTime();
                    }
                }
                
                http_request.open('GET',config.path+''+getParams,true);
                http_request.send(null);
            }
            
    		http_request.onreadystatechange = function () {
                try {
        			if(http_request.readyState == 4) {   
        				if(http_request.status == 200) {
        					var requestVal = http_request.responseText;             
                            
                            /*Preloader entfernen soweit vorhanden */
                            if(lAC_pS) { 
                                Element.unlink(lAC_pS); 
                                lAC_pS = null;
                            }
                            
        					if(callback) {
        						callback.call(callback,requestVal,returnparams);
        					}
        				}
        			}
                } catch (e) {
                    //sollte der Request abgegbrochen werden ¸ber http_request.abort( )
                    //wirft der FF aktuell eine Exception die wir hier mal gekonnt abfangen
                }
    		}
    	}
        
        this.cancelRequest = function () {
            if(lAC_pS) {
                Element.unlink(lAC_pS);
                lAC_pS = null; 
            }
            http_request.abort();
            http_request = false;
        }
        
        this.initLoad = function (preloadlayer,cb,rp) {
            callback     = cb;
            returnparams = rp;
            lAC_pS       = preloadlayer;
            getAjaxContent();
        }
    },
    XMLDocument:function (file,callback) {    
        try {
            var xmlFile = new XMLHttpRequest();
        } catch (e) {
            try {
                var xmlFile = new ActiveXObject("Msxml2.XMLHttp");
            } catch (e) {
                try {
                    var xmlFile = new ActiveXObject('Microsoft.XMLHTTP');
                } catch (e) {
                    var xmlFile = null;
                }
            }
        }     
        
        if(xmlFile) {
            xmlFile.onreadystatechange = function () {
                if(xmlFile.readyState == 4) {
                    callback.call(null,xmlFile);
                }
            }
            xmlFile.open('GET',file,true);
            xmlFile.send(null);
        } else {
            alert('Ihr Browser kann leider keine XML Datein ˆffenen');
        }
    }
}