/* [nodename, id, name, navigationtext, href, isnavigation, childs[], templatename] */

if (typeof(decodeURIComponent) == 'undefined') {
  decodeURIComponent = function(s) {
    return unescape(s);
  }
}

function jdecode(s) {
    s = s.replace(/\+/g, "%20")
    return decodeURIComponent(s);
}

var POS_NODENAME=0;
var POS_ID=1;
var POS_NAME=2;
var POS_NAVIGATIONTEXT=3;
var POS_HREF=4;
var POS_ISNAVIGATION=5;
var POS_CHILDS=6;
var POS_TEMPLATENAME=7;
var POS_TARGET=8;
var theSitetree=[ 
	['PAGE','3101',jdecode('Welcome'),jdecode(''), jdecode('%2F3101.html'), 'true',[],'',''],
	['PAGE','78501',jdecode('Featured+Listings'),jdecode(''), jdecode('%2F78501.html'), 'true',[],'',''],
	['PAGE','3152',jdecode('Property+Search'),jdecode(''), jdecode('%2F3152.html'), 'true',[],'',''],
	['PAGE','98912',jdecode('REO%2FShort+Sale+Search'),jdecode(''), jdecode('%2F98912.html'), 'true',[],'',''],
	['PAGE','81001',jdecode('Submit+Offer'),jdecode(''), jdecode('%2F81001.html'), 'true',[],'',''],
	['PAGE','3173',jdecode('Contact+us'),jdecode(''), jdecode('%2F3173.html'), 'true',[],'','']];
var siteelementCount=6;
theSitetree.topTemplateName='Office';
theSitetree.paletteFamily='727D9C';
theSitetree.keyvisualId='11163';
theSitetree.keyvisualName='kv_11163.jpg';
theSitetree.fontsetId='32064';
theSitetree.graphicsetId='13879';
theSitetree.contentColor='4e5978';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'wl_enom',
  product: 'WSCENOSSSLYTC21G'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Office',
				paletteFamily: 	'727D9C',
				keyvisualId: 	'11163',
				keyvisualName: 	'kv_11163.jpg',
				fontsetId: 		'32064',
				graphicsetId: 	'13879',
				contentColor: 	'4e5978',
				contentBGColor: 'FFFFFF',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['7008']=webappMappings['7008-4295']={
webappId:    '7008',
documentId:  '3173',
internalId:  '4295',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3101',
internalId:  '',
customField: '20120117-131751'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3152',
internalId:  '',
customField: '20111123-102120'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3173',
internalId:  '',
customField: '20120111-085142'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3101',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3152',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3173',
internalId:  '',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '78501',
internalId:  '',
customField: '20120210-094902'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '81001',
internalId:  '',
customField: '20110715-092613'
};
webappMappings['7008']=webappMappings['7008-4695']={
webappId:    '7008',
documentId:  '81001',
internalId:  '4695',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '98912',
internalId:  '',
customField: '20110913-093856'
};
var webAppHostname = 'wsc.ehost-services.com:80';
var canonHostname = 'wscwrk02.ehost-services.com';
var accountId     = 'AEN340INP0KK';
var companyName   = '';
var htmlTitle	  = 'Coldwell+Banker%C2%AE++Real+Estate+Listings';
var metaKeywords  = 'Southern%2C+California%2C+Real+Estate%2C+MLS%2C+Los+Angeles+County%2C+Orange+County%2C+Riverside%2C+San+Bernardino+County%2C+Long+Beach%2C+Seal+Beach%2C+Huntington+Beach%2C+Naples.+Island%2C+Belmont%2C+Shore%2C+Belmont%2C+Heights%2C+Bluff+Park%2C+Park+Estates%2C+Malibu%2C+Newport+Beach%2C+Laguna+Beach%2C+Beverly+Hills%2C+San+Diego%2C+Big+Bear+Lake%2C+Rossmoor%2C+Investments%2C+Income+units%2C+Investors%2C+Listings%2C+REO%2C+Bank+Owned%2C+Commercial%2C+Alhambra%2C+Altadena%2C+Arcadia%2CArtesia%2C+Avalon%2C+Azusa%2C+Baldwin+Park%2C+Bel+Air%2C+Bell%2C+Bell+Gardens%2C+Bellflower%2C+Beverly+Hills%2C+Bradbury%2C+Brea%2C+Brentwood%2C+Carson%2C+Century+City%2C+Cerritos%2C+City+of+Industry%2C+Claremont%2C+Commerce%2C+Compton%2C+Covina%2C+Cudahy%2C+Culver+City%2C+Cypress%2C+Diamond+Bar%2C+Downey%2C+Duarte%2C+East+Los+Angeles%2C+El+Monte%2C+El+Segundo%2C+Gardena%2C+Glendora%2C+Hacienda+Heights%2C+Harbor+City%2C+Hawaiian+Gardens%2C+Hawthorne%2C+Hermosa+Beach%2C+Hollywood%2C+Hollywood+Hills%2C+Inglewood%2C+Irwindale%2C+La+Canada%2C+La+Canada+Flintridge%2C+La+Crescenta%2C+La+Mirada%2C+La+Puente%2C+La+Verne%2C+Lakewood%2C+Lawndale%2C+Lennox%2C+Lomita%2C+Long+Beach%2C+Los+Angeles%2C+Lynwood%2C+Malibu%2C+Manhattan+Beach%2C+Mar+Vista%2C+Marina+Del+Rey%2C+Maywood%2C+Monrovia%2C+Montebello%2C+Monterey+Park%2C+Montrose%2C+Norwalk%2C+Pacific+Palisades%2C+Palos+Verdes%2C+Palos+Verdes+Est.%2C+Palos+Verdes+Estates%2C+Palos+Verdes+Pen.%2C+Paramount%2C+Pasadena%2C+Pico+Rivera%2C+Playa+del+Rey%2C+Playa+Vista%2C+Pomona%2C+Rancho+Palos+Verdes%2C+Redondo+Beach%2C+Rolling+Hills+Estates%2C+Rosemead%2C+Rowland+Heights%2C+San+Dimas%2C+San+Gabriel%2C+San+Marino%2C+San+Pedro%2C+Santa+Fe+Springs%2C+Santa+Monica%2C+Sierra+Madre%2C+Signal+Hill%2C+South+El+Monte%2C+South+Gate%2C+South+Pasadena%2C+South+San+Gabriel%2C+Temple+City%2C+Torrance%2C+Venice%2C+Verdugo+City%2C+Walnut%2C+West+Covina%2C+West+Hollywood%2C+Westchester%2C+Whittier%2C+Wilmington%2C+Coronado';
var metaContents  = 'Coldwell+Banker%C2%AE+';
theSitetree.getById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		if (ar[i][POS_ID] == id){
			return ar[i];
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getParentById = function(id, ar) {
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		for (var j = 0; j < ar[i][POS_CHILDS].length; j++) {
			if (ar[i][POS_CHILDS][j][POS_ID] == id) {
				// child found
				return ar[i];
			}
			var result=this.getParentById(id, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getName = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAME];
	}
	return null;
};

theSitetree.getNavigationText = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_NAVIGATIONTEXT];
	}
	return null;
};

theSitetree.getHREF = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_HREF];
	}
	return null;
};

theSitetree.getIsNavigation = function(id) {
	var elem = this.getById(id);
	if (elem != null){
		return elem[POS_ISNAVIGATION];
	}
	return null;
};

theSitetree.getTemplateName = function(id, lastTemplateName, ar) {
	if (typeof(lastTemplateName) == 'undefined'){
		lastTemplateName = this.topTemplateName;
	}
	if (typeof(ar) == 'undefined'){
		ar = this;
	}
	for (var i=0; i < ar.length; i++) {
		var actTemplateName = ar[i][POS_TEMPLATENAME];
		if (actTemplateName == ''){
			actTemplateName = lastTemplateName;
		}
		if (ar[i][POS_ID] == id) {
			return actTemplateName;
		}
		if (ar[i][POS_CHILDS].length > 0) {
			var result=this.getTemplateName(id, actTemplateName, ar[i][POS_CHILDS]);
			if (result != null){
				return result;
			}
		}
	}
	return null;
};

theSitetree.getByXx = function(lookup, xx, ar) {
    if (typeof(ar) == 'undefined'){
    	ar = this;
    }
    for (var i=0; i < ar.length; i++) {
        if (ar[i][xx] == lookup){
        	return ar[i];
        }
        if (ar[i][POS_CHILDS].length > 0) {
        	var result=this.getByXx(lookup, xx, ar[i][POS_CHILDS]);
            if (result != null){
                return result;
               }
        }
    }
    return null;
};

function gotoPage(lookup) {
	if(__path_prefix__ == "/servlet/CMServeRES" && typeof (changePage) == 'function'){
		changePage(lookup);
		return;
	}
	var page = theSitetree.getHREF(lookup);
	if (!page) {
		var testFor = [ POS_NAME, POS_NAVIGATIONTEXT ];
		for (var i=0 ; i < testFor.length ; i++) {
			var p = theSitetree.getByXx(lookup, testFor[i]);
			if (p != null) {
				page = p[POS_HREF];
				break;
			}
		}
	}
	document.location.href = (new URL(__path_prefix__ + page, true, true)).toString();
};

