var opMode="";
var centerTiles=true;
var centerMargin=0;
var oTabManager;
var currentTiles;
currentFormats=new Array();
var mapIndexsName="map_indexs";
function onLoad(){
if(window.addEventListener){
window.addEventListener("resize",resizeElements,false);
window.onresise=resizeElements;
}else{
window.attachEvent("onresize",resizeElements);
}
resizeElements();
oTabManager=new tab_manager();
oTabManager.add("1");
oTabManager.add("2");
oTabManager.setTitle("1","divTab1");
oTabManager.setTitle("2","divTab2");
currentTiles=new tileCollection();
var _1;
_1=document.getElementById("radioHidden");
if(_1){
_1.checked=true;
}
_1=document.getElementById("a_radio_0_0");
if(_1){
_1.checked=true;
}
document.getElementById("cboMunicipis").selectedIndex=0;
return false;
}
function onMapLoaded(){
document.getElementById("divContent").style.display="";
document.getElementById("divLoading").style.display="none";
return false;
}
function onResize(){
resizeElements();
return false;
}
function expandFile(id){
var _3=id.split("_");
var _4;
if(_3.length==3){
_4=_3[0]+"_";
index=_3[2];
}else{
_4="";
index=_3[1];
}
var el=document.getElementById(_4+"menu_"+index);
if(el){
value=(el.style.display!="");
el.style.display=(value)?"":"none";
el=document.getElementById(_4+"imgMenu_"+index);
el.src=(value)?"img/utils/up.gif":"img/utils/down.gif";
}
}
function selectRadio(_6){
var _7=_6.split("_");
var _8;
if(_7.length==4){
_8=_7[0];
type=_7[1];
groupCode=_7[2];
layerCode=_7[3];
}else{
_8="";
type=_7[0];
groupCode=_7[1];
layerCode=_7[2];
}
if(setLayerVisible(_8,groupCode,layerCode)){
var _9=(_8=="a")?document.getElementById("divMenuExtra"):document.getElementById("divMenuProducts");
var _a=document.getElementById("imgMenu_"+groupCode);
if(_a){
var _b=_a.src.substring(_a.src.lastIndexOf("/")+1,_a.src.lastIndexOf("."));
if(_b=="down"){
expandFile("imgMenu_"+groupCode);
}
var _c=_9.getElementsByTagName("input");
for(i=0;i<_c.length;i++){
var _d=_c[i].id.replace("radio","txt");
el=document.getElementById(_d);
if(el){
if(!(_c[i].id==_6)){
el.className="divMenu5";
}else{
_c[i].checked=true;
el.className="divMenu5 divMenuSelected";
}
}
}
}
}
return false;
}
function resizeElements(){
var _e=50;
wContainer=Math.floor(parseInt(getWindowWidth()*0.98));
hContainer=Math.floor(parseInt(getWindowHeight()));
hContainer=hContainer-_e-(hContainer*0.02);
var _f=wContainer*0.74;
var _10=hContainer-70;
var _11=_f-2;
var _12=_10-2;
sizeElement("divTabContainer",_f,_10,false,65);
sizeElement("iframeInfo",_f-4,_10-30-8+1,false,false);
wStatus=_f-170;
sizeElement("divTextButton4",wStatus,false,false,false);
var _13=getMyMapObject();
if(_13){
_13.width=_11;
_13.height=_12;
_13.refresh();
}else{
var _14=document.getElementById("iframeMap");
_14.src="egv/map.php?wmc=../xml/main.xml&w="+_11+"&h="+_12+"&lang="+locale;
}
return false;
}
function findPos(_15){
var el=document.getElementById(_15);
var _17=curtop=0;
if(el.offsetParent){
_17=el.offsetLeft;
curtop=el.offsetTop;
while(el=el.offsetParent){
_17+=el.offsetLeft;
curtop+=el.offsetTop;
}
}
return [_17,curtop];
}
function sizeElement(_18,_19,_1a,_1b,top){
var el=document.getElementById(_18);
if(el){
if(_19){
el.style.width=_19+"px";
}
if(_1a){
el.style.height=_1a+"px";
}
if(_1b){
el.style.left=_1b+"px";
}
if(top){
el.style.top=top+"px";
}
}
}
function includeScript(id,_1f){
var _20=parent.document.getElementsByTagName("head").item(0);
var js=parent.document.createElement("script");
js.setAttribute("language","javascript");
js.setAttribute("type","text/javascript");
js.setAttribute("src",_1f);
js.setAttribute("id",id+"_script");
_20.appendChild(js);
return false;
}
function removeScript(id){
var _23=parent.document.getElementsByTagName("head").item(0);
var _24=parent.document.getElementById(id);
if(_24){
_23.removeChild(_24);
}
return false;
}
function getWindowWidth(_25){
if(typeof (window.innerWidth)=="number"){
return window.innerWidth;
}else{
if(document.documentElement&&document.documentElement.clientWidth){
return document.documentElement.clientWidth;
}else{
if(document.body&&document.body.clientWidth){
return document.body.clientWidth;
}
}
}
return _25;
}
function getWindowHeight(_26){
if(typeof (window.innerHeight)=="number"){
return window.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
return document.documentElement.clientHeight;
}else{
if(document.body&&document.body.clientHeight){
return document.body.clientHeight;
}
}
}
return _26;
}
function getMyMapObject(obj){
var _28;
var _29;
_28=document.getElementById("iframeMap");
if(!_28){
_29=(parent.contentWindow||parent.contentDocument);
_28=_29.getElementById("iframeMap");
}
if(!_28){
return false;
}
_29=(_28.contentWindow||_28.contentDocument);
if(_29){
if(_29.myMap){
return _29.myMap;
}
}
return false;
}
function setMapValue(key,_2b){
var map=getMyMapObject().map;
if(map==null){
return false;
}
if(map.properties==null){
map.properties=new Array();
}
map.properties[key]=_2b;
return true;
}
function getMapValue(key){
var map=getMyMapObject().map;
if(map==null){
return false;
}
if(!map.properties){
return false;
}
return map.properties[key];
}
function centerFeature(_2f){
if(_2f){
_2f=_2f.split(",");
var map=getMyMapObject().map;
if(map){
map.setextent(parseInt(_2f[0]),parseInt(_2f[3]),parseInt(_2f[2]),parseInt(_2f[1]),true);
}
if(oTabManager.active=="1"){
oTabManager.activate("2");
}
}
return false;
}
function printFrame(_31){
var _32=document.getElementById(_31);
var _33=(_32.contentWindow||_32.contentDocument);
_33.focus();
_33.print();
return false;
}
function showTextMessage(_34,_35){
var el=document.getElementById("divTextStatus");
var _37=(_35)?"<font style=\"color:#"+_35+"\">"+_34+"</font>":_34;
if(el){
el.innerHTML=_37;
}
return false;
}
function showHelp(_38){
var src=(_38)?"pages/"+locale+"/help/index.htm":"pages/"+locale+"tutorial/index.html";
changeInfoPage(src);
if(oTabManager.active!="1"){
oTabManager.activate("1");
}
}
function showTileList(){
if(!currentTiles.tiles.length){
showWarning(locStrings._index_no_tiles);
}else{
changeInfoPage("pages/tilelist.php");
}
}
function showWarning(_3a){
_3a="<img id=\"imgWarning\" src=\"img/utils/achtungbaby.gif\" alt=\""+locStrings._generic_warning+"\" />"+_3a;
showTextMessage(_3a,"D51525");
colorFade("divTextStatus","FFFFCC","FFFFFF",25,50);
}
function colorFade(id,_3c,end,_3e,_3f){
var _40,endrgb,er,eg,eb,step,rint,gint,bint,step;
var _41;
var pos=id.indexOf(".");
if(pos!=-1){
var _43=id.substring(0,pos);
id=id.substring(pos+1);
oIframePage=document.getElementById(_43);
if(oIframePage){
oDoc=(oIframePage.contentWindow||oIframePage.contentDocument);
if(oDoc){
oDoc=oDoc.document;
}
_41=oDoc.getElementById(id);
}
}else{
_41=document.getElementById(id);
}
if(!_41){
return false;
}
_3e=_3e||20;
_3f=_3f||20;
clearInterval(_41.timer);
endrgb=colorConv(end);
er=endrgb[0];
eg=endrgb[1];
eb=endrgb[2];
if(!_41.r){
_40=colorConv(_3c);
r=_40[0];
g=_40[1];
b=_40[2];
_41.r=r;
_41.g=g;
_41.b=b;
}
rint=Math.round(Math.abs(_41.r-er)/_3e);
gint=Math.round(Math.abs(_41.g-eg)/_3e);
bint=Math.round(Math.abs(_41.b-eb)/_3e);
if(rint==0){
rint=1;
}
if(gint==0){
gint=1;
}
if(bint==0){
bint=1;
}
_41.step=1;
_41.timer=setInterval(function(){
animateColor(_41,_3e,er,eg,eb,rint,gint,bint);
},_3f);
}
function animateColor(_44,_45,er,eg,eb,_49,_4a,_4b){
if(!_44){
return false;
}
var _4c;
if(_44.step<=_45){
var r=_44.r;
var g=_44.g;
var b=_44.b;
r=(r>=er)?r-_49:parseInt(r)+parseInt(_49);
g=(g>=eg)?g-_4a:parseInt(g)+parseInt(_4a);
b=(b>=eb)?b-_4b:parseInt(b)+parseInt(_4b);
_4c="rgb("+r+","+g+","+b+")";
_44.style.backgroundColor=_4c;
_44.r=r;
_44.g=g;
_44.b=b;
_44.step++;
}else{
clearInterval(_44.timer);
_4c="rgb("+er+","+eg+","+eb+")";
_44.style.backgroundColor=_4c;
_44.r=false;
_44.g=false;
_44.b=false;
}
}
function colorConv(_50){
var rgb=[parseInt(_50.substring(0,2),16),parseInt(_50.substring(2,4),16),parseInt(_50.substring(4,6),16)];
return rgb;
}
function switchLog(_52){
var _53=(_52)?"img/utils/lock_closed.gif":"img/utils/lock_open.gif";
var _54=(_52)?locStrings._index_menutop_img_logout:locStrings._index_menutop_img_login;
var _55=(_52)?locStrings._index_menutop_logout:locStrings._index_menutop_login;
var _56;
if(_52){
_56=function(){
changeInfoPage("pages/logout.php",true);
return false;
};
}else{
_56=function(){
changeInfoPage("pages/login.php",true);
return false;
};
}
document.getElementById("imgLog").src=_53;
document.getElementById("spanLog").innerHTML=_55;
document.getElementById("aLog").onclick=_56;
return false;
}
function setLayerVisible(_57,_58,_59){
if(_57=="a"){
return setAltresVisible(_58,_59);
}else{
return setIndexVisible(_58,_59);
}
}
function setAltresVisible(_5a,_5b){
var map=getMyMapObject().map;
var _5d=getMapValue("currentRefLayer");
var _5e=altres[_5a].children[_5b];
if(_5e.caption=="Cap"){
setMapValue("currentRefLayer",null);
}else{
setMapValue("currentRefLayer",_5e);
}
if(isDefRefLyr){
_5d=defRefLyr;
isDefRefLyr=false;
}
var _5f=map._getserverindex(altres[_5a].children[_5b].mapFileName);
var _60=true;
if(_5d){
if(_5e.caption==_5d.caption){
return false;
}
var _61=map._getserverindex(_5d.mapFileName);
setConnLayersVisible(_61,false);
}
if(getMapValue("currentRefLayer")){
setConnLayersVisible(_5f,true);
}
if(_60){
map.refresh();
return true;
}
return false;
}
function setIndexVisible(_62,_63){
var map=getMyMapObject().map;
var _65=getMapValue("currentLayer");
var lyr=layersDefinition[_62].children[_63];
var _67=map._getserverindex(mapIndexsName);
var _68=map.connections[_67]._getlayerindex(lyr.layer);
if(_68==-1){
setMapValue("currentLayer",_65);
restoreRadio();
showLyrName(-1);
return false;
}
if(_65){
if(lyr.layer==_65.layer){
return false;
}
if(checkCurrentTiles()){
var _69=map._getserverindex(_65.mapFileName);
}else{
return false;
}
}
setMapValue("currentLayer",lyr);
setMapValue("group",lyr.type);
setMapValue("currentOption",_62+","+_63);
setMapValue("year",getLyrYear(lyr.layer,getMapValue("group")));
var _6a=true;
if(_65){
if(!setConnLayersVisible(_69,false)||!setConnLayersVisible(_67,false)){
_6a=false;
}
map.elementseditor.clear();
currentTiles.tiles=new Array();
removeScript(_65.layer+"_script");
setTitleNumTiles(0);
}
if(!map.setvisible(_67,_68,true)){
_6a=false;
}
if(lyr.type=="topo"||lyr.type=="orto"){
var _6b=map._getserverindex(lyr.mapFileName);
var _6c=map.connections[_6b]._getlayerindex(lyr.layer);
if(!map.setvisible(_6b,_6c,true)){
_6a=false;
}
}
if(_6a){
currentTiles.setProduct(lyr.id,lyr.titleText);
currentTiles.setFormat(false);
setToolbarButtonsVisibility(layersDefinition[_62].group);
showLyrName(lyr.titleText);
map.loadingcount=0;
map.refresh(_67);
includeScript(lyr.layer,"lib/indexs.php?pid="+lyr.layer);
currentFormats=new Array;
if(lyr.infoPage){
changeInfoPage(lyr.infoPage);
}
return true;
}
}
function setTopoVisible(_6d){
var map=getMyMapObject().map;
var lyr=getMapValue("currentLayer");
var _70=map._getserverindex(lyr.mapFileName);
map.connections[_70].setparameter("codi_topo",_6d);
setConnLayersVisible(_70,true);
map.refresh(_70);
}
function setOrtoVisible(_71){
var map=getMyMapObject().map;
var lyr=getMapValue("currentLayer");
var _74=map._getserverindex(lyr.mapFileName);
var _75=map.connections[_74]._getlayerindex(lyr.layer);
map.connections[_74].setparameter("codi_orto",_71);
map.setvisible(_74,_75,_71!="");
map.refresh(_74);
}
function setFotoVisible(_76){
var map=getMyMapObject().map;
var lyr=getMapValue("currentLayer");
var _79=map._getserverindex(lyr.mapFileName);
var _7a=map.connections[_79]._getlayerindex(lyr.layer);
map.connections[_79].setparameter("codi_foto",_76);
map.setvisible(_79,_7a,true);
map.refresh(_79);
}
function showLyrName(_7b){
var msg;
if(_7b==-1){
msg=locStrings._index_product_unavailable;
}else{
msg=locStrings._index_active_product+": "+_7b;
}
title=parent.document.createTextNode(msg);
old=parent.document.getElementById("divProduct").childNodes.item(0);
parent.document.getElementById("divProduct").replaceChild(title,old);
}
function setConnLayersVisible(_7d,_7e){
var _7f=true;
var map=getMyMapObject().map;
for(var i=0;i<map.connections[_7d].layers.length;i++){
if(!map.setvisible(_7d,i,_7e)){
_7f=_7e;
}
}
return _7f;
}
function getLyrYear(_82,_83){
if(_83=="foto"){
var _84=_82.substring(_82.length-2);
if(_84<50){
_84="20"+_84;
}else{
_84="19"+_84;
}
return _84;
}
return false;
}
function checkCurrentTiles(){
var _85=currentTiles.tiles;
if(_85.length){
if(confirm(locStrings._index_warning_tiles_selected)){
return true;
}else{
restoreRadio();
return false;
}
}
return true;
}
function restoreRadio(){
var _86=getMapValue("currentOption");
if(!_86){
return false;
}
var _87=_86.split(",");
el=document.getElementById("radio_"+_87[0]+"_"+_87[1]);
if(el){
el.checked=true;
}
return true;
}
function changeInfoPage(src,tab){
if(!tab){
tab=false;
}
var _8a=document.getElementById("iframeInfo");
if(_8a){
_8a.src=src;
}
if(tab){
if(oTabManager.active!="1"){
oTabManager.activate("1");
}
}
}
function setToolbarButtonsVisibility(_8b){
var _8c=getMyMapObject();
var _8d=_8c.tbar;
if(_8d){
if(!_8d._getbuttonindex("select")){
_8d.addbutton("select",locStrings._index_button_select,"select_over.gif","select_over.gif","select_active.gif","checkable");
}
if(!_8d._getbuttonindex("show")){
_8d.addbutton("show",locStrings._index_button_show,"show_over.gif","show_over.gif","show_active.gif","checkable");
}
_8c.refresh();
}
}
function setTitleNumTiles(num,_8f){
if(!_8f){
_8f=document.getElementById("spanNumTiles");
}
var _90="";
var _91=getMapValue("group");
if(_8f){
_90="";
if(num>0){
_90=_90+"("+num;
if(_91=="foto"){
if(num==1){
_90=_90+" "+locStrings._index_pic_selected;
}else{
_90=_90+" "+locStrings._index_pics_selected;
}
}else{
if(num==1){
_90=_90+" "+locStrings._index_tile_selected;
}else{
_90=_90+" "+locStrings._index_tiles_selected;
}
}
_90=_90+")";
}
_8f.innerHTML=_90;
}
return false;
}
function centerTile(_92){
var _92=_92.split(",");
var map=getMyMapObject().map;
var lyr=getMapValue("currentLayer");
if(lyr.forcescale){
var _95=parseInt(_92[0])+((parseInt(_92[2])-parseInt(_92[0]))/2);
var _96=parseInt(_92[3])+((parseInt(_92[1])-parseInt(_92[3]))/2);
map.setcenterscale(_95,_96,lyr.forcescale);
}else{
map.setextent(parseInt(_92[0])-centerMargin,parseInt(_92[1])+centerMargin,parseInt(_92[2])+centerMargin,parseInt(_92[3])-centerMargin,true);
}
return false;
}
function checkTileFile_callback(_97){
if(_97){
_97=_97.split("|");
var id=_97[0];
var _99=_97[1];
if(opMode=="show"){
if(centerTiles){
if(_99){
centerTile(_99);
}
}
var _9a=getMapValue("group");
switch(_9a){
case "foto":
setFotoVisible(id);
break;
case "orto":
setOrtoVisible(id);
break;
default:
break;
}
}else{
if(opMode=="select"){
recordSelection(id);
}
}
}else{
var _9b=getMyMapObject();
if(opMode=="show"){
_9b.stbar.locked=true;
_9b.stbar.show("<img id=\"imgWarning\" src=\"../img/utils/achtungbaby.gif\" alt=\""+locStrings._generic_warning+"\" />"+locStrings._index_visualization_unavailable,"#D51525");
colorFade("iframeMap.divMapStatus","FFFFCC","FFFFFF",25,50);
setTimeout("getMyMapObject().stbar.locked = false;",3000);
}
}
}
function recordSelection(_9c){
if(_9c){
var map=getMyMapObject().map;
var _9e=currentTiles.tileExistsByCode(_9c.codes);
if(_9e!==false){
var id=currentTiles.tiles[_9e].id;
var _a0=currentTiles.removeTile(id);
map.elementseditor.removeGeometry(id);
}else{
var _a1=addTileToMap(_9c.extent);
newTile=currentTiles.addTile(_a1,_9c.codes,_9c.fields,_9c.extent);
}
map.elementseditor.draw();
setTitleNumTiles(currentTiles.tiles.length);
refreshTilesList();
return false;
}
}
function addTileToMap(_a2){
var _a3=document.getElementById("iframeMap");
var _a4=(_a3.contentWindow||_a3.contentDocument);
var map=_a4.myMap.map;
element=new _a4.polygon();
element.setColor("#00FF00");
element.setSize(3);
element.setFill(false);
element.addVertex(_a2.xmin,_a2.ymin);
element.addVertex(_a2.xmin,_a2.ymax);
element.addVertex(_a2.xmax,_a2.ymax);
element.addVertex(_a2.xmax,_a2.ymin);
element.addVertex(_a2.xmin,_a2.ymin);
var id=map.elementseditor.addGeometry(element);
return id;
}
function refreshTilesList(){
var _a7=document.getElementById("iframeInfo");
if(_a7){
var src=_a7.src;
var _a9=(_a7.contentWindow||_a7.contentDocument);
if(src.substring(src.lastIndexOf("/")+1)=="tilelist.php"){
if(_a9){
if(typeof (_a9.addTile)=="function"){
_a9.addTile();
}
}
}else{
changeInfoPage("pages/tilelist.php");
}
}
}
function clearTiles(_aa){
if(!_aa&&!currentTiles.tiles.length){
showWarning(locStrings._index_no_tiles);
return false;
}
currentTiles.tiles=Array();
var map=getMyMapObject().map;
map.elementseditor.clear();
map.elementseditor.draw();
setTitleNumTiles(0);
if(!_aa){
refreshTilesList();
}
}
function unselectProduct(){
var _ac=getMapValue("currentLayer");
if(!_ac){
showWarning(locStrings._index_no_product);
}else{
if(checkCurrentTiles()){
var myMap  = getMyMapObject();var map  = myMap.map;

var _ae=map._getserverindex(mapIndexsName);
var _af=map.connections[_ae]._getlayerindex(_ac.layer);
var _b0=map._getserverindex(_ac.mapFileName);
setMapValue("currentLayer",false);
setMapValue("group",false);
setMapValue("currentOption",false);
setMapValue("year",false);
if(_b0){
if(!setConnLayersVisible(_b0,false)||!setConnLayersVisible(_ae,false)){
}
changeInfoPage("pages/"+locale+"/welcome.htm",true);
removeScript(_ac.layer+"_script");
clearTiles(true);
var _b1=document.getElementById("divMenuProducts");
var _b2=_b1.getElementsByTagName("input");
for(i=0;i<_b2.length;i++){
var _b3=_b2[i].id.replace("radio","txt");
el=document.getElementById(_b3);
if(el){
el.className="divMenu5";
}
_b2[i].checked=false;
}
myMap.tbar.removebutton("select");myMap.tbar.removebutton("show");map.refresh();myMap.refresh();
}
}else{
return false;
}
}
}

if(!this.JSON){
JSON=function(){
function f(n){
return n<10?"0"+n:n;
}
Date.prototype.toJSON=function(){
return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z";
};
var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"};
function stringify(_3,_4){
var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;
switch(typeof _3){
case "string":
return r.test(_3)?"\""+_3.replace(r,function(a){
var c=m[a];
if(c){
return c;
}
c=a.charCodeAt();
return "\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16);
})+"\"":"\""+_3+"\"";
case "number":
return isFinite(_3)?String(_3):"null";
case "boolean":
case "null":
return String(_3);
case "object":
if(!_3){
return "null";
}
if(typeof _3.toJSON==="function"){
return stringify(_3.toJSON());
}
a=[];
if(typeof _3.length==="number"&&!(_3.propertyIsEnumerable("length"))){
l=_3.length;
for(i=0;i<l;i+=1){
a.push(stringify(_3[i],_4)||"null");
}
return "["+a.join(",")+"]";
}
if(_4){
l=_4.length;
for(i=0;i<l;i+=1){
k=_4[i];
if(typeof k==="string"){
v=stringify(_3[k],_4);
if(v){
a.push(stringify(k)+":"+v);
}
}
}
}else{
for(k in _3){
if(typeof k==="string"){
v=stringify(_3[k],_4);
if(v){
a.push(stringify(k)+":"+v);
}
}
}
}
return "{"+a.join(",")+"}";
}
}
return {stringify:stringify,parse:function(_8,_9){
var j;
function walk(k,v){
var i,n;
if(v&&typeof v==="object"){
for(i in v){
if(Object.prototype.hasOwnProperty.apply(v,[i])){
n=walk(i,v[i]);
if(n!==undefined){
v[i]=n;
}
}
}
}
return _9(k,v);
}
if(/^[\],:{}\s]*$/.test(_8.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){
j=eval("("+_8+")");
return typeof _9==="function"?walk("",j):j;
}
throw new SyntaxError("parseJSON");
}};
}();
}

var jsEncoder={encode:function(_1){
var _2=_1;
if(typeof (_2)=="string"){
_2=escape(_2);
}
return _2;
},encodeObject:function(_3){
if(typeof (_3)=="object"){
for(var i in _3){
if(typeof (_3[i])=="object"){
_3[i]=this.encodeObject(_3[i]);
}else{
_3[i]=this.encode(_3[i]);
}
}
}else{
_3=this.encode(_3);
}
return _3;
}};
var jsDecoder={decode:function(_5){
var _6=_5;
if(typeof (_6)=="string"){
_6=unescape(_6);
}
return _6;
},decodeObject:function(_7){
if(typeof (_7)=="object"){
for(var i in _7){
if(typeof (_7[i])=="object"){
_7[i]=this.decodeObject(_7[i]);
}else{
_7[i]=this.decode(_7[i]);
}
}
}else{
_7=this.decode(_7);
}
return _7;
}};

var sajax_request_type="GET";
function sajax_debug(_1){
if(false){
alert("RSD: "+_1);
}
}
function sajax_init_object(){
var _2;
try{
_2=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
_2=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc){
_2=null;
}
}
if(!_2&&typeof XMLHttpRequest!="undefined"){
_2=new XMLHttpRequest();
}
if(!_2){
sajax_debug("Could not create connection object.");
}
return _2;
}
function sajax_do_call(_3,_4){
var i,x,n;
var _6;
var _7;
_6="lib/ajax.php";
if(sajax_request_type=="GET"){
if(_6.indexOf("?")==-1){
_6=_6+"?rs="+escape(_3);
}else{
_6=_6+"&rs="+escape(_3);
}
for(i=0;i<_4.length-1;i++){
_6=_6+"&rsargs[]="+escape(_4[i]);
}
_6=_6+"&rsrnd="+new Date().getTime();
_7=null;
}else{
_7="rs="+escape(_3);
for(i=0;i<_4.length-1;i++){
_7=_7+"&rsargs[]="+escape(_4[i]);
}
}
x=sajax_init_object();
x.open(sajax_request_type,_6,true);
if(sajax_request_type=="POST"){
x.setRequestHeader("Method","POST "+_6+" HTTP/1.1");
x.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
x.setRequestHeader("Content-length",_7.length);
x.setRequestHeader("Connection","close");
}
x.onreadystatechange=function(){
if(x.readyState!=4){
return;
}
sajax_debug("received "+x.responseText);
var _8;
var _9;
_8=x.responseText.charAt(0);
var i=x.responseText.indexOf(":");
_9=x.responseText.substring(i+1);
if(_8=="-"){
alert("Error: "+_9);
}else{
_4[_4.length-1](_9);
}
};
x.send(_7);
sajax_debug(_3+" uri = "+_6+"/post = "+_7);
sajax_debug(_3+" waiting..");
delete x;
}

var altres=new Array();
altres[0]={caption:"Altres informacions",expanded:false,type:"radio",group:"altres"};
altres[0].children=new Array();
altres[0].children[0]={caption:"Mapa base",checked:true,mapFileName:"map_referencia",layer:"referencia"};
altres[0].children[1]={caption:"Cadastre (DGC)",mapFileName:"map_cadastre",layer:"catastro"};
altres[0].children[2]={caption:"Topogr%E0fic (ICC)",mapFileName:"map_topoicc"};
altres[0].children[3]={caption:"Ortofotogr%E0fic (ICC)",mapFileName:"map_ortoicc"};
altres[0].children[4]={caption:"Cap",mapFileName:"map_cap"};
var defRefLyr=altres[0].children[0];
var isDefRefLyr=true;

tab_manager.prototype.add=function(_1,_2,_3){
var _4=this.tabs.length;
this.tabs[_4]=new Object();
this.tabs[_4].name=_1;
this.tabs[_4].title=_2;
this.tabs[_4].loaded=false;
if(_4==0){
this.active=_1;
}
if(_3){
this.tabs[_4].src=_3;
}
return true;
};
tab_manager.prototype.setTitle=function(_5,id){
oDiv=document.getElementById(id);
if(oDiv){
oDiv.onclick=function(e){
oTabManager.activate(_5);
};
oDiv.onmouseover=function(e){
if(_5!=oTabManager.active){
this.className="divTabTitle divTabTitleHover";
}
};
oDiv.onmouseout=function(e){
this.className=(_5==oTabManager.active)?"divTabTitle divTabTitleSelected":"divTabTitle";
};
}
};
tab_manager.prototype.build=function(){
oParent=document.getElementById(this.parent);
if(oParent){
oDiv=document.createElement("div");
oDiv.id="container";
oDiv.style.zIndex=5;
oDiv.style.position="relative";
oDiv.style.background=this.backgroundcolor;
oDiv.style.border="1px solid "+this.bordercolor;
oDiv.style.left=0;
oDiv.style.top=this.tab_height+this.spacing_height+"px";
oDiv.style.width=this.width+"px";
oDiv.style.height=this.height-this.tab_height-this.spacing_height+"px";
html="";
for(var _a=0;_a<this.tabs.length;_a++){
var _b=this.tabs[_a].name;
oTab=document.createElement("div");
oTab.style.position="absolute";
oTab.style.left=_a*(this.tab_width+this.spacing_width)+"px";
oTab.style.width=this.tab_width+"px";
oTab.style.height=this.tab_height+"px";
oTab.id="tab_"+_b;
oTab.name=_b;
oTab.style.zIndex=5;
oImg=document.createElement("img");
oImg.style.position="absolute";
oImg.parent=this;
oImg.id="img_"+_b;
oImg.name=_b;
oImg.style.left=0;
oImg.style.top=0;
oImg.style.width=this.tab_width+"px";
oImg.style.height=this.tab_height+"px";
oImg.src=this.tab_normal;
oImg.onclick=function(e){
this.parent.activate(this.name);
};
oImg.onmouseover=function(e){
if(this.name!=this.parent.active){
this.src=this.parent.tab_hover;
}
};
oImg.onmouseout=function(e){
this.src=(this.name==this.parent.active)?this.parent.tab_active:this.parent.tab_normal;
};
oTab.appendChild(oImg);
oTxt=document.createElement("div");
oTxt.parent=oImg;
oTxt.id="txtTab_"+_a;
oTxt.style.position="absolute";
oTxt.style.left=this.text_padding+"px";
oTxt.style.top=this.text_padding+"px";
oTxt.innerHTML="<b>"+this.tabs[_a].title+"</b>";
oTxt.onclick=function(e){
this.parent.onclick();
};
oTxt.onmouseover=function(e){
this.parent.onmouseover();
};
oTxt.onmouseout=function(e){
this.parent.onmouseout();
};
oTab.appendChild(oTxt);
try{
oImg.style.cursor="pointer";
oTxt.style.cursor="pointer";
}
catch(e){
oImg.style.cursor="hand";
oTxt.style.cursor="hand";
}
oParent.appendChild(oTab);
html+="<iframe id='"+_b+"' name='"+_b+"' allowtransparency='true' frameborder='no' ";
html+="style='position: absolute; border: 0px; left: "+this.padding+"px; top: "+this.padding+"px; ";
html+="width: "+(parseInt(oDiv.style.width)-2*this.padding)+"px; ";
html+="height: "+(parseInt(oDiv.style.height)-2*this.padding)+"px; display: \"\";'";
if(this.useMapOnLoad&&_b=="map"){
html+="onload='_onloaded()'></iframe>";
}else{
html+="></iframe>";
}
}
oDiv.innerHTML=html;
oParent.appendChild(oDiv);
for(var _a=this.tabs.length;_a>0;_a--){
this.activate(this.tabs[_a-1].name);
}
return true;
}
return false;
};
tab_manager.prototype.setfocus=function(_12){
el=document.getElementById(_12);
if(el){
el.focus();
}
};
tab_manager.prototype.activate=function(_13){
for(var _14=0;_14<this.tabs.length;_14++){
el=document.getElementById("divTabContent"+this.tabs[_14].name);
if(el){
div=document.getElementById("divTab"+this.tabs[_14].name);
if(this.tabs[_14].name==_13){
el.style.display="";
div.className="divTabTitle divTabTitleSelected";
}else{
el.style.display="none";
div.className="divTabTitle";
}
}
this.active=_13;
}
};
tab_manager.prototype.src=function(_15,src){
el=document.getElementById(_15);
if(el){
el.src=src;
}
};
tab_manager.prototype.get_tab_index=function(_17){
for(var _18=0;_18<this.tabs.length;_18++){
if(this.tabs[_18].name==_17){
return _18;
}
}
return false;
};
function tab_manager(_19,_1a,_1b){
this.parent=_19;
this.backgroundcolor="#FFFFFF";
this.bordercolor="#FFFFFF";
this.width=_1a;
this.height=_1b;
this.padding=10;
this.spacing_width=1;
this.spacing_height=-1;
this.text_padding=6;
this.tab_width=263;
this.tab_height=23;
this.tab_normal="img/tab.normal.png";
this.tab_active="img/tab.active.png";
this.tab_hover="img/tab.hover.png";
this.active=false;
this.useMapOnLoad=true;
this.tabs=Array();
}

tileCollection.prototype.addTile=function(id,_2,_3,_4){
var _5=this.tiles.length;
this.tiles[_5]=new Object();
this.tiles[_5].id=id;
this.tiles[_5].codes=_2;
this.tiles[_5].fields=_3;
this.tiles[_5].extent=_4;
return this.tiles[_5];
};
tileCollection.prototype.removeTile=function(id){
var _7=this.getTileIndex(id);
if(_7!==false){
this.tiles.splice(_7,1);
return _7;
}
return false;
};
tileCollection.prototype.clearTiles=function(){
this.tiles=new Array();
return this.tiles.length;
};
tileCollection.prototype.count=function(){
var _8=this.tiles.length;
return _8;
};
tileCollection.prototype.setProduct=function(_9,_a){
this.idProd=_9;
this.nameProd=_a;
};
tileCollection.prototype.setFormat=function(_b){
this.idFormat=_b;
};
tileCollection.prototype.getTileIndex=function(id){
for(var i=0;i<this.tiles.length;i++){
if(this.tiles[i].id==id){
return i;
}
}
return false;
};
tileCollection.prototype.tileExists=function(id){
for(var i=0;i<this.tiles.length;i++){
if(this.tiles[i].id==id){
return i;
}
}
return false;
};
tileCollection.prototype.tileExistsByCode=function(_10){
for(var i=0;i<this.tiles.length;i++){
if((this.tiles[i].codes[0].format==_10[0].format)&&(this.tiles[i].codes[0].code==_10[0].code)){
return i;
}
}
return false;
};
function tileCollection(){
this.idProd=false;
this.nameProd=false;
this.idFormat=false;
this.tiles=new Array();
}


