var sites = new Array('philosophie','technik','produkte','kontakt','referenz','wuerfel','kugelGross','kugelKlein','kugelMini','kugelKokos', 'links');
var isLoading = false;
var contentDiv;
var startseite = 'produkte';

window.onload = function() {
contentDiv = AJS.$('content_div'); 
load(startseite);
}

function load(type) {
	if (isLoading) {
		return;
	}
	isLoading = true;
	if (in_array(type,sites)) {
		var req = AJS.getRequest('inhalt/'+type+'.php');
		req.addCallback(function(res, req) { 
           contentDiv.innerHTML = res;
			isLoading = false;
            
        });		
        
        req.addErrback(function(res,req) {
			contentDiv.innerHTML = res;
			isLoading = false;
			//Fehler
		});
        
		req.sendReq();
	}
	else {
		isLoading = false;
        //Seite nicht in Array
	}
}

function in_array(needle, haystack) {
    for (key in haystack) {
        if (haystack[key] == needle) {
           return true;
        }
    }
    return false;
}
