/* [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','4597',jdecode('Home'),jdecode(''),'/4597/index.html','true',[ 
		['PAGE','4681',jdecode('Location+Map'),jdecode(''),'/4597/4681.html','true',[],'',''],
		['PAGE','4654',jdecode('About+us'),jdecode(''),'/4597/4654.html','true',[],'',''],
		['PAGE','10602',jdecode('Our+suppliers'),jdecode(''),'/4597/10602.html','true',[],'',''],
		['PAGE','7902',jdecode('Contact+%28follow+up+page%29'),jdecode(''),'/4597/7902.html','false',[],'',''],
		['PAGE','35101',jdecode('Specials'),jdecode(''),'/4597/35101.html','true',[],'',''],
		['PAGE','27001',jdecode('Feedback'),jdecode(''),'/4597/27001.html','true',[],'','']
	],'',''],
	['PAGE','4708',jdecode('Greymouth'),jdecode(''),'/4708.html','true',[],'',''],
	['PAGE','4735',jdecode('Retread+Factory'),jdecode(''),'/4735.html','true',[],'',''],
	['PAGE','4762',jdecode('Westport'),jdecode(''),'/4762.html','true',[],'',''],
	['PAGE','4789',jdecode('Richmond'),jdecode(''),'/4789.html','true',[],'',''],
	['PAGE','4816',jdecode('Motueka'),jdecode(''),'/4816.html','true',[],'',''],
	['PAGE','4843',jdecode('Oamaru'),jdecode(''),'/4843.html','true',[],'','']];
var siteelementCount=13;
theSitetree.topTemplateName='Trend';
theSitetree.paletteFamily='A74747';
theSitetree.keyvisualId='7928';
theSitetree.keyvisualName='kv_7928.jpg';
theSitetree.fontsetId='16912';
theSitetree.graphicsetId='12325';
theSitetree.contentColor='742626';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				hasFlashNavigation: 'true',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Trend',
				paletteFamily: 	'A74747',
				keyvisualId: 	'7928',
				keyvisualName: 	'kv_7928.jpg',
				fontsetId: 		'16912',
				graphicsetId: 	'12325',
				contentColor: 	'742626',
				contentBGColor: 'FFFFFF',
				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:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4708',
internalId:  '',
customField: '20100422-235434'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4597',
internalId:  '',
customField: '20091119-225242'
};
webappMappings['7008']=webappMappings['7008-10259']={
webappId:    '7008',
documentId:  '35101',
internalId:  '10259',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-10258']={
webappId:    '7008',
documentId:  '27001',
internalId:  '10258',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4654',
internalId:  '',
customField: '20090812-214259'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '10602',
internalId:  '',
customField: '20091124-173515'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4735',
internalId:  '',
customField: '20090812-214833'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4762',
internalId:  '',
customField: '20091119-225856'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4789',
internalId:  '',
customField: '20100426-204446'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4816',
internalId:  '',
customField: '20100426-204334'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4843',
internalId:  '',
customField: '20100422-235608'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35101',
internalId:  '',
customField: '20070511-020028'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27001',
internalId:  '',
customField: '20061110-161326'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4681',
internalId:  '',
customField: '20060919-012046'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '4597',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7902',
internalId:  '',
customField: '20060826-042220'
};
var canonHostname = 'diywk00.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVEC10IN2GF4';
var companyName   = 'Tasman+Tyre+Treads';
var htmlTitle	  = 'Tasman+Tyres+Treads+Ltd';
var metaKeywords  = 'tyres%2Ctasman%2Ctransport%2Cfleet%2Cservice%2Cair%2Cpunture%2Ccar%2Cfirestone%2Cbridgstone%2Cwheel%2C+alignment%2Cloader%2Cearthmoving%2Cotr%2Cretread%2Crepairs%2Ctractor%2Ccurtain%2Csides%2Cinsurance%2Cassessements';
var metaContents  = 'Tasman+Tyre+Treads+for+supply+and+fitting+of+all+tyres%2C+from+Car%2C+Bus%2C+Trucks%2C+Trailers+Loaders%2C+Folk+lifts%2C+Graders...+even+Dumper+truck+tyres';
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();
};
