var corewindow=window;
function configGetKey(key) {
	var splitkey = typeof key == "string" ? key.split(".") : key;
	if (!window.config) {
		return null;
	}
	var tmp=ox.api.config.get();//(corewindow) ? corewindow.config : config;
	for ( var i = 0; i < splitkey.length; i++) {
		if (tmp[splitkey[i]] != undefined) {
			tmp = tmp[splitkey[i]];
		} else {
			return null;
		}
	}
	return clone(tmp);
}

function configSetKey(key,value) {
	if(!corewindow.config) {
		corewindow.config={};
	}
	var tmp=ox.api.config.get();//(corewindow) ? corewindow.config : config;
	var splitkey = typeof key == "string" ? key.split(".") : key;
	for ( var i = 0; i < splitkey.length - 1; i++) {
		if (tmp[splitkey[i]]) {
			tmp = tmp[splitkey[i]];
			if (typeof (tmp) != "object") {
				alert("" + tmp + " parentNode is a value");
				return;
			}
		} else {
			tmp[splitkey[i]] = {};
			tmp = tmp[splitkey[i]];
		}
	}
	tmp[splitkey[splitkey.length-1]]=clone(value);
	configuration_changed_outside=true;
	triggerEvent("OX_Configuration_Parameter_Changed",key,value);
}

function configContainsKey(key) {
	var splitkey = typeof key == "string" ? key.split(".") : key;
	if (!config) {
		return false;
	}
	var tmp=ox.api.config.get();//(corewindow) ? corewindow.config : config;
	for ( var i = 0; i < splitkey.length; i++) {
		if (tmp[splitkey[i]] != undefined) {
			tmp = tmp[splitkey[i]];
		} else {
			return false;
		}
	}
	return true;
}

function configRemoveKey(key) {
    // get full config (not a clone is this case)
    var tmp = ox.api.config.get();
    // key split key (key might already be an array)
    var splitkey = typeof key == "string" ? key.split(".") : key;
    // iterate over config to find the node
    for ( var i = 0; i < splitkey.length - 1; i++) {
        if (tmp[splitkey[i]]) {
            tmp = tmp[splitkey[i]];
            if (typeof (tmp) != "object") {
                alert("" + tmp + " parentNode is a value");
                return;
            }
        } else {
            tmp[splitkey[i]] = {};
            tmp = tmp[splitkey[i]];
        }
    }
    // now, we have the right node, so...
    delete tmp[splitkey[splitkey.length-1]];
    // done
    configuration_changed_outside = true;
    triggerEvent("OX_Configuration_Parameter_Changed", key, undefined);
}