function BrowserManager(name,defaultBrowser) {
	this.name = name;
	this.delimeter = '_';
	this.childBrowsers = new Array();
	this.defaultBrowser = defaultBrowser;
	this.pathToFrameWork = "/sitewide/apps/flipbook/swf/";
	this.swfName = "flash_browser.swf";
}

BrowserManager.prototype.routeMessage = function(type,args,target,pathSegment) {
	Debug.trace(this.name + ' BrowserManager.routeMessage(' + type + ',' + args + ','+target+','+pathSegment+');');
	try {
		if(pathSegment){
			// it's an iframe we're looking for, with a BrowserManager in it.
			// we found a path segment, so there is a childBrowser w/ the name pathSegment
			// lets continue to route to the target through it.
			var targetNew = pathSegment.slice(pathSegment.lastIndexOf('.')+1,pathSegment.length) + target.split(pathSegment).join("");
			this.childBrowsers[pathSegment].routeMessage(type,args,target);
			return;
		}
		if(type=="command"){
			var func = args.slice(0,args.indexOf(":"))
			var args = args.slice(args.indexOf(":")+1)
			if(this.childBrowsers[target]){
				// we have what we are looking for
				this.childBrowsers[target].command(target,func,args);
			}else{
				// we don't have what we're looking for and we don't have a path segment.
				// so let's see if this framework can find one.
				// if it does, it will kick it back out
				this.findFirstChild(target).command(target,func,args);
			}
		}
		if(type=="setBrowserProperty"){
			// here we don't have a pathSegment, so we'll dig into the first flash thing we find (since we are setting a browser property)
			// if it's in here, we'll set it
			// otherwise maybe we'll find a pathSegment
			var temp = args.split('=');
			this.findFirstChild(target).setBrowserProperty(target,temp[0],temp[1]);
		}
		if(type=="navigate"){
			var targetSwfBrowser = this.childBrowsers[this.defaultBrowser];
			if(target){

				// the full target will be sent to the SwfBrowser to handle
				args = BrowserManager_buildUrl(args,target);

				// call navigate on the first browser - slice the target down to the first browser.
				targetSwfBrowser = this.findFirstChild(target)//(target.indexOf(this.delimeter)>0) ? target.slice(0,target.indexOf(this.delimeter)) : target;
			}

			Debug.trace(targetSwfBrowser.name + 'BrowserManager.navigate('+args+','+target+')');
			targetSwfBrowser.navigate(args);
		}
	}catch(e){
		Debug.trace(type +  ' ' + target + ' Error: ' + e)
	}
}

BrowserManager.prototype.omniture = function(args) {
	Debug.trace('omniture = ' + args)
	try {

		var o = BrowserManager_buildOmnitureCall(args)
		if(Debug.active){

			str = "";
			for(var i in o) {
				str+= '\t' + i + ' = ' + o[i] + '\n';
				for(oi in o[i])
					str+= '\t\t' + oi + ' = ' + o[i][oi] + '\n';

			}

			//alert(str);

		}
		REPORTING.makeCall('fbml_pv',o);

	}catch(e) {
		Debug.trace("ominiture error: " + e + " ->\nomniture object :");
		for(var i in o) {
			Debug.trace('\t' + i + ' = ' + o[i]);
			for(oi in o[i])
				Debug.trace('\t\t' + oi + ' = ' + o[i][oi]);

		}
	}
}

BrowserManager.prototype.omniture_grid = function(args)
{
    var o = BrowserManager_buildOmnitureCall(args);
	if(window.location.search.indexOf("debug=grid")>=0){
		var gridvars = "";
	    for (var prop in o.tVars){
				gridvars += prop + ":" + o.tVars[prop] + "\n";
		}
		//alert(gridvars);
	}
    REPORTING.makeCall("fbml_grid", o.tVars);
}

BrowserManager.prototype.updateTitle = function(title) {
	window.document.title =  title;
}

BrowserManager.prototype.updateUrl = function(url) {

	var currentUrl = window.location.href;

	var hash = currentUrl.indexOf('#');

	if (hash >= 0){
		currentUrl = currentUrl.substring(0, hash) + '#' + url;
	}else{
		currentUrl = currentUrl + '#' + url;
	}

	if(currentUrl != window.location.href)
		window.location.href = currentUrl;

	try {
		if(url){
			this.childBrowsers["root.browser.historyTracker"].iframeBrowser.src = "/sitewide/apps/historyTracker/navigator.jhtml?page=" + url
		}
	}catch(e){
	}
}


BrowserManager.prototype.createWindow = function(parentWindow,type,name,position,left,top,width,height,src) {
	try{
		this.childBrowsers[name] = eval(' new ' + type + '()');
		//this.childBrowsers[name].createWindow(parentWindow,name,position,left,top,width,height,src,args,visible);
		var temp = BrowserManager_removeItemAt(arguments,1);
		this.childBrowsers[name].createWindow.apply(this.childBrowsers[name],temp);

	}catch(e){
		//window.status = 'Error creating ' + name + ' : ' + e;
	}
}

BrowserManager.prototype.updateWindow = function(name,position,left,top,width,height,src) {
	try{
		var temp = BrowserManager_removeItemAt(arguments,0);
		this.childBrowsers[name].updateWindow.apply(this.childBrowsers[name],temp);
		//this.childBrowsers[name].updateWindow(position,left,top,width,height,src,args,visible);
	}catch(e){
		//window.status = 'Error updating ' + name + ' : ' + e;
	}
}

BrowserManager.prototype.destroyWindow = function(name) {
	try{
		this.childBrowsers[name].destroyWindow();
	}catch(e){
		//window.status = 'Error destroying ' + name + ' : ' + e;
	}
}

BrowserManager.prototype.findFirstChild = function(name) {
	var path = '';
	var browsers = name.split(this.delimeter);
	for (var i in browsers){
		path += (i>0 ? this.delimeter : '') + browsers[i];
		try{
			if(this.childBrowsers[path]){
				return this.childBrowsers[path];
			}
		}catch(e){ // no error handling here, just move to the next browser.
		}
	}
}

BrowserManager.prototype.onPageLoad = function() {
	for (i in this.childBrowsers){
		this.childBrowsers[i].onPageLoad();
	}
}


