var facility_to_moodle_course=function(){
var me={
constructor:function(){
YAHOO.util.Event.addListener(window, 'load', function(){me.applyClickEvents()});
},

dgAddGroups:function(){
var buttons=[
{name:'OK', functCode:function(){me.ajajTransferGroups();}},
{name:'Cancel', functCode:function(){me.dg.CloseDialog();}}];

var promptHTML="<div id='tgtree'></div>";
me.dg=new Dialog("Select Teaching Group(s)",promptHTML, {buttons:buttons,w:400,h:300});
me.dg.zIndex=1200;
me.dg.lightBox=true;
//me.dg.effects=false;
me.dg.Init();

me.nTree=new AJAJTree('tgtree', facility_to_moodle_treeurl); // tree url is a global var
me.nTree.debug=true;
me.nTree.rootTitle="Teaching Group Tree";
me.nTree.docsSelectable=true;
me.nTree.multiSelect=true;
me.nTree.foldersSelectable=false;
me.nTree.init();
},
dgRemoveGroups:function(){
var buttons=[
{name:'OK', functCode:function(){me.ajajRemoveGroupsReq();}},
{name:'Cancel', functCode:function(){me.dg.CloseDialog();}}];
var promptHTML="";
me.dg=new Dialog("Select Teaching Group(s) To Remove",promptHTML, {buttons:buttons,w:400,h:300});
me.dg.zIndex=1200;
me.dg.lightBox=true;
//me.dg.effects=false;
me.dg.Init();
me.dg.StatusLoading('Please wait, loading teaching groups...');
var reqURL=facility_to_moodle_ajax+"linkedGroupsAJAJ.p hp";
var sendStr="courseId="+courseId;

AJAXPost(reqURL, sendStr, {success:function(o){me.ajajLinkedGroupsRec(o)}, failure:function(){alert('failed '+reqURL)}});

},

applyClickEvents:function(){
YAHOO.util.Event.onDOMReady(function() {
document.getElementById("FacilityToMoodleLink").on click = function (){me.dgAddGroups();return false;};
});
YAHOO.util.Event.onDOMReady(function() {
document.getElementById("FacilityToMoodleUnlink"). onclick = function (){me.dgRemoveGroups();return false;};
});
},

ajajTransferGroups:function(){
if (isUndefinedOrNull(me.nTree.selectedNodes[0])){
Uncaught ReferenceError: isUndefinedOrNull is not defined (repeated 5 times)
if (me.promptDG){
me.promptDG.RemoveDialogDiv();
}
me.promptDG=new Dialog("No groups selected.","No groups selected.", {y:me.dg.y+((me.dg.h/2)-50),w:200,h:100});
me.promptDG.Init();
return;
}
me.ajajTransferGroupsReq();
},

ajajTransferGroupsReq:function(){
me.nTree.domObj.style.display='none';
me.dg.StatusLoading('Please wait, transferring teaching groups...');
me.dg.RemoveButtons();

// collapse node str
var nodeStr="";
for (var n=0; n<me.nTree.selectedNodes.length; n++){
nodeStr+=nodeStr=="" ? "" : ";";
nodeStr+=me.nTree.selectedNodes[n];
}
var sendStr="courseId="+courseId+"&tgIds="+nodeStr;
var reqURL=facility_to_moodle_ajax+"transferGroupsAJAJ .php";

AJAXPost(reqURL, sendStr, {success:function(o){me.ajajTransferGroupsRec(o)}, failure:function(){alert('failed '+reqURL)}});

},

ajajTransferGroupsRec:function(o){
eval(o.responseText);

me.dg.CloseDialog();

// Create log text for general output and non-critical errors
if (response.logOutput[0]){
var outputLog="<h4>Output Log</h4><p>";
for (var e=0; e<response.logOutput.length; e++){
outputLog+=response.logOutput[e]+"<br />";
}
outputLog+="</p>";
} else {
var outputLog="";
}

if (response.errorOutput[0]){
var errorLog="<h4>Error Log</h4><p>";
for (var e=0; e<response.errorOutput.length; e++){
errorLog+=response.errorOutput[e]+"<br />";
}
errorLog+="</p>";
} else {
var errorLog="";
}

if (response.success){
var title="Transfer Complete";
var dgHTML="<h3>Transfer Successfully Completed</h3>";
} else {
var title="Critical Transfer Error!";
var dgHTML="<h3>Transfer Errors Occurred</h3>";
if (response.criticalError){
dgHTML+="<p>Critical transfer error:"+response.criticalError+"</p>";
}
}
dgHTML+="<p><a href=\"#\" onclick=\"$GT('transferLog').style.display='block' ;\">Click here to see log.</a></p><div id='transferLog' style='display:none; position:relative; width:90%; border1x solid red;'>";
dgHTML+=(outputLog+errorLog);
dgHTML+="</div>";
var buttons=[
{name:'OK', functCode:function(){me.dg.CloseDialog();}}];
me.dg=new Dialog(title,dgHTML,{buttons:buttons,w:400,h:300}) ;
me.dg.Init();
},

ajajLinkedGroupsRec:function(o){

//var dg=new Dialog(null,null,400,300,"",o.responseText, {});
//dg.Init();

eval(o.responseText);
var tgs=response.links;
if (typeof(tgs[0])=='undefined'){
me.dg.CloseDialog();
var buttons=[
{name:'OK', functCode:function(){me.promptDG.CloseDialog();}}];
me.promptDG=new Dialog("No teaching groups to remove","No teaching groups to remove",{buttons:buttons,w:300,h:100});
me.promptDG.Init();
return;
}

me.dg.StatusLoadingRemove();
var promptHTML="<h3>Please select the teaching group(s) you wish to remove</h3>";
var dgPrompt=$GT(me.dg.id+"_prompt");
dgPrompt.innerHTML=promptHTML;

var selectBox=createEl('select', {id:'tgSelectRemove', name:'tgSelect', multiple:'multiple', style:'height:85px; width:150px'});
for (t=0; t<tgs.length; t++){
var tg=tgs[t];
var selected=t==0;
var opt=document.createElement('option');
opt.selected=selected;
opt.value=tg.moodleGroupId;
opt.innerHTML=tg.facGroupCode;
selectBox.appendChild(opt);
}
dgPrompt.appendChild(selectBox);
// I hate IE - fix ie6 select box bug
if (GTLib.Browser.ie6){
dgPrompt.innerHTML+='';
}
},

ajajRemoveGroupsReq:function(){
me.dg.RemoveButtons();
me.dg.StatusLoading('Please wait, removing teaching groups...');
var groups=$GTF('tgSelectRemove');
var sendStr="courseId="+courseId+"&grpIds="+groups;
var reqURL=facility_to_moodle_ajax+"removeGroupsAJAJ.p hp";

AJAXPost(reqURL, sendStr, {success:function(o){me.ajajRemoveGroupsRec(o)}, failure:function(){alert('failed '+reqURL)}});

},

ajajRemoveGroupsRec:function(o){
me.dg.CloseDialog();
var buttons=[
{name:'OK', functCode:function(){me.promptDG.CloseDialog();}}];
me.promptDG=new Dialog("Teaching Groups Removed","Teaching Groups Successfully Removed",{buttons:buttons,w:300,h:100});
me.promptDG.Init();
}


};
me.constructor();
return (me);
}


var facilityToMoodle=new facility_to_moodle_course();

Above is the code for my facility_to_moodle_course_init file
i keep getting back a reference error - can anyone help?