/* [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','2701',jdecode('Inicio'),jdecode(''), jdecode('%2F2701.html'), 'true',[],'',''],
	['PAGE','3601',jdecode('Homologaciones'),jdecode(''), jdecode('%2F3601.html'), 'true',[],'',''],
	['PAGE','3643',jdecode('Veh.+Hist%C3%B3ricos'),jdecode(''), jdecode('%2F3643.html'), 'true',[],'',''],
	['PAGE','3622',jdecode('Patrocinio'),jdecode(''), jdecode('%2F3622.html'), 'true',[],'',''],
	['PAGE','18201',jdecode('Contacto'),jdecode(''), jdecode('%2F18201.html'), 'true',[],'','']];
var siteelementCount=5;
theSitetree.topTemplateName='Commercial';
theSitetree.paletteFamily='C5E8FE';
theSitetree.keyvisualId='10206';
theSitetree.keyvisualName='blanco.swf';
theSitetree.fontsetId='21116';
theSitetree.graphicsetId='13215';
theSitetree.contentColor='232323';
theSitetree.contentBGColor='FFFFFF';
var localeDef={
  language: 'es',
  country: 'ES'
};
var prodDef={
  wl_name: 'arsys',
  product: 'WSCSYSSSSLYTC2IF'
};
var theTemplate={
				hasFlashNavigation: 'false',
				hasFlashLogo: 	'false',
				hasFlashCompanyname: 'false',
				hasFlashElements: 'true',
				hasCompanyname: 'false',
				name: 			'Commercial',
				paletteFamily: 	'C5E8FE',
				keyvisualId: 	'10206',
				keyvisualName: 	'blanco.swf',
				fontsetId: 		'21116',
				graphicsetId: 	'13215',
				contentColor: 	'232323',
				contentBGColor: 'FFFFFF',
				a_color: 		'e6e6e6',
				b_color: 		'ffffff',
				c_color: 		'000000',
				d_color: 		'000000',
				e_color: 		'000000',
				f_color: 		'000000',
				hasCustomLogo: 	'true',
				contentFontFace:'Verdana, Arial, Helvetica, sans-serif',
				contentFontSize:'12',
				useFavicon:     'true'
			  };
var webappMappings = {};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '2701',
internalId:  '',
customField: '20110908-011753'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3622',
internalId:  '',
customField: '20120201-223232'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3601',
internalId:  '',
customField: '20110713-002849'
};
webappMappings['1006']=webappMappings['1006-1006']={
webappId:    '1006',
documentId:  '2701',
internalId:  '1006',
customField: '1006'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '18201',
internalId:  '',
customField: '20100517-180545'
};
webappMappings['5000']=webappMappings['5000-']={
webappId:    '5000',
documentId:  '3643',
internalId:  '',
customField: '20110713-003110'
};
webappMappings['7060']=webappMappings['7060-9f607a5039ddefa209c32238180c966c']={
webappId:    '7060',
documentId:  '3622',
internalId:  '9f607a5039ddefa209c32238180c966c',
customField: 'language:es;country:ES;'
};
webappMappings['7008']=webappMappings['7008-9320']={
webappId:    '7008',
documentId:  '18201',
internalId:  '9320',
customField: 'language:es;country:ES;'
};
var webAppHostname = 'wsc.webaporter.com:80';
var canonHostname = 'llwc535.servidoresdns.net';
var accountId     = 'AAS340INZ1UH';
var companyName   = '+%2F+%2F+%2F+A+U+T+O+I+N+G+E+N+I+E+R+I+A+%2F+%2F+%2F';
var htmlTitle	  = 'AUTOINGENIERIA';
var metaKeywords  = 'autoingenieria%2C+reformas%2C+homologaciones%2C+matriculaciones%2C+historicos%2C+autoingenieria.es%2C+fichas+reducidas%2C+legalizar%2C+modificaciones%2C+catalogaci%C3%B3n+de+hist%C3%B3ricos%2C+cl%C3%A1sicos%2C+rallyes+de+regularidad%2C+laboratorio+de+reformas%2C+carlab%2C+automovilidad%2C+carlos+iii%2C+inta%2C+idiada%2C+pyh%2C+homologastur%2C+vicracing%2C+itv.';
var metaContents  = 'AUTOINGENIERIA%3A+homologaciones%2C+reformas+de+importancia%2C+fichas+reducidas%2C+matriculaciones%2C+catalogaci%C3%B3n+de+veh%C3%ADculos+historicos.';
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();
};

