/* [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','501',jdecode('Gem+Cutting+Services'),jdecode(''), jdecode('%2F501.html'), 'true',[],'',''],
	['PAGE','552',jdecode('Blue+Topaz+Treatment+'),jdecode(''), jdecode('%2F552.html'), 'true',[],'',''],
	['PAGE','48212',jdecode('Artisticut+Gemstones'),jdecode(''), jdecode('%2F48212.html'), 'true',[],'',''],
	['PAGE','594',jdecode('Ceylon+Blue+Sapphire'),jdecode(''), jdecode('%2F594.html'), 'true',[],'',''],
	['PAGE','615',jdecode('Lab-Enhanced+Quartz'),jdecode(''), jdecode('%2F615.html'), 'true',[],'',''],
	['PAGE','636',jdecode('Lab-Enhanced+Topaz'),jdecode(''), jdecode('%2F636.html'), 'true',[],'',''],
	['PAGE','72534',jdecode('Opal+Moonstones'),jdecode(''), jdecode('%2F72534.html'), 'true',[],'',''],
	['PAGE','678',jdecode('Payment+%2F+Shipping+'),jdecode(''), jdecode('%2F678.html'), 'true',[],'',''],
	['PAGE','699',jdecode('Contact'),jdecode(''), jdecode('%2F699.html'), 'true',[],'','']];
var siteelementCount=9;
theSitetree.topTemplateName='Moonflight';
theSitetree.paletteFamily='708B50';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='446';
theSitetree.graphicsetId='500';
theSitetree.contentColor='A00000';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var prodDef={
  wl_name: 'grp19-dulles',
  product: 'WSCSYSSSSLYTCPII'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				name: 			'Moonflight',
				paletteFamily: 	'708B50',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'446',
				graphicsetId: 	'500',
				contentColor: 	'A00000',
				contentBGColor: 'FFFFFF',
				a_color: 		'476A1E',
				b_color: 		'FFFFFF',
				c_color: 		'FFFFFF',
				d_color: 		'FFFFFF',
				e_color: 		'FFFFFF',
				f_color: 		'FFFFFF',
				hasCustomLogo: 	'false',
				contentFontFace:'Times New Roman, Times, serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '501',
internalId:  '1006',
customField: '1006'
};
webappMappings['1501']=webappMappings['1501-7579092']={
webappId:    '1501',
documentId:  '501',
internalId:  '7579092',
customField: '1501'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '501',
internalId:  '',
customField: '20110911-164840'
};
webappMappings['7008']=webappMappings['7008-7139']={
webappId:    '7008',
documentId:  '501',
internalId:  '7139',
customField: 'language:en;country:US;'
};
webappMappings['7060']=webappMappings['7060-c4e0129f6af48856bb4017f46df07d47']={
webappId:    '7060',
documentId:  '48212',
internalId:  'c4e0129f6af48856bb4017f46df07d47',
customField: 'language:en;country:US;'
};
webappMappings['7008']=webappMappings['7008-7138']={
webappId:    '7008',
documentId:  '699',
internalId:  '7138',
customField: 'language:en;country:US;'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '552',
internalId:  '',
customField: '20101212-141225'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '594',
internalId:  '',
customField: '20110629-122305'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '72534',
internalId:  '',
customField: '20101113-125620'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '615',
internalId:  '',
customField: '20110201-213006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '636',
internalId:  '',
customField: '20101115-163942'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '48212',
internalId:  '',
customField: '20091016-212945'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '678',
internalId:  '',
customField: '20091017-232938'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '699',
internalId:  '',
customField: '20091206-120456'
};
var webAppHostname = 'diycgi.cluster.stngva01.us.diy-servers.net:80';
var canonHostname = 'diywk00.verio.stngva01.us.diy-servers.net';
var accountId     = 'AVEC10INLV8E';
var companyName   = 'SITHY+GEMS+%26+LAPIDARY+-+SRI+LANKA';
var htmlTitle	  = 'Gem+Cutting%2C+Faceting+Gems%2C+Custom+Cut+Gemstone%2C+Opals+Cutters%2C+Lapidary%2C+cutting+sapphires%2C+Gems+faceter%2CGemcutter%2CTopaz%2CGarnet%2C+Ruby%2CSapphire+Cutting%2CCutter%2CCustom+Faceting%2CCabbing+Gemstone';
var metaKeywords  = 'Faceting%2C+Gem+cutting%2C+Gemstone+cutters%2C+Lapidary%2C+Cutting+gemstones%2C+Lapidarist%2C+Lapidaries%2C+Gemstones+cutting%2C+Cutting+gem+stone%2C+Gems+cutting%2C+Rockhound%2C+Cutting+emeralds%2C%0D%0ACutting+precious+stones%2C+Cutting+Opals%2C+Gem+cutters%2C+Precious+stone+cutting%2C+Cutting+topaz%2C+Opal+cutters%2C+Garnet+Cutting%2C+Sapphire+Cutting%2C+Lapidary+Cutting%2C+Faceting+Gemstones%2C%0D%0AGemstone+cutting+and+polishing%2C+Gemstone+cutting+services%2C+Gem+cutting+services%2C+Cutting+garnets%2C+Cutting+rubies%2C+Gemstone+digging%2C+Gems+cutter%2C+Gem+faceting%2C+Custom+gemstone+cutting%2C+Ruby+cutter%2C+Custom+faceting%0D%0A';
var metaContents  = 'Lapidary+Services+for+Faceting+Gemstone+to+similar+Quality+of+American+%26+European+Gem+Cutters+%26+Low+Cutting+Rates.+World+Class+Gem+Cutting%2C+Faceting+%26+Cabbing%2C+Custom+Cut+Gemstone%2C+Opals+Cutters%2C+Lapidary+Services%2C+Rockhound+Lapidaries%2CGems+Cutting+Lapidariest%2C+Gems+stone+Emeralds%2C+Precious+stones%2C+Sapphire%2C+Garnet%2C+Tourmaline%2C+Cutting+Topaz%2C+%0D%0APolishing+Ruby%2C+Rubies%2C+Gemstone+Digging%2C+Gemcutter%2C+%0D%0A%0D%0A';
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();
};

