/* [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','5701',jdecode('Home'),jdecode(''),'/5701.html','true',[],''],
	['PAGE','20506',jdecode('Contact'),jdecode(''),'/20506.html','true',[],''],
	['PAGE','34201',jdecode('Store+Policy'),jdecode(''),'/34201.html','true',[],'']];
var siteelementCount=3;
theSitetree.topTemplateName='Tide';
theSitetree.paletteFamily='C04B0B';
theSitetree.keyvisualId='-1';
theSitetree.keyvisualName='keyv.jpg';
theSitetree.fontsetId='13624';
theSitetree.graphicsetId='12063';
theSitetree.contentColor='FFFFFF';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'en',
  country: 'US'
};
var theTemplate={
				name: 			'Tide',
				paletteFamily: 	'C04B0B',
				keyvisualId: 	'-1',
				keyvisualName: 	'keyv.jpg',
				fontsetId: 		'13624',
				graphicsetId: 	'12063',
				contentColor: 	'FFFFFF',
				contentBGColor: 'FFFFFF',
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'false',
				hasCompanyname: 'false',
				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:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '5701',
internalId:  '',
customField: '20090411-224832'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '34201',
internalId:  '',
customField: '20090118-231206'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '20506',
internalId:  '',
customField: '20080816-153218'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '5701',
internalId:  '1006',
customField: '1006'
};
var canonHostname = 'cmworker01.yourhostingaccount.com';
var accountId     = 'AENDU0IN2VQJ';
var companyName   = 'Valance+Station';
var htmlTitle	  = 'Valances%2C+Curtains%2C+Window+Treatments%2C+and+More%21';
var metaKeywords  = 'valances%2C+curtains%2C+window+treatments%2C+tiers%2C+drapes%2C+panels%2C+rod+pocket%2C+custom+colors%2C+kids+rooms%2C+baby%2C+nursery%2C+sheets%2C+pillow+cases%2C+solid+color+fabric%2C+bedding%2C+lamp+shades%2C+animal+prints%2C+room+decor%2C+home+items%2C+drapery%2C+tab+top%2C+shades%2C+tie+backs%2C+custom+french+door+curtains%2C+household+items%2C+red%2C+blue%2C+brown%2C+green%2C+yellow%2C+orange%2C+purple%2C+pink%2C+lavender%2C+lavander%2C+grey%2C+gray%2C+golden%2C+silver%2C+black%2C+white%2C+tan%2C+beige%2C+hunter+green%2C+kelly%2C+slate%2C+mauve%2C+rust%2C+turquoise%2C+light+blue%2C+lime+green%2C+apple+green%2C+dusty+rose%2C+periwinkle%2C+royal+blue%2C+navy+blue%2C+plum%2C+mustard%2C+bubble+gum+pink%2C+polka+dots+fabic%2C+pastels%2C+earth+tones%2C+primary%2C+off-white+';
var metaContents  = 'Valances%2C+curtains%2C+window+treatments%2C+and+more+at+low+prices.++Shipping+is+always+free%21++For+your+convenience%2C+we+accept+all+major+credit+cards%2C+Google+Checkout%2C+PayPal%2C+and+money+orders.+';
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();
};
