/* $Id: bbb.js 1815 2008-07-09 15:05:41Z abs $
 * This function returns the 3B version installed, undefined if it is unable
 * to detect the version, or 0 if it can detect that 3B is not installed.
 *
 * Four distinct states
 * 1) Recent version (>=2.1) installed, in IE or Webview. All .bbb options work
 * 2) Old version (<2.1) of 3B installed, in Webview. Some .bbb options work
 * 3) In IE and old version or no version of 3B installed
 * 4) In another browser, no idea if 3B installed
 */
function ver3B()
{
var i; var v; var a = navigator.userAgent.toString();

v = ver3BMimeBBBB();

// 3B 2.x to 3.2 have a 'real' .bbb plugin, which includes the version
if (navigator.mimeTypes && navigator.mimeTypes['application/x-bbb'] )
    {
    var desc = navigator.mimeTypes['application/x-bbb'].description;
    if (desc.match(/^3B \d/))
	v = desc.substring(3).match(/[\d.]+/);
    }

if (!v)
    {
    if (a.indexOf(' Gecko/') != -1 && (i = a.indexOf(' 3B-Webview/')) != -1 )
	v = a.substring(i + 12);
    else if (a.indexOf(' MSIE ') != -1)
	{
	if ((i = a.indexOf('; 3B/')) != -1 || (i = a.indexOf('; 3B ')) != -1)
	    {
	    v = a.substring(i + 5);		// Now strip ; or ) onwards
	    if ((i = v.indexOf(';')) != -1)
		v = v.substring(0, v.indexOf(';'));
	    else if ((i = v.indexOf(')')) != -1)
		v = v.substring(0, v.indexOf(')'));
	    }
	else if (a.indexOf(' Opera ') == -1)	// Check for Opera faking IE
	    v = 0;
	}
    }
if (a.match(/ 3B-3Bview\//))	// In case we are in cache3b
    return -v;
return v;
}

function ver3BMimeBBBB()
{
var v;
// For 3B 3.3 and later there is a 'fake' .bbbb mozilla plugin, purely to
// allow javascript to determine if 3B is installed, and which version
if (navigator.mimeTypes && navigator.mimeTypes['application/x-bbbb'] )
    {
    var desc = navigator.mimeTypes['application/x-bbbb'].description;
    if (desc.match(/^3B \d/))
	v = desc.substring(3).match(/[\d.]+/);
    }
return v;
}

function getBBB()
{
var args = location.search.substring(1).match(/.+/g);
if (args)
    {
    args = unescape(args);
    // Strip trailing ? introduced by Apache RewriteRule
    args = args.replace(/\?$/, '');
    /* Handle the case of an old room redirect where we are called as
     * http://www.3b.net/v/?villageuser/villagename.bbb
     */
    if (! args.match(/^https?:\/\//))
	{
	var domain;
	if (location.host.match(/\.i$/))	// Work out if we are internal
	    domain = '3b.i';
	else
	    domain = '3b.net';
	if (location.pathname == '/v/')		// Handle (old) room links
	    args = 'http://village.' + domain + '/' + args;
	else if (!args.match(/^\//))		// Relative (old) city links
	    args = 'http://' + domain + '/bbb/' + args;
	else					// Absolute (old) links
	    args = 'http://' + domain + args;
	}
    }
return args;
}

function setCookieLastBBB(url)
    {
    setCookie('last-bbb', url, 30 * 24 * 60 * 60);
    setCookieOld('lastbbb', url, 30 * 24 * 60 * 60);
    }

function setCookie(name, value, expSecs)
    {
    var expires = "";
    if (expSecs)
	{
	var date = new Date();
	date.setTime(date.getTime() + (expSecs * 1000));
	expires = "; expires=" + date.toGMTString();
	}
    document.cookie = name + "=" + encodeURIComponent(value) +
                                                    "; domain=.3b.net" +
						    expires + "; path=/";
    }

function setCookieOld(name, value, expSecs)
    {
    var expires = "";
    if (expSecs)
	{
	var date = new Date();
	date.setTime(date.getTime() + (expSecs * 1000));
	expires = "; expires=" + date.toGMTString();
	}
    document.cookie = name + "=" + value.replace(/;/g, '&') +
						expires + "; path=/";
    }


function getXMLHttpObj(){
	if(typeof(XMLHttpRequest)!='undefined')
		return new XMLHttpRequest();

	var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
	for(i=0;i<axO.length;i++)
		try{
			return new ActiveXObject(axO[i]);
		}catch(e){}
	return null;
}

function getCityFromBBB(bbburl)
{
var oXML = getXMLHttpObj();
oXML.open('GET', '/js/gen_citylist.json', false);
oXML.send('');
eval('var cityById = ' + oXML.responseText);

var oldLookup = new Object();
oldLookup['3b-amsterdam'] = '3B Amsterdam';
oldLookup['3b-animals'] = '3B animals';
oldLookup['3b-art'] = '3B art';
oldLookup['3b-backpacking-the-world'] = '3B backpacking the world';
oldLookup['3b-band-links'] = '3B band links';
oldLookup['3b-bands'] = '3B bands';
oldLookup['3b-blogs'] = '3B blogs';
oldLookup['3b-christmas'] = '3B Christmas';
oldLookup['3b-comics'] = '3B comics';
oldLookup['3b-electronics'] = '3B electronics';
oldLookup['3b-extreme-sports'] = '3B extreme sports';
oldLookup['3b-fashion'] = '3B fashion';
oldLookup['3b-fashion-weeks'] = '3B Fashion weeks';
oldLookup['3b-fathersday-cards'] = '3B Fathersday cards';
oldLookup['3b-fun-zone'] = '3B fun zone';
oldLookup['3b-funny-pics'] = '3B funny pics';
oldLookup['3b-golf-destinations'] = '3B golf destinations';
oldLookup['3b-hip-hop'] = '3B hip hop';
oldLookup['3b-home-garden'] = '3B home + garden';
oldLookup['3b-las-vegas'] = '3B Las Vegas';
oldLookup['3b-learning'] = '3B learning';
oldLookup['3b-london'] = '3B London';
oldLookup['3b-london-fashion-week'] = '3B London Fashion Week';
oldLookup['3b-mall'] = '3B Mall';
oldLookup['3b-miami'] = '3B Miami';
oldLookup['3b-miss-teen'] = '3B Miss Teen';
oldLookup['3b-mothersday-cards'] = '3B Mothersday cards';
oldLookup['3b-motor-racing'] = '3B motor racing';
oldLookup['3b-movies'] = '3B movies';
oldLookup['3b-music-creators'] = '3B music creators';
oldLookup['3b-music-downloads'] = '3B music downloads';
oldLookup['3b-new-york'] = '3B New York';
oldLookup['3b-photography'] = '3B photography';
oldLookup['3b-pimp-my-ride'] = '3B pimp my ride';
oldLookup['3b-pregnancy-parenting'] = '3B pregnancy + parenting';
oldLookup['3b-prom'] = '3B prom';
oldLookup['3b-spas-retreats'] = '3B spas + retreats';
oldLookup['3b-teen-alternative'] = '3B Teen alternative';
oldLookup['3b-tv-shows'] = '3B TV shows';
oldLookup['3b-urban-life'] = '3B urban life';
oldLookup['3b-vacation'] = '3B vacation';
oldLookup['3b-valentine'] = '3B valentine';
oldLookup['3b-valentines-cards'] = '3B valentines cards';
oldLookup['3b-video-games'] = '3B video games';
oldLookup['3b-weddings'] = '3B weddings';
oldLookup['3b-wellness'] = '3B wellness';
oldLookup['3b-woman'] = '3B Woman';
oldLookup['3b-world-cup-2006'] = '3B world cup 2006';
oldLookup['6pm'] = '6pm affiliate store';
oldLookup['airport'] = 'Airport';
oldLookup['alice-in-wonderland-room'] = 'Alice in wonderland room';
oldLookup['alloy'] = 'Alloy affiliate store';
oldLookup['allposter-tv'] = 'Allposter TV affiliate store';
oldLookup['allposters-art'] = 'AllPosters art affiliate store';
oldLookup['allposters-movie'] = 'AllPosters movie affiliate store';
oldLookup['allposters-sport'] = 'AllPosters sport affiliate store';
oldLookup['amazon-animation-dvds'] = 'Amazon animation DVDs affiliate store';
oldLookup['amazon-beauty'] = 'Amazon beauty affiliate store';
oldLookup['amazon-book'] = 'Amazon book affiliate store';
oldLookup['amazon-cd'] = 'Amazon CD affiliate store';
oldLookup['amazon-dvd'] = 'Amazon DVD affiliate store';
oldLookup['amazon-gourmet-foods'] = 'Amazon gourmet foods affiliate store';
oldLookup['amazon-rock-music'] = 'Amazon rock music affiliate store';
oldLookup['amazon-sports-outdoor'] = 'Amazon sports + outdoor affiliate store';
oldLookup['amazon-toys'] = 'Amazon toys affiliate store';
oldLookup['amazon-video-games'] = 'Amazon video games affiliate store';
oldLookup['american-football-room'] = 'American football room';
oldLookup['american-greetings'] = 'american greetings';
oldLookup['amsterdam-room'] = 'Amsterdam room';
oldLookup['art-gallery-room'] = 'Art gallery room';
oldLookup['auto-room'] = 'Auto room';
oldLookup['babygap'] = 'babyGap affiliate store';
oldLookup['babystyle'] = 'babystyle affiliate store';
oldLookup['back-to-basics-toys'] = 'Back to Basics Toys affiliate store';
oldLookup['bag-borrow-or-steal'] = 'Bag Borrow Or Steal affiliate store';
oldLookup['basketball-room'] = 'Basketball room';
oldLookup['bbc-kids'] = 'BBC kids';
oldLookup['beach-room'] = 'Beach room';
oldLookup['best-buy'] = 'Best Buy affiliate store';
oldLookup['bewild'] = 'beWild affiliate store';
oldLookup['bloomstoday'] = 'Bloomstoday affiliate store';
oldLookup['blue-nile'] = 'Blue Nile affiliate store';
oldLookup['bluefly'] = 'bluefly affiliate store';
oldLookup['bn-comedy-dvds'] = 'BN comedy DVDs affiliate store';
oldLookup['bombay'] = 'Bombay affiliate store';
oldLookup['bootbay'] = 'Bootbay affiliate store';
oldLookup['buckle'] = 'Buckle affiliate store';
oldLookup['business-room'] = 'Business room';
oldLookup['candy-depot'] = 'Candy Depot affiliate store';
oldLookup['catwalk-fashion-room'] = 'Catwalk fashion room';
oldLookup['ccs'] = 'CCS affiliate store';
oldLookup['christmas-fun-room'] = 'Christmas fun room';
oldLookup['christmas-traditional-room'] = 'Christmas traditional room';
oldLookup['circuit-city'] = 'Circuit City affiliate store';
oldLookup['classic-closeouts'] = 'Classic Closeouts affiliate store';
oldLookup['classic-fashion-room'] = 'Classic fashion room';
oldLookup['cooking.com'] = 'Cooking.com affiliate store';
oldLookup['daisy-maze'] = 'Daisy Maze affiliate store';
oldLookup['delias'] = 'dELiAs affiliate store';
oldLookup['delightful-deliveries'] = 'Delightful Deliveries affiliate store';
oldLookup['designer-linens-outlet'] = 'Designer Linens Outlet affiliate store';
oldLookup['designershoes'] = 'DesignerShoes affiliate store';
oldLookup['discovery-channel-store'] = 'Discovery Channel Store affiliate store';
oldLookup['dr-jays'] = 'Dr. Jay%27s affiliate store';
oldLookup['dvd-empire-video-games'] = 'DVD Empire video games affiliate store';
oldLookup['ebags'] = 'eBags affiliate store';
oldLookup['ebay-action-figures'] = 'eBay action figures affiliate store';
oldLookup['ebay-anime-collectibles'] = 'eBay anime collectibles affiliate store';
oldLookup['ebay-antique-ceramics'] = 'eBay antique ceramics affiliate store';
oldLookup['ebay-antique-furniture'] = 'eBay antique furniture affiliate store';
oldLookup['ebay-antique-rugs-carpets'] = 'eBay antique rugs + carpets affiliate store';
oldLookup['ebay-asian-auto-models'] = 'eBay Asian auto models affiliate store';
oldLookup['ebay-barbie'] = 'eBay Barbie affiliate store';
oldLookup['ebay-body-jewelry'] = 'eBay body jewelry affiliate store';
oldLookup['ebay-car-truck-parts'] = 'eBay car + truck parts affiliate store';
oldLookup['ebay-cartoon-collectibles'] = 'eBay cartoon collectibles affiliate store';
oldLookup['ebay-cellphones'] = 'eBay cellphones affiliate store';
oldLookup['ebay-country-music'] = 'eBay country music affiliate store';
oldLookup['ebay-designer-jewelry'] = 'eBay designer jewelry affiliate store';
oldLookup['ebay-digital-cameras'] = 'eBay digital cameras affiliate store';
oldLookup['ebay-drawings'] = 'eBay drawings affiliate store';
oldLookup['ebay-fitness-equipment'] = 'eBay fitness equipment affiliate store';
oldLookup['ebay-furniture'] = 'eBay furniture affiliate store';
oldLookup['ebay-gadgets'] = 'eBay gadgets affiliate store';
oldLookup['ebay-glassware'] = 'eBay glassware affiliate store';
oldLookup['ebay-golfing-goods'] = 'eBay golfing goods affiliate store';
oldLookup['ebay-handbags'] = 'eBay handbags affiliate store';
oldLookup['ebay-jewelry-watches'] = 'eBay jewelry watches affiliate store';
oldLookup['ebay-lcd-tvs'] = 'eBay LCD TVs affiliate store';
oldLookup['ebay-luggage'] = 'eBay luggage affiliate store';
oldLookup['ebay-motorcycles'] = 'eBay motorcycles affiliate store';
oldLookup['ebay-mp3-player'] = 'eBay MP3 player affiliate store';
oldLookup['ebay-musical-instruments'] = 'eBay musical instruments affiliate store';
oldLookup['ebay-new-cellphone-accessories'] = 'eBay new cellphone accessories affiliate store';
oldLookup['ebay-new-home-audio'] = 'eBay new home audio affiliate store';
oldLookup['ebay-new-non-fiction-books'] = 'eBay new non-fiction books affiliate store';
oldLookup['ebay-new-rock-cds'] = 'eBay new rock CDs affiliate store';
oldLookup['ebay-original-paintings'] = 'eBay original paintings affiliate store';
oldLookup['ebay-photographic-images'] = 'eBay photographic images affiliate store';
oldLookup['ebay-powersports'] = 'eBay powersports affiliate store';
oldLookup['ebay-radio-control'] = 'eBay radio control affiliate store';
oldLookup['ebay-scarves-wraps'] = 'eBay scarves + wraps affiliate store';
oldLookup['ebay-sci-fi-collectibles'] = 'eBay sci-fi collectibles affiliate store';
oldLookup['ebay-sculptures'] = 'eBay sculptures affiliate store';
oldLookup['ebay-sportscars'] = 'eBay sportscars affiliate store';
oldLookup['ebay-suvs'] = 'eBay SUVs affiliate store';
oldLookup['ebay-teddy-bears'] = 'eBay teddy bears affiliate store';
oldLookup['ebay-us-auto-models'] = 'eBay US auto models affiliate store';
oldLookup['ebay-wedding-apparel'] = 'eBay wedding apparel affiliate store';
oldLookup['ebay-womens-shoes'] = 'eBay womens shoes affiliate store';
oldLookup['ebay-womens-sunglasses'] = 'eBay womens sunglasses affiliate store';
oldLookup['ebay-womens-vintage-clothing'] = 'eBay womens vintage clothing affiliate store';
oldLookup['ecampus.com-apparel'] = 'eCampus.com apparel affiliate store';
oldLookup['elisabeth'] = 'Elisabeth affiliate store';
oldLookup['emo-room'] = 'Emo room';
oldLookup['entrepeneurial-room'] = 'Entrepeneurial room';
oldLookup['etoys'] = 'eToys affiliate store';
oldLookup['extreme-sports-room'] = 'Extreme sports room';
oldLookup['fashionista-room'] = 'Fashionista room';
oldLookup['finishline-womens'] = 'Finishline womens';
oldLookup['firststreet'] = 'firstSTREET affiliate store';
oldLookup['forzieri'] = 'Forzieri affiliate store';
oldLookup['fossil'] = 'Fossil affiliate store';
oldLookup['fredericks-of-hollywood'] = 'Fredericks of Hollywood affiliate store';
oldLookup['ftd.com'] = 'FTD.com affiliate store';
oldLookup['fun-to-collect'] = 'Fun to Collect affiliate store';
oldLookup['gapbody'] = 'GapBody affiliate store';
oldLookup['gapkids'] = 'GapKids affiliate store';
oldLookup['gapmaternity'] = 'GapMaternity affiliate store';
oldLookup['gapmen'] = 'GapMen affiliate store';
oldLookup['gapwomen'] = 'GapWomen affiliate store';
oldLookup['girly-room'] = 'Girly room';
oldLookup['goth-room'] = 'Goth room';
oldLookup['gotham-online-shoes'] = 'Gotham Online shoes affiliate store';
oldLookup['hallmark'] = 'Hallmark affiliate store';
oldLookup['hammacher-schlemmer'] = 'Hammacher Schlemmer affiliate store';
oldLookup['haunted-room'] = 'Haunted room';
oldLookup['henry-and-june'] = 'Henry and June affiliate store';
oldLookup['hiphop-room'] = 'Hiphop room';
oldLookup['home-visions'] = 'Home Visions affiliate store';
oldLookup['hot-topic-band'] = 'Hot Topic band affiliate store';
oldLookup['hot-topic-clothing'] = 'Hot Topic clothing affiliate store';
oldLookup['hsn-beauty-fitness'] = 'HSN beauty + fitness affiliate store';
oldLookup['hsn-food-wine'] = 'HSN food + wine affiliate store';
oldLookup['hsn-jewelry'] = 'HSN jewelry affiliate store';
oldLookup['indie-rock-room'] = 'Indie rock room';
oldLookup['islandsurf.com'] = 'IslandSurf.com affiliate store';
oldLookup['kids-room'] = 'Kids room';
oldLookup['kitbag-football'] = 'Kitbag football affiliate store';
oldLookup['lane-bryant'] = 'Lane Bryant affiliate store';
oldLookup['lillian-vernon'] = 'Lillian Vernon affiliate store';
oldLookup['limitedtoo'] = 'LimitedToo affiliate store';
oldLookup['linen-n-things'] = 'Linen %27n things affiliate store';
oldLookup['lounge-room'] = 'Lounge room';
oldLookup['macys-wedding-gift-registry'] = 'Macy%27s Wedding + Gift Registry';
oldLookup['magazines.com'] = 'Magazines.com affiliate store';
oldLookup['montgomery-ward-decor'] = 'Montgomery Ward decor affiliate store';
oldLookup['montgomery-ward-furniture'] = 'Montgomery Ward furniture affiliate store';
oldLookup['moosejaw'] = 'Moosejaw affiliate store';
oldLookup['music-room'] = 'Music room';
oldLookup['myspace-emo-bands'] = 'MySpace emo bands';
oldLookup['myspace-rock-bands'] = 'MySpace rock bands';
oldLookup['new-york-room'] = 'New York room';
oldLookup['old-navy'] = 'Old Navy affiliate store';
oldLookup['pacsun'] = 'Pacsun affiliate store';
oldLookup['party-room'] = 'Party room';
oldLookup['petsmart'] = 'PetSmart affiliate store';
oldLookup['pimp-my-ride-room'] = 'Pimp my ride room';
oldLookup['primewine'] = 'PrimeWine affiliate store';
oldLookup['prom-room'] = 'Prom room';
oldLookup['raffaello'] = 'Raffaello affiliate store';
oldLookup['redenvelope'] = 'RedEnvelope affiliate store';
oldLookup['retro-cafe-room'] = 'Retro cafe room';
oldLookup['rock-room'] = 'Rock room';
oldLookup['rugman'] = 'Rugman';
oldLookup['scholastic'] = 'Scholastic affiliate store';
oldLookup['scifi-room'] = 'Scifi room';
oldLookup['sharper-image'] = 'Sharper image affiliate store';
oldLookup['shecoolhecool'] = 'SheCoolHeCool affiliate store';
oldLookup['shoe-buy'] = 'Shoe buy affiliate store';
oldLookup['sky-lounge-room'] = 'Sky lounge room';
oldLookup['soccer-room'] = 'Soccer room';
oldLookup['softmoc'] = 'Softmoc affiliate store';
oldLookup['solestruck'] = 'Solestruck affiliate store';
oldLookup['spa-room'] = 'Spa room';
oldLookup['stickergiant.com'] = 'StickerGiant.com affiliate store';
oldLookup['street-room'] = 'Street room';
oldLookup['superhero-room'] = 'Superhero room';
oldLookup['t-shirtking.com'] = 'T-ShirtKing.com affiliate store';
oldLookup['techno-room'] = 'Techno room';
oldLookup['the-body-shop'] = 'The Body Shop affiliate store';
oldLookup['topshop-uk'] = 'Topshop (UK)';
oldLookup['torrid'] = 'Torrid affiliate store';
oldLookup['ulta-beauty'] = 'Ulta beauty affiliate store';
oldLookup['universal-gear'] = 'Universal Gear affiliate store';
oldLookup['urban-fashion-room'] = 'Urban fashion room';
oldLookup['walmart-apparel'] = 'Walmart apparel affiliate store';
oldLookup['walmart-fishing'] = 'Walmart fishing affiliate store';
oldLookup['walmart-gifts-flowers'] = 'Walmart gifts + flowers affiliate store';
oldLookup['walmart-outdoor-sports'] = 'Walmart outdoor sports affiliate store';
oldLookup['walmart-sports-fitness'] = 'Walmart sports + fitness affiliate store';
oldLookup['walmart-toys'] = 'Walmart toys affiliate store';
oldLookup['webundies'] = 'WebUndies affiliate store';
oldLookup['weddings-room'] = 'Weddings room';
oldLookup['whimsical-fashion-room'] = 'Whimsical fashion room';
oldLookup['wickedcoolstuff'] = 'Wickedcoolstuff affiliate store';
oldLookup['world-of-watches'] = 'World of Watches affiliate store';
oldLookup['worldsoccershop-equipment'] = 'worldsoccershop equipment affiliate store';
oldLookup['worldsoccershop-teams'] = 'worldsoccershop teams affiliate store';
oldLookup['yoox'] = 'Yoox affiliate store';
oldLookup['your-kids-direct'] = 'Your Kids Direct affiliate store';
oldLookup['zappos-kids'] = 'Zappos kids affiliate store';
oldLookup['zappos-men'] = 'Zappos men affiliate store';
oldLookup['zappos-women'] = 'Zappos women affiliate store';

var city = new Object();
city.cityid = 1000;
city.name = 'The Airport';
city.type = 'city';
city.download = '/go/download';

if (bbburl)
    {
    var res=String(bbburl).match(/^http.\/\/places\.3b\.[^\/]+\/([\d]+)\.bbb$/);
    if (res)
	{
	if(cityById[res[1]])
	    {
	    city = cityById[res[1]];
	    city.download = '/go/download';
	    }
	else
	    {
	    city.cityid = res[1];
	    city.type = 'city';
	    }
	}

    var res = String(bbburl).match(/^http.\/\/.[^\/]+\/bbb\/city\/(.*)\.bbb$/);
    if (res)
	{
	res[1] = unescape(res[1]);
	if (oldLookup[ res[1] ])
	    city.name = unescape(oldLookup[ res[1] ]);
	else
	    city.name = 'this';
	if (city.name.match(/ store/, ''))
	    city.type = 'store';
	else
	    city.type = 'city';
	city.cityid = 0;
	return city;
	}
    else if (String(bbburl).match(/^http.\/\/www\.firmspace\.3b\.net/))
	{
	city.name = 'your Firmspace';
	city.cityid = 0;
	city.type = 'meeting';
	city.download = 'http://www.firmspace.3b.net/download';
	}
    else if (String(bbburl).match(/^http.\/\/chat(server)?\.3b\./))
	{
	city.name = 'a 3B';
	city.cityid = 0;
	city.type = 'party';
	}
    else if (String(bbburl).match(/^http.\/\/cards\.3b\.net\/card\/goto\//))
	{
	city.name = 'card';
	city.cityid = 0;
	city.type = 'city';
	}
    else if (String(bbburl).match(/^http:\/\/[^/]*bbb\.3b/))
	{
	res = String(bbburl).match(/t=([^;&]+)/);
	if (res)
	    city.name = 'a ' + res[1];
	else
	    city.name = 'a';
	city.cityid = 0;
	city.type = 'room';
	}
    else if ((res = String(bbburl).match(/^http:\/\/rooms\.3b\.[^/]+\//)))
	{
	if ((res = String(bbburl).match(/([^/]+)\/\.bbb$/)))
	    city.name = res[1] + "'s home";
	else if ((res = String(bbburl).match(/([^/]+)\/q\d+\.bbb/)))
	    city.name = res[1] + "'s";
	else if ((res = String(bbburl).match(/([^/]+)\/([^/]+)\.bbb/)))
	    city.name = res[1] + "'s " + res[2];
	else
	    city.name = 'this';
	city.cityid = 0;
	city.type = 'room';
	}
    city.name = city.name + ' ' + city.type;
    }
return city;
}

function getNameFromBBB(bbburl)
{
    return getCityFromBBB(bbburl).name;
}
