/* [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 theSitetree=[ 
	['PAGE','2301',jdecode('Home%2FWelcome%21'),jdecode(''),'/2301.html','true',[],''],
	['PAGE','2901',jdecode('Grocery+Savings'),jdecode(''),'/2901.html','true',[],''],
	['PAGE','18701',jdecode('Grocery+Coupons'),jdecode(''),'/18701.html','true',[],''],
	['PAGE','6301',jdecode('%24mart+%24hoppers'),jdecode(''),'/6301.html','true',[],''],
	['PAGE','26201',jdecode('Shopping+Tips'),jdecode(''),'/26201/index.html','true',[ 
		['PAGE','26401',jdecode('Shop+Faster%21'),jdecode(''),'/26201/26401.html','true',[],'']
	],''],
	['PAGE','25601',jdecode('Free+Newsletter'),jdecode(''),'/25601.html','true',[],''],
	['PAGE','12501',jdecode('The+BOGO%21+Book'),jdecode(''),'/12501/index.html','true',[ 
		['PAGE','19201',jdecode('BOGO+Chapter+8'),jdecode(''),'/12501/19201.html','true',[],'']
	],''],
	['PAGE','11901',jdecode('Supermarket+Poetry'),jdecode(''),'/11901/index.html','true',[ 
		['PAGE','23101',jdecode('Past+Poetry+Winners'),jdecode(''),'/11901/23101.html','true',[],'']
	],''],
	['PAGE','3701',jdecode('About+Martin+Sloane'),jdecode(''),'/3701.html','true',[],''],
	['PAGE','14801',jdecode('Sloane+Appearances'),jdecode(''),'/14801.html','true',[],''],
	['PAGE','22201',jdecode('News+Releases'),jdecode(''),'/22201.html','true',[],''],
	['PAGE','16001',jdecode('Contact+Us'),jdecode(''),'/16001.html','true',[],''],
	['PAGE','27501',jdecode('Coupons+for+Military'),jdecode(''),'/27501.html','true',[],'']];
var siteelementCount=16;
theSitetree.topTemplateName='Notice';
theSitetree.paletteFamily='E1AA40';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='10488';
theSitetree.graphicsetId='11047';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='EADFCE';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Notice',
				paletteFamily: 	'E1AA40',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'10488',
				graphicsetId: 	'11047',
				contentColor: 	'000000',
				contentBGColor: 'EADFCE',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'F9F9F9',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'B61F1F',
				e_color: 		'B61F1F',
				f_color: 		'B61F1F',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2301',
internalId:  '',
customField: '20090617-224311'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19201',
internalId:  '',
customField: '20090529-004119'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2901',
internalId:  '',
customField: '20090526-204245'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3701',
internalId:  '',
customField: '20090520-224840'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '6301',
internalId:  '',
customField: '20090521-220311'
};
webappMappings['7008']=webappMappings['7008-16823']={
webappId:    '7008',
documentId:  '11901',
internalId:  '16823',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '11901',
internalId:  '',
customField: '20090525-130943'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '12501',
internalId:  '',
customField: '20090529-004025'
};
webappMappings['7008']=webappMappings['7008-16858']={
webappId:    '7008',
documentId:  '14801',
internalId:  '16858',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14801',
internalId:  '',
customField: '20090520-151029'
};
webappMappings['7008']=webappMappings['7008-16871']={
webappId:    '7008',
documentId:  '6301',
internalId:  '16871',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-16872']={
webappId:    '7008',
documentId:  '16001',
internalId:  '16872',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '16001',
internalId:  '',
customField: '20090520-204818'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18701',
internalId:  '',
customField: '20090522-001248'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '22201',
internalId:  '',
customField: '20090531-220432'
};
webappMappings['7008']=webappMappings['7008-16986']={
webappId:    '7008',
documentId:  '22201',
internalId:  '16986',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '23101',
internalId:  '',
customField: '20090525-074820'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '25601',
internalId:  '',
customField: '20090529-004354'
};
webappMappings['7008']=webappMappings['7008-17379']={
webappId:    '7008',
documentId:  '26201',
internalId:  '17379',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26201',
internalId:  '',
customField: '20090605-140823'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '26401',
internalId:  '',
customField: '20090605-140548'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27501',
internalId:  '',
customField: '20090813-102859'
};
var canonHostname = 'cmworker02.yourhostingaccount.com';
var accountId     = 'AENDU0INEQSU';
var companyName   = 'MartinSloane.com';
var htmlTitle	  = 'Save+%24100+a+Month+Playing+The+Great+Grocery+Game%21+Martin+Sloane+supermarket+advice+columnist';
var metaKeywords  = 'Save+money%2C+supermarket%2C+grocery+store%2C+groceries%2C+coupons%2C+refunds%2C+sales%2C+free+groceries%2C+grocery+shopper%2C+supermarket+shopper%2C+coupon+clipper%2C+Buy+1+%E2%80%93+Get+1+Free%2C+BOGO%2C+Smart+shopper%2C+Budget+stretcher%2C+Frugal+shopper%2C+grocery+tips%2C+specially+market+packages%2C+mail-in+offers%2C+rebates%2C';
var metaContents  = 'Save+%24100+every+month+on+your+favorite+groceries%2C+Play+The+Great+Grocery+Game%2C+Double+and+Triple+Play+Savings+Free+Food+Home+Runs%2C+Martin+Sloane%E2%80%99s+Site+For+Savvy+Shoppers%2C+Grocery+savings+tips%2C+Your+own+grocery+Gold+Mine%2C+';
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();
};
