/* [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','2301',jdecode('Home'),jdecode(''),'/2301.html','true',[],'',''],
	['PAGE','4401',jdecode('The+Apartment'),jdecode(''),'/4401.html','true',[],'',''],
	['PAGE','28801',jdecode('Photo+Gallery'),jdecode(''),'/28801.html','true',[],'',''],
	['PAGE','4801',jdecode('Local+Facilities'),jdecode(''),'/4801.html','true',[],'',''],
	['PAGE','35701',jdecode('Activities'),jdecode(''),'/35701.html','true',[],'',''],
	['PAGE','3501',jdecode('Levada+walks'),jdecode(''),'/3501.html','true',[],'',''],
	['PAGE','27901',jdecode('Availability+and+Prices'),jdecode(''),'/27901.html','true',[],'',''],
	['PAGE','36701',jdecode('Getting+to+Madeira'),jdecode(''),'/36701.html','true',[],'',''],
	['PAGE','70012',jdecode('Guest+Comments'),jdecode(''),'/70012.html','true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Ragtime';
theSitetree.paletteFamily='9BA8DA';
theSitetree.keyvisualId='3572';
theSitetree.keyvisualName='kv_3572.jpg';
theSitetree.fontsetId='10452';
theSitetree.graphicsetId='10850';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'GB'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Ragtime',
				paletteFamily: 	'9BA8DA',
				keyvisualId: 	'3572',
				keyvisualName: 	'kv_3572.jpg',
				fontsetId: 		'10452',
				graphicsetId: 	'10850',
				contentColor: 	'000000',
				contentBGColor: 'FFFFFF',
				a_color: 		'9BA8DA',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'8D8C8C',
				e_color: 		'7D87B0',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2301',
internalId:  '',
customField: '20100105-184923'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3501',
internalId:  '',
customField: '20090114-190732'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4401',
internalId:  '',
customField: '20090713-184514'
};
webappMappings['7008']=webappMappings['7008-1964']={
webappId:    '7008',
documentId:  '27901',
internalId:  '1964',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '70012',
internalId:  '',
customField: '20100105-202619'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '35701',
internalId:  '',
customField: '20090714-182132'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '4801',
internalId:  '',
customField: '20090714-181642'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '28801',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2301',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-6789657']={
webappId:    '1501',
documentId:  '2301',
internalId:  '6789657',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '36701',
internalId:  '',
customField: '20090215-110752'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '2301',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['7060']=webappMappings['7060-7368e099cb6d5a6005c8a3144e22e905']={
webappId:    '7060',
documentId:  '28801',
internalId:  '7368e099cb6d5a6005c8a3144e22e905',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '27901',
internalId:  '',
customField: '20110118-191458'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4401',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '28801',
internalId:  '',
customField: '20090114-190603'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '4801',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '35701',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '3501',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '27901',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['5001']=webappMappings['5001-']={
webappId:    '5001',
documentId:  '36701',
internalId:  '',
customField: 'language:en;country:GB;'
};
webappMappings['1002']=webappMappings['1002-70012anbt20ine9rw']={
webappId:    '1002',
documentId:  '70012',
internalId:  '70012anbt20ine9rw',
customField: 'icq=false'
};
var canonHostname = 'coucm4all01.netbenefit.co.uk';
var accountId     = 'ANBT20INE9RW';
var companyName   = 'Luxury+Holiday+Accommodation+Madeira+-+Calheta';
var htmlTitle	  = 'Calheta+Self+Catering+Apartment+-+Madeira+Portugal';
var metaKeywords  = 'HEADMETA+name%3Dkeywords+content%3Dluxury+apartment+rental+madeira%2Cmadeira+holiday+accommodation%2Cmadeira+holiday+apartments%2Cmadeira+apartments%2Cmadeira+luxury+holiday+apartment%2Choliday+homes+apartments+in+madeira%2Cmadeira+accommodation%2Cself+catering+madeira%2Cluxury+holiday+accommodation+madeira%2Cwalking+holidays+in+madeira%2Cmadeira+golf+holiday%2Cmadeira+luxury+holidays%2Cluxury+holiday+offer+madeira%2Cprivate+holiday+villa+madeira%2Choliday+villas+madeira%2Cprivate+villa+rental+madeira%2Cmadeira+luxury+villa%2Choliday+accommodation+in+portugal%2Capartment+rental+portugal%2Cportugal+holiday+apartments%2Cself+catering+in+portugal%2Cmadeira+fishing%2Cmadeira+luxury+resort%2Cgolf+in+madeira%2C+www.self-catering-madeira.com%2FHEAD';
var metaContents  = 'Luxury+2+beedroom+self+catering+holiday+apartment+in+Calheta+Madeira.++Situated+in+the+village+of+Estrela+a+short+distance+from+Calheta+Beach+and+Marina.++Local+activities+include+Whale++Dolphin+watching+as+well+as+levada+walking+excursions.+The+holiday+accommodation+is+fully+equiped+ideal+for+families+or+couples+seeking+a+peaceful+holiday.++Book+your+Madeira+self+catering+break+online+now.';
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();
};

