/* [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','47701',jdecode('About+Us'),jdecode(''),'/47701.html','true',[],''],
	['PAGE','51101',jdecode('Promotions'),jdecode(''),'/51101.html','true',[],''],
	['PAGE','14301',jdecode('Direct+Mail'),jdecode(''),'/14301.html','true',[],''],
	['PAGE','67501',jdecode('Business+Consulting'),jdecode(''),'/67501.html','true',[],''],
	['PAGE','19201',jdecode('Conditional+Rebates'),jdecode(''),'/19201.html','true',[],''],
	['PAGE','20001',jdecode('Weather+Promos'),jdecode(''),'/20001.html','true',[],''],
	['PAGE','53101',jdecode('Success+Stories'),jdecode(''),'/53101.html','true',[],''],
	['PAGE','18201',jdecode('Contact+Us'),jdecode(''),'/18201.html','true',[],'']];
var siteelementCount=8;
theSitetree.topTemplateName='Porthole';
theSitetree.paletteFamily='064B91';
theSitetree.keyvisualId='6713';
theSitetree.keyvisualName='kv_6713.jpg';
theSitetree.fontsetId='11200';
theSitetree.graphicsetId='12013';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='E9F3FF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Porthole',
				paletteFamily: 	'064B91',
				keyvisualId: 	'6713',
				keyvisualName: 	'kv_6713.jpg',
				fontsetId: 		'11200',
				graphicsetId: 	'12013',
				contentColor: 	'000000',
				contentBGColor: 'E9F3FF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'000000',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '51101',
internalId:  '',
customField: '20100313-174723'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '47701',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '14301',
internalId:  '',
customField: '20090519-164417'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18201',
internalId:  '',
customField: '20100318-223339'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '53101',
internalId:  '',
customField: '20090519-165114'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '19201',
internalId:  '',
customField: '20090509-171403'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20001',
internalId:  '',
customField: '20090519-163510'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '67501',
internalId:  '',
customField: '20100626-141759'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '47701',
internalId:  '',
customField: '20100425-140917'
};
var canonHostname = 'cmworker03.yourhostingaccount.com';
var accountId     = 'AENDU0IN30X5';
var companyName   = 'PROMOTIONS+THAT+WORK';
var htmlTitle	  = 'Retail+Promotions+That+Work';
var metaKeywords  = 'Promotions+That+Work+for+Retailers%2C+Promotions%2C+Promotions+That+Work%2C+Marketing+Promotions+That+Work%2C+retail+sales+promotions%2C+sales+promotion%2C+sales+promotions%2C+promotions+that+work%3Dptwusa.com%2C+Promotions+that+work%3Dpromotionsthatwork.org%2C+business+promotions%2C+advertising%2C+promotional+advertising%2C+promotion+games%2C+promotion+prizes%2C+prize%2C+promotion%2C+advertising+promotion%2C+retail+business+promotion%2C+promotions+and+customers%2C+customers+more%2C+more+customers%2C+promotional+material%2C+promotions+that+work+in+a+down+economy%2C+bad+economic+promotion%2C+promotions+in+poor+economics%2C+economical+promotion%2C+promotional+idea%2C+promotion+ideas%2C+Marketing+Promotions+That+Work%2C+promotional%2C+promotional+products%2C+marketing%2C+promotional+giveaways%2C+business%2C+ad%2C+advertising%2C+advertising+that+works';
var metaContents  = 'On+our+website+you+will+find+information+about+Unique%2C+Retail+Sales+Promotions%2C+That+Work.+Our+affordable+promotions+are+designed+to+drive+large+numbers+of+customers+into+your+retail+store.';
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();
};
