/* [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','42',jdecode('Home'),jdecode(''),'/42.html','true',[],''],
	['PAGE','63',jdecode('Gallery'),jdecode(''),'/63.html','true',[],''],
	['PAGE','72',jdecode('Panoramas+%26+Paintings'),jdecode(''),'/72.html','true',[],''],
	['PAGE','81',jdecode('Order+Info+'),jdecode(''),'/81.html','true',[],''],
	['PAGE','90',jdecode('Bio+-+Contact'),jdecode(''),'/90.html','true',[],'']];
var siteelementCount=5;
theSitetree.topTemplateName='Bombay';
theSitetree.paletteFamily='395987';
theSitetree.keyvisualId='7531';
theSitetree.keyvisualName='kv_7531.jpg';
theSitetree.fontsetId='16583';
theSitetree.graphicsetId='12202';
theSitetree.contentColor='000000';
theSitetree.contentBGColor='C0B89D';
var theTemplate={
				name: 			'Bombay',
				paletteFamily: 	'395987',
				keyvisualId: 	'7531',
				keyvisualName: 	'kv_7531.jpg',
				fontsetId: 		'16583',
				graphicsetId: 	'12202',
				contentColor: 	'000000',
				contentBGColor: 'C0B89D',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				a_color: 		'395987',
				b_color: 		'000000',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'false',
				contentFontFace:'Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'false'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '42',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '42',
internalId:  '',
customField: '20090726-193119'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '72',
internalId:  '',
customField: '20090805-175823'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '63',
internalId:  '',
customField: '20090807-130912'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '81',
internalId:  '',
customField: '20090726-184205'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '90',
internalId:  '',
customField: '20090726-190249'
};
var canonHostname = 'wsc-worker04.chi.us.siteprotect.com';
var accountId     = 'AHW050INX2NF';
var companyName   = 'KANEGIS+GALLERY+-+Fine+Art+Photography';
var htmlTitle	  = 'KANEGIS+GALLERY';
var metaKeywords  = 'Lighthouse+photographs%2C+lighthouse%2C+lighthouses%2C+lighthouse+pics%2C+Lighthouse+photos%2C+new+england+photographs%2C+new+england+pics%2C+new+England+photos%2C+new+England%2C+panoramas%2C+panoramas%2C+panoramic%2C+Rockport+photographs%2C+Rockport%2C+Rockport+pics%2C+Rockport+photos%2C+Gloucester%2C+Gloucester+photographs%2C+Rockport+Massachusetts%2C+Massachusetts%2C+Gloucester+pics%2C+Gloucester+photos%2C+cape+ann%2C+cape+ann+photographs%2C+cape+ann+photos%2C+cape+ann+pics%2C+motif%2C+motif+photographs%2C+motif+photos%2C+motif+pics%2C+ocean%2C+ocean+photographs%2C+ocean+photos%2C+ocean+pics%2C+sea+smoke%2C+arctic+sea+smoke%2C+sea+smoke+photographs%2C+sea+smoke+photos%2C+sea+smoke+pics%2C+buoys%2C+buoy+photographs%2C+buoy+photos%2C+buoy+pics%2C+lobster+traps%2C+lobster+trap+photographs%2C+lobster+trap+photos%2C+lobster+trap+pics%2C+fishing+boats%2C+fishing+boat+photographs%2C+fishing+boat+photos%2C+fishing+boat+pics%2C+beaches%2C+beach%2C+beach+photographs%2C+beach+photos%2C+beach+pics%2C+fine+art+photography%2C+outdoor+photographs%2C+outdoor+photography%2C+outdoor+photos%2C+outdoor+pics%2C+nature+photography%2C+nature+photographs%2C+nature+photos%2C+nature+pics%2C+southwest+photographs%2C+southwest+photos%2C+southwest%2C+southwest+pics%2C+byrce+canyon%2C+grand+canyon%2C+zion%2C+arches%2C+mesa+verde%2C';
var metaContents  = 'Fine+Art+Photography%3A+Kanegis+Gallery+located+in+Rockport+Massachusetts+features+fine+art+photography.+Visit+Kanegis+gallery+online+at+www.kanegisgallery.com%2C+by+email+info%40kanegisgallery.com+or+phone+at+617-875-2999.++Kanegis+Gallery++Fine+Art+Photography+13+B+Bearskin+Neck+Rockport%2C+MA+01966';
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();
};
