/* [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','401',jdecode('Home'),jdecode(''),'/401.html','true',[],''],
	['PAGE','7401',jdecode('Photo+album'),jdecode(''),'/7401.html','true',[],''],
	['PAGE','601',jdecode('A+bit+about+us'),jdecode(''),'/601.html','true',[],''],
	['PAGE','7501',jdecode('Accomodation+%26+Prices'),jdecode(''),'/7501.html','true',[],''],
	['PAGE','8901',jdecode('Contact+Us'),jdecode(''),'/8901.html','true',[],'']];
var siteelementCount=5;
theSitetree.topTemplateName='Animal';
theSitetree.paletteFamily='519D4A';
theSitetree.keyvisualId='4292';
theSitetree.keyvisualName='kv_4292.jpg';
theSitetree.fontsetId='10791';
theSitetree.graphicsetId='11210';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='D0E3CE';
var theTemplate={
				name: 			'Animal',
				paletteFamily: 	'519D4A',
				keyvisualId: 	'4292',
				keyvisualName: 	'kv_4292.jpg',
				fontsetId: 		'10791',
				graphicsetId: 	'11210',
				contentColor: 	'000000',
				contentBGColor: 'D0E3CE',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'519D4A',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '401',
internalId:  '',
customField: '20100421-052305'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '601',
internalId:  '',
customField: '20090415-144854'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7401',
internalId:  '',
customField: '20090120-093500'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '7501',
internalId:  '',
customField: '20100410-122209'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '8901',
internalId:  '',
customField: '20090422-152850'
};
webappMappings['7008']=webappMappings['7008-152']={
webappId:    '7008',
documentId:  '8901',
internalId:  '152',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-980541db8c8d9da040e224f72ebc75d8']={
webappId:    '7060',
documentId:  '7401',
internalId:  '980541db8c8d9da040e224f72ebc75d8',
customField: 'language:en;country:US;'
};
var canonHostname = 'wsc-worker04.chi.us.siteprotect.com';
var accountId     = 'AHW050INVUOW';
var companyName   = 'Andalucian+Dream+Holidays';
var htmlTitle	  = 'Andalucian+Dream+Holidays+-+relax%2C+restore%2Cexplore+in+rural+Spain';
var metaKeywords  = '+Cheap++Bed+and+Breakfast+in+Castril+Parque+Natural%2C+All+Inclusive+holidays+in+Castril+Parque+Natural+Andalucia%2C+BB+Andalucia%2C+Granada%2CParque+Natural%2C+Castril+Parque+Naturall%2CCazorla+Parque+Natural%2C+Peaceful+rural+spain%2C+%2C+peace+and+tranquility%2C+photography%2C+birdwatching%2C+cycling%2C+mountains+%2Clakes%2C++beaches%2C+nature%2C+naturist%2C+fiestas%2C++white+villages%2C+ancient+monuments%2C+archeology%2C+history%2C++trees%2C+Santa+Semana%2C+Cuevas+del+Campo%2C+caves%2C+cuevas%2C+';
var metaContents  = 'Bed++Breakfast+in+Castril+Parque+Natural+%2C+All+Inclusive+holidays+in+Castril+Natural+Park%2C+Cazorla+Parque+Natural%2Cl+Andalucia.++Long+term+accomodation.+Holistic+breaks+with+natural+therapies+.+Relax%2C+recharge+and+recuperate%2C+recover+from+surgery+or+illness+with+attentive+and+caring+proprietors.++.+Vibrant+Summer+Fiestas.+Enjoy+photography%2C+birdwatching%2C+walking+amongst+pine+clad+mountains+and+lakes.+Perfect++peace+and++tranquility.+Nature%2C+fiesta%2C+archeology%2C+history%2Cgeology.+Santa+Semana+de+Cuevas+del+Campo-+%28re-enactment+of+Cruxifiction+and+Resurrection%29+in+March%2F+April+every+year.';
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();
};
