var maintitle="Wintershine";var logoimage="images/logogeom2.png";
var lgcd=new Array(5); lgcd[1]="en";lgcd[2]="zh";lgcd[3]="de";lgcd[4]="fr";lgcd[5]="it";var introlg="en";
var xmlcommon=loadxml('common.xml');var xmlsource;var pgcd;
var ntotsect=xmlcommon.getElementsByTagName("sect").length;
var xmlreserve=new Array(ntotsect);var xmlcheck=new Array(ntotsect)
for (i=0;i<ntotsect;i++) {xmlreserve[i]=new Array(5);xmlcheck[i]=new Array(5);}

function entersite(cd) {pgcd="#"+cd.substring(0,3)+"000"+cd.substring(3);location.hash=pgcd;document.getElementsByTagName("html")[0].style.overflow="auto";document.getElementById("intro").style.display="none";document.getElementById("preloader").style.display="none";setpage()}
function displaypop(id) {document.getElementById("desc"+id).style.display="block";}
function hydepop(id){document.getElementById("desc"+id).style.display="none"}
function introlgclk(cd) {for (i=1;i<=5;i++){document.getElementById(lgcd[i]+"visbox").style.display="none"}document.getElementById(cd+"visbox").style.display="block";introlg=cd}

var activecheck;
function manager() {if (pgcd!=location.hash){pgcd=location.hash;setpage()}activecheck=setTimeout("manager()",50);}
function setpage() {if (checkpgcd(pgcd)){document.getElementsByTagName("html")[0].style.overflow="auto";document.getElementById("intro").style.display="none";document.getElementById("preloader").style.display="none";putband();setsect();resetsect();if(pgcd.charAt(1)==ntotsect-1){showmap()} else {setfull()}} else {document.getElementsByTagName("html")[0].style.overflow="hidden";document.getElementById("intro").style.display="block";document.title="Wintershine/Index";introlgclk(introlg)}}
function checkpgcd(cd) {if (cd.length==9 && cd.charAt(0)=="#" &&!isNaN(cd.substring(1,7)) && isNaN(cd.substring(7,9))) {return true} else {return false}}
function setfull(){document.getElementById("smapcont").style.display="none";
document.getElementById("mainmenu").style.display="block";document.getElementById("main").style.display="block";window.scrollTo(0,0);
loadxmlsect(pgcd.charAt(1),pgcd.substring(7,9));
if(xmlsource.getElementsByTagName("pages")[0]){setmenu();resetmenu();setside();resetside();settitle();setmode();resetmode();settext()}
else {document.getElementById("mainmenu").innerHTML="";document.getElementById("sidemenu").innerHTML="";document.getElementById("maintext").innerHTML="Sorry, translation not yet available";document.getElementById("navmode").innerHTML="";}
}
/*_______________________________________LOAD XML__________________________________*/
function loadxml(url) {
if (navigator.appName!="Microsoft Internet Explorer") {var xmlhttp=null;
  if (window.XMLHttpRequest){/*FF, OP, SF*/ xmlhttp=new XMLHttpRequest();}
  if (xmlhttp!=null) {xmlhttp.open("get",url,false); xmlhttp.send(null);} else {alert("Your browser does not support XMLHTTP.");}
  return xmlhttp.responseXML.documentElement}
else {/*IEs only*/ var objvar=null;
 if (window.ActiveXObject) {objvar=new ActiveXObject("Microsoft.XMLDOM");} else {alert('Your browser cannot handle this script');}
 if (objvar!=null) {objvar.async=false; objvar.load(url);}
 return objvar;}
}
function loadxmlsect(r,lc) {switch(lc) {case "en": k=0;break; case "zh" : k=1;break;case "de" :k=2;break; case "fr":k=3;break;case "it":k=4;break;default:k=0};
if (xmlcheck[r][k]!=1) {xmlor=lc+xmlcommon.getElementsByTagName("sect")[r].getElementsByTagName("xmlfile")[0].firstChild.nodeValue;
xmlreserve[r][k]=loadxml(xmlor);xmlcheck[r][k]=1;xmlsource=xmlreserve[r][k];}
xmlsource=xmlreserve[r][k];}
function getSibling(node) {y=node.nextSibling;while (y!=null && y.nodeType!=1){y=y.nextSibling;}return y;}
function is_all_ws(nod){return !(/[^\t\n\r ]/.test(nod.data))}
function is_ignorable(nod){return ( nod.nodeType == 8)||( (nod.nodeType == 3) && is_all_ws(nod) )}
function getChild(nod){var res=nod.firstChild;while(res) {if(!is_ignorable(res)) return res;res = res.nextSibling;}return null;}

/*__________________________________TOP BAND____________________________*/
function putband() {
var wsbt=new Array(4);var wsblk=new Array(4);
document.getElementById("lout").style.fontSize=setdim();
t="<div class=\"log\"><img src=\""+logoimage+"\" width=\"100%\" onclick=\"location.hash=\'#start\';manager()\"/></div>";
t+="<div class=\"logotitle\">"+maintitle+"<div id=\"stit\" class=\"sublogotitle\"></div></div>";
t+="<div class=\"rmenu\"><ul>";for (i=0;i<ntotsect;i++) {t+="<li  id=\"sect" +i +"\" onclick=\"clksect("+i+")\"></li>";}t+="</ul></div>";
t+="<div class=\"flags\"><ul>";for (i=1;i<=5;i++) {t+="<li title=\""+lgcd[i]+"\" style=\"background-position:"+(-16*(i-1))+"px\" onclick=\"clklang(\'"+lgcd[i]+"\')\" ></li>"} t+="</ul></div>";
document.getElementById("topband").innerHTML = t;
var f="<span id=\"timer\"></span>"; document.getElementById("bottomband").innerHTML = f;showtime();
}
function setdim() {smscr=800;lgscr=1280;smfnt=10;lgfnt=12;
fntsize=((lgfnt-smfnt)*screen.width+(smfnt*lgscr-lgfnt*smscr))/(lgscr-smscr);
fntsize=Math.floor(fntsize)+"px";return fntsize;}
function showtime() {var today=new Date(); document.getElementById('timer').innerHTML=today.toLocaleString(); t=setTimeout('showtime()',500);}

function clksect(r) {rinit=pgcd.charAt(1);pgcd=pgcd.substring(0,1)+r+"00000"+pgcd.substring(7,9);location.hash=pgcd;setsect();resetsect();
if(pgcd.charAt(1)==ntotsect-1){showmap()} else {document.getElementById("smap"+pgcd.substring(7,9)).style.display="none";
loadxmlsect(r,pgcd.substring(7,9));setfull()}}

function clklang(lc) {pgcd=pgcd.substring(0,7)+lc;location.hash=pgcd;setsect();introlg=lc;
if(pgcd.charAt(1)==ntotsect-1){showmap()} else {setfull()}}

function setsect() {var wsbt=new Array(ntotsect);var wsblk=new Array(ntotsect);
document.getElementById("stit").innerHTML=xmlcommon.getElementsByTagName("sect")[pgcd.substring(1,2)].getElementsByTagName("stit")[0].firstChild.nodeValue;
/*for (i=0;i<ntotsect;i++) {
document.getElementById("sect"+i).innerHTML=xmlcommon.getElementsByTagName("sect")[i].getElementsByTagName(pgcd.substring(7,9)+"tit")[0].firstChild.nodeValue;}*/
}

function resetsect() {for (r=0;r<ntotsect;r++) {document.getElementById("sect"+r).className="rmenubas";};
document.getElementById("sect"+pgcd.charAt(1)).className="rmenuact";}

/*________________________________SET MENU_________________________________________*/
function setmenu() {nod=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[0];p=0;s=1;last="p";z="";
x="<div class=\"pmenu\"><ul>";
while(nod!=null) {if(nod.getAttribute("pos")<=1) {
if(nod.getAttribute("pos")=="0"){
 if (p>0) {while (z.search("SWW")>0) {z=z.replace("SWW",(100/(s-1)))}};
 x+="<li id=\"pmenu"+p+"\" style=\"width:PWW%\"";
 x+=" onmouseover=\"displaymain(\'"+p +"\')\" onclick=\"clkmenu(\'"+p+ "0\')\">";
 x+=nod.firstChild.nodeValue+"</li>";
 if (last=="s") {z+="</ul></div>"};last="p";p=p+1;s=1;}
if(nod.getAttribute("pos")=="1"){p=p-1;
 if (last=="p") {z+="<div id=\"smenu" + p + "0\" class=\"smenu\" style=\"display:none\"><ul>";}
 z+="<li id=\"smenu" + p + s + "\" class=\"smenu\" style=\"width:SWW%\"";
 z+=" onmouseover=\"displaysub(\'smenu"+p +s +"\')\" onmouseout=\"hydesub(\'smenu"+p +s +"\')\"";
 z+=" onclick=\"clkmenu(\'"+p + s + "\')\">";
 z+=nod.firstChild.nodeValue+"</li>";last="s";p=p+1;s=s+1;}
} nod=getSibling(nod)}; x+="</ul></div>";
while (x.search("PWW")>0) {x=x.replace("PWW",(100/p))};while (z.search("SWW")>0) {z=z.replace("SWW",(100/(s-1)))};
document.getElementById("mainmenu").innerHTML=x+z;
}
function clkmenu(ps) {pgcd=pgcd.substring(0,2)+ps+"00"+pgcd.substring(6,9);location.hash=pgcd;
resetmenu();setside();resetside();settitle();setmode();resetmode();settext();}
function displaymain(n) {p=0;while (document.getElementById("pmenu" +p)!=null) {
 if (document.getElementById("smenu" +p +"0")) {document.getElementById("smenu" +p +"0").style.display="none";}
document.getElementById("pmenu" +p).className="pmenubas"; p=p+1};
document.getElementById("pmenu"+pgcd.charAt(2)).className="pmenuact";
document.getElementById("pmenu"+n).className="pmenuhov";
if(document.getElementById("smenu" +n +"0")){document.getElementById("smenu" +n +"0").style.display="inline";}}
function displaysub(xid) {if (pgcd.charAt(3)!="0") {document.getElementById("smenu"+pgcd.charAt(2)+pgcd.charAt(3)).className="smenuact"}}
function hydesub(xid) {document.getElementById(xid).className="smenubas";if (pgcd.charAt(3)!="0") {document.getElementById("smenu"+pgcd.charAt(2)+pgcd.charAt(3)).className="smenuact"}}
function resetmenu() {p=0; while(document.getElementById("pmenu" +p)!=null) {document.getElementById("pmenu"+p).className="pmenubas";
 if(document.getElementById("smenu"+p +"0")) {document.getElementById("smenu"+p +"0").style.display="none";s=1;
 while(document.getElementById("smenu" +p+s)!=null) {document.getElementById("smenu"+p+s).className="smenubas";s=s+1}};p=p+1;}
if(document.getElementById("pmenu"+pgcd.charAt(2))) {document.getElementById("pmenu"+pgcd.charAt(2)).className="pmenuact";
if(document.getElementById("smenu"+pgcd.charAt(2)+"0")) {document.getElementById("smenu"+pgcd.charAt(2)+"0").style.display="inline";}
if (pgcd.charAt(3)!="0") {document.getElementById("smenu"+pgcd.charAt(2)+pgcd.charAt(3)).className="smenuact";}
}}
/*________________________________SET SIDE__________________________*/
function setside() {x="";nod=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[0];s=0;c=0;last="p";
if (pgcd.substring(3,6)=="000") {clev=1;}else {clev=2};
i=0;while(nod!=null && i<=pgcd.charAt(2)) {if(nod.getAttribute("pos")==0) {i=i+1;};nod=getSibling(nod);}
j=0;if(clev==2) {while(nod!=null && j<pgcd.charAt(3)) {if(nod.getAttribute("pos")==1) {j=j+1;};nod=getSibling(nod);}}
while(nod!=null && nod.getAttribute("pos")!=clev-1) {
if(nod.getAttribute("pos")==clev) {
 if (last=="c") {x+="</ul></div>";c=0;};last="s";s=s+1;
 if(clev==1) {scf=s+"00"} else {scf=pgcd.charAt(3)+s+"0"};
 x+="<div id=\"cmenu"+s+"\"  class=\"cmenu\" onmouseover=\"overcmenu(\'"+s+"\')\"";
 x+=" onclick=\"clkside(\'"+scf+"\')\">";
 x+=nod.firstChild.nodeValue+"</div>";}
if(nod.getAttribute("pos")==clev+1) {
 if(last=="s") {x+="<div id=\"cmenutab"+s+"\" class=\"fmenu\" style=\"display:none\"><ul>"}last="c";c=c+1;
 if(clev==1) {scf=s+""+c+"0"} else {scf=pgcd.charAt(3)+s+""+c};
 x+="<li id=\"fmenu"+s+c+"\" onclick=\"clkside(\'" +scf+"\')\">"+nod.firstChild.nodeValue+"</li>"}
nod=getSibling(nod);}if (last=="c") {x+="</div>"}
document.getElementById("sidemenu").innerHTML=x;
}
function clkside(scf) {pgcd=pgcd.substring(0,3)+scf+pgcd.substring(6,9);location.hash=pgcd;resetmenu();setside();resetside();settitle();setmode();resetmode();settext()}
function overcmenu(n) {document.getElementById("cmenu"+n).className="cmenu cmenuhov";
 if(document.getElementById("cmenutab"+n)) {document.getElementById("cmenutab"+n).style.display="block";}}
function resetside() {c=1;while(document.getElementById("cmenu" +c)!=null) {document.getElementById("cmenu"+c).className="cmenu cmenubas";
 if(document.getElementById("cmenutab"+c)) {document.getElementById("cmenutab"+c).style.display="none";}
 f=1; while(document.getElementById("fmenu" +c+f)!=null) {document.getElementById("fmenu"+c+f).className="fmenubas";f=f+1};c=c+1;}
 if (pgcd.charAt(4)!="0" && document.getElementById("cmenu"+pgcd.charAt(4))) {document.getElementById("cmenu"+pgcd.charAt(4)).className="cmenu cmenuact";
 if(document.getElementById("cmenutab"+pgcd.charAt(4))) {document.getElementById("cmenutab"+pgcd.charAt(4)).style.display="block";}
 if (pgcd.charAt(5)!="0" && document.getElementById("fmenu"+pgcd.charAt(4)+pgcd.charAt(5))) {document.getElementById("fmenu"+pgcd.charAt(4)+pgcd.charAt(5)).className="fmenuact"}
}}
/*___________________________SET TITLE_____________________________*/
function settitle() {nod=gettopage();document.title=maintitle+": "+nod.firstChild.nodeValue;}
/*___________________________SET MODE_____________________________*/
var mflag;
function setmode() {mflag=0;
if (xmlsource.getElementsByTagName("views")[0]){mflag=1;x="<div class=\"mod\"><span>VIEWS</span><ul>";
for (m=0;m<xmlsource.getElementsByTagName("views")[0].getElementsByTagName("mode").length;m++){
x+="<li id=\"mod"+m+"\" onclick=\"clkmode("+m+")\">";
x+=xmlsource.getElementsByTagName("views")[0].getElementsByTagName("mode")[m].firstChild.nodeValue+"</li>";};x+="</ul></div>";
document.getElementById("navmode").innerHTML=x;}else{document.getElementById("navmode").innerHTML="";}
}
function clkmode(m) {pgcd=pgcd.substring(0,6)+m+pgcd.substring(7,9);location.hash=pgcd;resetmode();settext()}
function resetmode() {if (mflag==1) {xmlpage=gettopage();
for (m=0;m<xmlsource.getElementsByTagName("views")[0].getElementsByTagName("mode").length;m++){document.getElementById("mod"+m).className="moddwn"}
for (c=0;c<xmlpage.getElementsByTagName("cont").length;c++) {m=xmlpage.getElementsByTagName("cont")[c].getAttribute("mod");
document.getElementById("mod"+m).className="modbas"};document.getElementById("mod"+pgcd.charAt(6)).className="modact";
}}
/*____________________________________GET TO PAGE____________________________*/
function gettopage(){nod=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[0];p=0;s=0;c=0;f=0;
while (nod!=null && p<pgcd.charAt(2)) {nod=getSibling(nod);if (nod.getAttribute("pos")==0) {p=p+1}}
while (nod!=null && s<pgcd.charAt(3)) {nod=getSibling(nod);if (nod.getAttribute("pos")==1) {s=s+1}}
while (nod!=null && c<pgcd.charAt(4)) {nod=getSibling(nod);if (nod.getAttribute("pos")==2) {c=c+1}}
while (nod!=null && f<pgcd.charAt(5)) {nod=getSibling(nod);if (nod.getAttribute("pos")==3) {f=f+1}}
return nod;
}
/*___________________________________SET TEXT__________________________________*/
function settext() {nod=gettopage().getElementsByTagName("cont")[0];ck=0;x="";nid=0;var lout="";
while (nod!=null && nod.nodeName=="cont" && ck==0) {
if(pgcd.charAt(6)==0 || nod.getAttribute("mod")==pgcd.charAt(6)){ck=1} else {nod=getSibling(nod)}}
if (ck==1){lout=nod.getAttribute("lout");while(lout.length>0){ncol=0;nhgt="";
if(lout.search("#")>0) {poshash=lout.search("#")} else {poshash=lout.length};posasl=lout.search("h");
if(posasl>0 && posasl<poshash){posdiv=posasl;for (i=posasl+1;i<poshash;i++) {nhgt=nhgt+lout.charAt(i)};hgtstyle=";height:"+nhgt+"em"}
else{posdiv=poshash;hgtstyle=""};
for (i=0;i<posdiv;i++) {ncol=ncol+Number(lout.charAt(i))}
if(posdiv==1){for (i=0;i<ncol;i++) {nid=nid+1;x+="<div id=\"e"+nid+"\" class=\"divlout\"></div>"}}
else {x+="<div class=\"loutrow\">"; 
 for (i=0;i<posdiv;i++) {nid=nid+1; x+="<div id=\"e"+nid+"\" class=\"divlout\" style=\"width:"+(100/ncol*lout.charAt(i)-6)+"%"+hgtstyle+"\"></div>"}; 
 x+="</div>"}
lout=lout.substring(poshash+1,lout.length);}
x+="<div id=\"topbut\" onclick=\"window.scrollTo(0,0)\">⤴</div>";
document.getElementById("maintext").innerHTML=x;getcontent(nod);}
else{document.getElementById("maintext").innerHTML="<div style=\"text-align:center\">Sorry: page not available</div>";}}

var nid=0;
function getcontent(nod) {ev=nod.getElementsByTagName('*')[0];nid=0;
elink=nod.getElementsByTagName("qlk");nlk=0;
while(ev!=null) {nck=0;x=getelem(ev);
while(x.search("QKS")>0 && nlk<elink.length) {if (elink[nlk].firstChild.nodeValue.charAt(0)=="#"){
x=x.replace("QKS","<span class=\"qks\" onclick=\"clkqlk(\'"+elink[nlk].firstChild.nodeValue+"\')\">");x=x.replace("QKF","</span>")}
else {x=x.replace("QKS","<a href=\""+elink[nlk].firstChild.nodeValue+"\" target=\"_blank\">");x=x.replace("QKF","</a>");}
nlk=nlk+1;}
if (nck==1) {document.getElementById("e"+nid).innerHTML=x;}
ev=getSibling(ev);
}}

function getelem(ev) {
if (ev.nodeName=="titl") {x="<div class=\"big\" style=\"padding-bottom:0px\">"+ev.firstChild.nodeValue+"</div>";nid=nid+1;nck=1}
else if (ev.nodeName.charAt(0)=="x") {x="<div class=\""+ev.nodeName.substring(1,4)+"\">"+ev.firstChild.nodeValue+"</div>";nid=nid+1;nck=1}

else if (ev.nodeName=="imag") 
  {x=ev.firstChild.nodeValue;nd=x.search("#");im=x.substring(0,nd);lim=x.substring(nd+5);
   if (x.length>nd+4) {
    if (lim.substring(0,4)=="http"){z1="<a href=\""+lim+"\" target=\"_blank\">";z2="  title=\""+lim+"\"></a>";}
    else {z1="<span style=\"cursor:pointer\" onclick=\"clkqlk(\'"+lim+"\')\">";z2="</span>"}
   }
   else {z1=""; z2=" title=\"click to enlarge\" onclick=\"showimage(\'"+im+"\')\">"}
  x=z1 +"<img src=\"" +im +"\" class=\"imstd\" style=\"width:" +(Number(x.substring(nd+1,nd+4))) +"%\""+z2;
  if(document.getElementById("e"+(nid+1))){document.getElementById("e"+(nid+1)).style.textAlign="center"}
  nid=nid+1;nck=1;
 }

else if (ev.nodeName=="sprite") {ref=ev.firstChild.nodeValue;imadr=ref.substring(0,ref.search("#"));dim=ref.substring(ref.search("#"));
imwidth=dim.substring(1,dim.search("h"));imheight=dim.substring(dim.search("h")+1,dim.search("r"));
pr=dim.substring(dim.search("r")+1,dim.search("c"));pc=dim.substring(dim.search("c")+1);
x="<div class=\"sprite\" style=\"background-image:url("+imadr+");width:"+imwidth+"px;height:"+imheight+"px;background-position:"+(-(pc-1)*imwidth)+"px "+(-(pr-1)*imheight)+"px\"></div>";nid=nid+1;nck=1}

else if (ev.nodeName=="hovgall") {x="";
  imthum=ev.getElementsByTagName("imweb")[0].firstChild.nodeValue;imadr=imthum.substring(0,imthum.search("#"));dim=imthum.substring(imthum.search("#"));
  oneimwidth=dim.substring(1,dim.search("h"));oneimheight=dim.substring(dim.search("h")+1,dim.search("r"));
  nr=dim.substring(dim.search("r")+1,dim.search("r")+2);nc=dim.substring(dim.search("c")+1,dim.search("c")+2);
  imorig=ev.getElementsByTagName("imorig")[0].firstChild.nodeValue;
  imadb=imorig.substring(0,imorig.search("#"));dimb=imorig.substring(imorig.search("#"));
  imorigwidth=dimb.substring(1,dimb.search("h"));imorigheight=dimb.substring(dimb.search("h")+1);
  for (j=0;j<nr;j++){for (k=0;k<nc;k++){
  x+="<div  class=\"gall\" style=\"width:"+oneimwidth+"px;height:"+oneimheight+"px;\">";
  x+="<div style=\"background-image:url("+imadr+");width:"+(oneimwidth)+"px;height:"+(oneimheight)+"px;background-position:"+(-oneimwidth*k)+"px "+(-oneimheight*j)+"px;\" onmouseover=\"displayphoto("+j+","+k+")\" onmouseout=\"hydephoto("+j+","+k+")\"></div>";
  x+="<div id=\"imorig"+j+""+k+"\" class=\"imgalorig\" style=\"width:"+imorigwidth+"px;height:"+imorigheight+"px\" onmouseover=\"displayphoto("+j+","+k+")\" onmouseout=\"hydephoto("+j+","+k+")\"><div style=\"background-image:url("+imadb+");background-position:"+(-imorigwidth*k)+"px "+(-imorigheight*j)+"px;width:"+imorigwidth+"px;height:"+imorigheight+"px\"></div><div class=\"imtit\">Title:una bella giornata di sole<br/>link:<span class=\"imtitlk\">http://www.tomorrow.net/en/</span></div></div>";
  x+="</div>";
  }}nid=nid+1;nck=1}

else if (ev.nodeName=="fixgall") {x="";
  imthum=ev.getElementsByTagName("imweb")[0].firstChild.nodeValue;imadr=imthum.substring(0,imthum.search("#"));dim=imthum.substring(imthum.search("#"));
  oneimwidth=dim.substring(1,dim.search("h"));oneimheight=dim.substring(dim.search("h")+1,dim.search("r"));
  nr=dim.substring(dim.search("r")+1,dim.search("r")+2);nc=dim.substring(dim.search("c")+1,dim.search("c")+2);
  imorig=ev.getElementsByTagName("imorig")[0].firstChild.nodeValue;
  imadb=imorig.substring(0,imorig.search("#"));dimb=imorig.substring(imorig.search("#"));
  imorigwidth=dimb.substring(1,dimb.search("h"));imorigheight=dimb.substring(dimb.search("h")+1);

  y="<div style=\"float:right;width:"+imorigwidth+"px;height:"+(50+Number(imorigheight))+"px\">";
  for (j=0;j<nr;j++){for (k=0;k<nc;k++){
  y+="<div id=\"imorig"+j+""+k+"\" style=\"position:absolute;display:none;width:"+imorigwidth+"px;height:"+(50+Number(imorigheight))+"px\">";
  y+="<div style=\"position:absolute\"><div style=\"background-image:url("+imadb+");background-position:"+(-imorigwidth*k)+"px "+(-imorigheight*j)+"px;width:"+imorigwidth+"px;height:"+imorigheight+"px\"></div>";
  y+="<div class=\"imtit\">Title:una bella giornata di sole<br/>link:<span class=\"imtitlk\">http://www.tomorrow.net/en/</span></div></div>";
  y+="</div>";
  x+="<div class=\"gall\" style=\"width:"+oneimwidth+"px;height:"+oneimheight+"px;\">";
  x+="<div style=\"background-image:url("+imadr+");width:"+(oneimwidth)+"px;height:"+(oneimheight)+"px;background-position:"+(-oneimwidth*k)+"px "+(-oneimheight*j)+"px;\" onmouseover=\"displayphotofix("+j+","+k+","+nr+","+nc+")\"></div>";
  x+="</div>";
  }}nid=nid+1;nck=1;  y+="</div>";x=y+x;}

else if (ev.nodeName=="contgall") {x="";

  imorig=ev.getElementsByTagName("imorig")[0].firstChild.nodeValue;
  imadb=imorig.substring(0,imorig.search("#"));dimb=imorig.substring(imorig.search("#"));
  imorigwidth=dimb.substring(1,dimb.search("h"));imorigheight=dimb.substring(dimb.search("h")+1,dimb.search("r"));
  nr=dimb.substring(dimb.search("r")+1,dimb.search("r")+2);nc=dimb.substring(dimb.search("c")+1,dimb.search("c")+2);

  for (j=0;j<nr;j++){for (k=0;k<nc;k++){
  x+="<div id=\"imorig"+j+""+k+"\" style=\"width:"+imorigwidth+"px;height:"+(50+Number(imorigheight))+"px\">";
  x+="<div style=\"position:absolute\"><div style=\"background-image:url("+imadb+");background-position:"+(-imorigwidth*k)+"px "+(-imorigheight*j)+"px;width:"+imorigwidth+"px;height:"+imorigheight+"px\"></div>";
  x+="<div class=\"imtit\">Title:una bella giornata di sole<br/>link:<span class=\"imtitlk\">http://www.tomorrow.net/en/</span></div></div>";
  x+="</div>";

  }}nid=nid+1;nck=1}

x=x.replace(new RegExp("QEE","g"),"<br/>");x=x.replace(new RegExp("QHR","g"),"<hr/>");x=x.replace(new RegExp("QLP","g"),"</div><div class=\"lit\">");x=x.replace(new RegExp("QMP","g"),"</div><div class=\"mid\">");x=x.replace(new RegExp("QBP","g"),"</div><div class=\"big\">");
x=x.replace(new RegExp("QLS","g"),"<ul><li class=\"lit\">");x=x.replace(new RegExp("QMS","g"),"<ul><li class=\"mid\">");x=x.replace(new RegExp("QBS","g"),"<ul><li class=\"big\">");x=x.replace(new RegExp("QLB","g"),"</li><li class=\"lit\">");x=x.replace(new RegExp("QMB","g"),"</li><li class=\"mid\">");x=x.replace(new RegExp("QBB","g"),"</li><li class=\"big\">");x=x.replace(new RegExp("QBF","g"),"</li></ul>");

return x;
}

function clkqlk(qlk) {pgcd=qlk;location.hash=pgcd;setsect();resetsect();if(pgcd.charAt(1)==ntotsect-1){showmap()} else {loadxmlsect(pgcd.charAt(1),pgcd.substring(7,9));setfull()}}

function showimage(im){window.open(im,'newwind','scrollbar=yes,height=400,width=800')}
function displayphoto(j,k) {document.getElementById("imorig"+j+k).style.display="block"}
function hydephoto(j,k) {document.getElementById("imorig"+j+k).style.display="none"}
function displayphotofix(j,k,nr,nc) {for(r=0;r<nr;r++){for(c=0;c<nc;c++){
document.getElementById("imorig"+r+c).style.display="none"}}document.getElementById("imorig"+j+k).style.display="block"}

/*________________________________BUILD SITEMAP_____________________________________*/
var mapflag=new Array(5); for (i=0;i<5;i++) {mapflag[i]=0;}
function showmap() {document.title=maintitle+"/"+xmlcommon.getElementsByTagName("sect")[pgcd.substring(1,2)].getElementsByTagName(pgcd.substring(7,9)+"tit")[0].firstChild.nodeValue;document.getElementById("smapcont").style.display="block";
k=0;for (i=1;i<=5;i++){document.getElementById("smap"+lgcd[i]).style.display="none";if(pgcd.substring(7,9)==lgcd[i]){k=i-1}}
document.getElementById("smap"+pgcd.substring(7,9)).style.display="block";document.getElementById("mainmenu").style.display="none";document.getElementById("main").style.display="none";
if (mapflag[k]==0){x=""; for (r=0;r<ntotsect-1;r++) {loadxmlsect(r,pgcd.substring(7,9));
if(xmlsource.getElementsByTagName("pages")[0]){
nod=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[0];p=-1;
x+="<div class=\"sitemap\" style=\"width:"+(100/(ntotsect-1)-0.2)+"%\">"; 
x+="<div class=\"rstm\">"+xmlcommon.getElementsByTagName("sect")[r].getElementsByTagName(pgcd.substring(7,9)+"tit")[0].firstChild.nodeValue+"</div>";
while(nod!=null) {if(nod.nodeName=="pg") {if(nod.getAttribute("pos")=="0"){p=p+1;s=0;
x+="<div class=\"pstm\" id=\"map"+r+p+"000\" onclick=\"clkmap(\'"+r+p+"000\')\">";x+=nod.firstChild.nodeValue+"</div>"}
else if(nod.getAttribute("pos")=="1"){s=s+1;c=0;
x+="<div class=\"sstm\" id=\"map"+r+p+s+"00\" onclick=\"clkmap(\'"+r+p+s+"00\')\">";x+=nod.firstChild.nodeValue+"</div>"}
else if(nod.getAttribute("pos")=="2"){c=c+1;f=0;
x+="<div class=\"cstm\" id=\"map"+r+p+s+c+"0\" onclick=\"clkmap(\'"+r+p+s+c+"0\')\">";x+=nod.firstChild.nodeValue+"</div>"}
else if(nod.getAttribute("pos")=="3"){f=f+1;
x+="<div class=\"fstm\" id=\"map"+r+p+s+c+f+"\" onclick=\"clkmap(\'"+r+p+s+c+f+"\')\">";x+=nod.firstChild.nodeValue+"</div>"}
}nod=getSibling(nod)} x+="</div>";document.getElementById("smap"+pgcd.substring(7,9)).innerHTML=x;mapflag[k]=1;
}}}}
function clkmap(rpscf) {pgcd=pgcd.substring(0,1)+rpscf+pgcd.substring(6,9);location.hash=pgcd;loadxmlsect(pgcd.charAt(1),pgcd.substring(7,9));
document.getElementById("map"+rpscf).className=document.getElementById("map"+rpscf).className+" mapvisited";
document.getElementById("smap"+pgcd.substring(7,9)).style.display="none";window.scrollTo(0,0);setsect();resetsect();setfull()};

/*_____________________________PRELOADER___________________________*/
function preloader() {if (location.hash==""){x="";for (r=0;r<1;r++) {loadxmlsect(r,"en");
for (i=0;i<xmlsource.getElementsByTagName("imag").length;i++){x+="<img src=\""+xmlsource.getElementsByTagName("imag")[i].firstChild.nodeValue.substring(0,xmlsource.getElementsByTagName("imag")[i].firstChild.nodeValue.search("#"))+"\" />";}
document.getElementById("preloader").innerHTML=x;}}}
/*_____________________________PRINTABLE___________________________*/
function openprint(r,cd) {
var printwin=window.open('','null','width=1000,height=1200,scrollbars=yes,menubar=yes');
printwin.document.write("<script type=\"text/javascript\">location.href=\"printable.html#"+r+cd+"\";</script>");}

function managerp(rcd) {pgcd="#"+rcd.charAt(1)+"00000"+rcd.substring(2);putbandp();loadxmlsect(pgcd.charAt(1),pgcd.substring(7,9));setfullp()}

function putbandp() {
subtit=xmlcommon.getElementsByTagName("sect")[pgcd.substring(1,2)].getElementsByTagName("stit")[0].firstChild.nodeValue;
t="<div class=\"logotitle\">"+maintitle+"<div id=\"stit\" class=\"sublogotitle\">"+subtit+"</div></div>";
t+="<div class=\"log\"><img src=\""+logoimage+"\" width=\"80px\"/></div>";
document.getElementById("topband").innerHTML = t;
tc="<img src=\"images/logicoclearBack.jpeg\" width=\"20%\" />";
document.getElementById("cover").innerHTML=tc;
}

function setfullp(){zbr="<div style=\"width:100%;page-break-after:always;\">&nbsp;</div>";
document.getElementById("maintext").innerHTML+=zbr;
for (i=0;i<xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg").length;i++)
{page=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[i];
zsep="<div class=\"separpg\">Page: "+(i+1)+" - "+page.firstChild.nodeValue+"</div>";
if(page.getElementsByTagName("cont")[0]!=null){document.getElementById("maintext").innerHTML+=zsep+settextp(page)+zbr;}}}

function settextp(page) {nod=page.getElementsByTagName("cont")[0];ck=0;x="";var lout="";
while (nod!=null && nod.nodeName=="cont" && ck==0) {if(pgcd.charAt(6)==0 || nod.getAttribute("mod")==pgcd.charAt(6)){ck=1} else {nod=getSibling(nod)}}
if (ck==1){lout=nod.getAttribute("lout");ev=nod.getElementsByTagName('*')[0];
while(lout.length>0){ncol=0;nhgt="";
if(lout.search("#")>0) {poshash=lout.search("#")} else {poshash=lout.length};posasl=lout.search("h");
if(posasl>0 && posasl<poshash){posdiv=posasl;for (j=posasl+1;j<poshash;j++) {nhgt=nhgt+lout.charAt(j)};hgtstyle=";height:"+nhgt+"em"}
else{posdiv=poshash;hgtstyle=""};
for (j=0;j<posdiv;j++) {ncol=ncol+Number(lout.charAt(j))}
if(posdiv==1){for (j=0;j<ncol;j++) {x+="<div class=\"divlout\">"+getelem(ev)+"</div>";ev=getSibling(ev)}}
else {x+="<div class=\"loutrow\">"; 
 for (j=0;j<posdiv;j++) {x+="<div class=\"divlout\" style=\"width:"+(100/ncol*lout.charAt(j)-6)+"%"+hgtstyle+"\">"+getelem(ev)+"</div>";ev=getSibling(ev);}; 
 x+="</div>"}
lout=lout.substring(poshash+1,lout.length);}
return x;}
else{return ""}
}
/*_____________________________SEARCHER___________________________*/

function searchstring(form) {xwrite="";xlkcurr="";currpgpath="";p=-1;s=0;c=0;f=0;m=0;strcheck=-1;strresult=0;
var xf=form.inputbox.value;
if (xf!=""){
var xfreg=new RegExp (xf,"i");
var searchwin=window.open('','null','width=500,height=600,scrollbars=yes,menubar=yes,status=0');
for (r=0;r<ntotsect-1;r++) {loadxmlsect(r,introlg);
if(xmlsource.getElementsByTagName("pages")[0]){nod=xmlsource.getElementsByTagName("pages")[0].getElementsByTagName("pg")[0];p=-1;
while(nod!=null) {
if(nod.nodeName=="pg") {
if(nod.getAttribute("pos")=="0"){p=p+1;s=0;currp="➔"+nod.firstChild.nodeValue;currs="";currc="";currf=""}
else if(nod.getAttribute("pos")=="1"){s=s+1;c=0;currs="➔"+nod.firstChild.nodeValue;currc="";currf=""}
else if(nod.getAttribute("pos")=="2"){c=c+1;f=0;currc="➔"+nod.firstChild.nodeValue;currf=""}
else if(nod.getAttribute("pos")=="3"){f=f+1;currf="➔"+nod.firstChild.nodeValue}
for (j=0;j<nod.getElementsByTagName("cont").length;j++){nodarr=nod.getElementsByTagName("cont")[j].getElementsByTagName('*');
for (k=0;k<nodarr.length;k++){ckk=getChild(nodarr[k]).nodeValue;if(ckk!=null){cks=ckk.search(xfreg)};
if(ckk!=null && cks>0){strcheck=strcheck+1;if(strcheck==0){strdesc="..."+ckk.substring(cks-150,cks+150)+"..."}}}}
xlkcurr="#"+r+p+s+c+f+"0";currpgpath=currp+currs+currc+currf;
}nod=getSibling(nod);
if (strcheck>=0){xwrite+="<div class=\"searpat\" onclick=\"clksearchlk(\'"+xlkcurr+introlg+"\')\">"+currpgpath+"</div><div class=\"seardsc\">"+strdesc+"</div>";strresult=1;}
strcheck=-1;
}}}
xbeg="<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html style=\"overflow:auto\"><head><link rel=\"stylesheet\" type=\"text/css\" href=\"datastyle.css\"/><script type=\"text/javascript\" src=\"getall.js\"></script><title>Search Results</title></head><body><div class=\"seartit\">--"+xf+"--";
if(strresult>0) {xbeg+=" was found in the following pages</div>"} else {xbeg+=" not found</div>"};xend="<br/><br/></body></html>";
xwrite=xbeg+xwrite+xend;
xwrite=xwrite.replace(new RegExp(xf,"gi"),"<span class=\"searevid\">"+xf+"</span>");
searchwin.document.write(xwrite);
}searchwin.document.close();
}
function clksearchlk(ref) {window.close();window.opener.location.hash=ref;}







