var actTree = new SeqActivityTree("","","",""); actTree.setRoot(adlTree); actTree.setDepths(); actTree.setTreeCount();  
function init(config) {	function camWalk(cam, act) 	{		function move(act, prop, newprop, id) 		{			var k;			var cls = this[prop.charAt().toUpperCase()+prop.substr(1)] || Object;			if (!act[prop]) {return;}			while ((k = act[prop].pop()))			{				var subact = new cls();				act[newprop][k[id] ? k[id] : '$'] = subact;				for (var kk in k) 				{					//subact[kk] = k[kk];					setItemValue(kk, subact, k);				}			}			delete act[prop];		}				var k, i, ni, seq, v;		seq = cam.sequencingId in seqs ? seqs[cam.sequencingId] : {};		for (k in seq) 		{			setItemValue(k, act, seq);		}		for (k in cam) 		{			setItemValue(k, act, cam);		}		act.index = activitiesByNo.length;		activitiesByNo.push(act);		act.cp_node_id = act.foreignId;		activitiesByCAM[act.foreignId] = act;		activities[act.id] = act;		if (cam.item) 		{			act.item = new Array();			var availableChildren = [];			for (i=0, ni=cam.item.length; i<ni; i+=1) 			{				var subact = new Activity();				subact.parent = act; 				camWalk(cam.item[i], subact);				availableChildren.push(subact);				act.item.push(subact);			}			act.availableChildren = availableChildren;		}		move(act, "objective", "objectives", "objectiveID");		move(act, "hideLMSUI", "hideLMSUIs", "value");		move(act, "rule", "rules", "foreignId");		act.primaryObjective = act;		for (k in act.objectives) 		{			move(act.objectives[k], "mapinfo", "mapinfos", "targetObjectiveID");			for (var l in act.objectives[k].mapinfos) 			{				var dat = sharedObjectives[l];				if (!dat) 				{					dat = new Objective();					dat.id = l;					dat.cmi_node_id = globalAct.cmi_node_id;					sharedObjectives[l] = dat;				}			}			// if we find a primaryObjective overwrite reference to activity as data container			if (act.objectives[k].primary) 			{				act.primaryObjective = act.objectives[k];			}		}	}	this.config = config;		setInfo('loading');	setState('loading');		setLocalStrings( // define these strings in host localization table	{		'resource_undelivered' : 'Resource unloaded. Use navigation to load a new one.'	});	setLocalStrings(this.config.langstrings);	setTimeout(onWindowLoad, 0);			// Step 1: load manifest data		var cam = this.config.cp_data || sendJSONRequest(this.config.cp_url);	if (!cam) return alert('Fatal: Could not load content data.')	// Step 2: load adlActivityTree	var adlAct = this.config.adlact_data || sendJSONRequest(this.config.adlact_url);	if (!adlAct) {		return alert('Fatal: Could not load ADLActivityTree.');	} else {			var tree;				adlTree = buildADLtree(adlAct,tree);		//set parents	    adlTree= setParents(adlTree);		//assign Tree				var actTree = new SeqActivityTree("","","","");		actTree.setRoot(adlTree);		actTree.setDepths();        actTree.setTreeCount();		//set parents		msequencer.setActivityTree(actTree);		}				// convert seq array into seq map and decode seq data en passant	var seqs = cam.sequencing ? cam.sequencing  : [];	for (var i=seqs.length; i--;)	{		seq = seqs.pop();		// TODO This is error-prone, since seq.id maybe an already used index		seqs[seq.id] = seq;		delete seq.foreignId;	}	// resolve one step inheritance in sequencing	for (var k in seqs) 	{		seq = seqs[k];		if (seq.sequencingId) 		{			var baseseq = seqs[seq.sequencingId];			for (k in baseseq) 			{				if (seq[k]===undefined) 				{					seq[k] = baseseq[k];				}			}			delete seq.id;			delete seq.sequencingId;		}	}	// copy data from manifest into globalAct	for (k in cam) 	{		if (typeof cam[k] !== "object") 		{			globalAct[k] = cam[k];		}	}		// identifiy cp_node for saving global activity into cmi_node	// and add global activity to list of activities	globalAct.cp_node_id = globalAct.foreignId;	globalAct.index = activitiesByNo.length;	activitiesByNo.push(globalAct);	activitiesByCAM[globalAct.foreignId] = globalAct;	activities[globalAct.id] = globalAct;		//set data from LMS	globalAct.learner_id=this.config.learner_id;	globalAct.learner_name=this.config.learner_name;		// walk throught activities and add some helpful properties	camWalk(cam.item, rootAct);			// Step 2: load tracking data	load();		}
6251	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/6251/41a8a11bad36a732e8970056ab880d5ace98ed52/main.js/clean/Modules/Scorm2004/scripts/main.js