dojo.provide("tests.Util");

dojo.require("dijit.dijit");

tests.Util.moveConsole = function(){
	setTimeout(function(){
		var fb = dojo.query(".firebug");
		if (fb.length == 0) return;
		fb = fb[0];
		dojo.style(fb, "position", "absolute");
		dojo.style(fb, "top", "500px");
		dojo.style(fb, "left", "10px");
		dojo.style(fb, "width", "1000px");
		dojo.style(fb, "height", "100px");
		dojo.style(fb, "zIndex", "0");
		dojo.style(dojo.byId("firebugLog"), "height", "84px");
	},500);
};
tests.Util.resetDom = function(){
	//dijit.registry.forEach(function(w){w.destroy();});
	dijit.registry = new dijit.WidgetSet();//bad hack
	var ally = dojo.byId("a11yTestNode");
	if (ally)
		document.body.removeChild(ally);
	var fb = dojo.query(".firebug");
	
	if (fb.length == 1) {
		fb = fb[0];
		dojo.style(fb, "position", "absolute");
		dojo.style(fb, "top", "10px");
		dojo.style(fb, "left", "10px");
		dojo.style(fb, "width", "800px");
		dojo.style(fb, "height", "560px");
		dojo.style(dojo.byId("firebugLog"), "height", "540px");
		dojo.style(fb, "zIndex", "3000");
		var lastNodeToRemove = 2;
		if (dojo.isIE)
			lastNodeToRemove = 1;
		var nodes = document.body.childNodes;
		if (nodes.length > 1) {
			for (var i = nodes.length - 1; i >= lastNodeToRemove; i--) {
				document.body.removeChild(nodes[i]);
			}
		}
	} else {
		while (document.body.lastChild)
			document.body.removeChild(document.body.lastChild);
	}
};
tests.Util.getAbsolutePath = function(relPath){
	absPath = new String(document.location);
	absPath = absPath.substr(0, absPath.lastIndexOf("/js/"));
	var i = relPath.lastIndexOf("../");
	i < 0 ? i = 0 : i = i + 2;
	absPath = absPath + "/js" + relPath.substr(i).replace(/\/\//,/\//);
	return absPath;
};
