var AImatge=850; 
var AltImatge=487; 
var marge=20; 
var aleatori; 
var loop=true; 

var IE = document.all?true:false;
var ns4=false; var ie4=false; var standard=false;

if (document.getElementById) {
  standard=true
} else if (document.all) {
  ie4=true
} else if (document.layers) {
  ns4=true
} else {
}

function moveLayer(nomCapa,x,y) {
  if (ns4) { document.layers[nomCapa].left=x; document.layers[nomCapa].top=y; }
  if (ie4) { document.all[nomCapa].style.left=x; document.all[nomCapa].style.top=y; }
  if (standard) { document.getElementById(nomCapa).style.left=x; document.getElementById(nomCapa).style.top=y; }
}

function viewLayer(nomCapa,accio) {
  if (ns4) document.layers[nomCapa].visibility = accio;
  if (ie4) document.all[nomCapa].style.visibility = accio;
  if (standard) document.getElementById(nomCapa).style.visibility = accio;
}

function iRandom(nom,tope) {
  var src = 'img/' + url + '_1';
  var nom_src = '<div id="' + nom + '"><img src="' + src + '.jpg" id="' + nom + nom + '" width="'+ AImatge +'" height="'+ AltImatge +'" /></div>';
  aleatori=1;
  return nom_src;
}

function iRandom_(nom,tope) {
  var src = 'img/' + url + '_1';
  var nom_src = '<div id="' + nom + '"><img src="img/arribarFons.jpg" id="' + nom + nom + '" width="'+ AImatge +'" height="'+ AltImatge +'" /></div>';
  return nom_src;
}

function resize() {
  if (ns4) {location.reload(); } else {init(); }
}

function resize1() {
  if (ns4) {location.reload(); } else {init2(); }
}

function init1(com) {

  AmpleMenu=parseInt(document.getElementById('root').offsetWidth);
  AmpleTitol=0;
  document.getElementById('root').style.clip = "rect(0px " + (AImatge-AmpleTitol) + "px 35px 0px)"
  //document.body.style.overflow='hidden';
  if (ns4) {
	var finestrax = window.innerWidth; 
	var finestray = window.innerHeight; 
  } else {
	var finestrax = document.body.clientWidth; 
	var finestray = document.body.clientHeight;
  }
  Centrat=Math.floor((finestrax - AImatge) /2); if (Centrat<0) Centrat=0;
  Vertical=((finestray - AltImatge) /2)+10; if (Vertical<0) Vertical=0;
  moveLayer('root', Centrat+AmpleTitol, 400+Vertical); 
  moveLayer('Menu', Centrat+40, 500+Vertical); 
  moveLayer('imatge', Centrat-20, Vertical+1);
  moveLayer('txtSubmenu', Centrat-20, Vertical + 540); 
  moveLayer('pdfMenu', Centrat+550, Vertical-35)

  viewLayer('root','visible'); 
  viewLayer('Menu','visible'); 
  viewLayer('txtSubmenu','visible'); 
  viewLayer('imatge','visible');
  viewLayer('pdfMenu','visible');

  posMenu = Centrat + AmpleTitol;
  
 	  

  if (!IE) document.captureEvents(Event.MOUSEMOVE)
    
  
}


function init(com) {
  AmpleMenu=parseInt(document.getElementById('root').offsetWidth);
  AmpleTitol=0;
  document.getElementById('root').style.clip = "rect(0px " + (AImatge-AmpleTitol) + "px 35px 0px)"
  //document.body.style.overflow='hidden';
  if (ns4) {
	var finestrax = window.innerWidth; 
	var finestray = window.innerHeight; 
  } else {
	var finestrax = document.body.clientWidth; 
	var finestray = document.body.clientHeight;
  }

  Centrat=Math.floor((finestrax - AImatge) /2); if (Centrat<0) Centrat=0;
  Vertical=((finestray - AltImatge) /2)+10; if (Vertical<0) Vertical=0;
  moveLayer('root', Centrat+AmpleTitol, 400+Vertical); 
  moveLayer('Menu', Centrat+40, 500+Vertical); 
  moveLayer('main', Centrat, Vertical);
  moveLayer('imatge', Centrat-20, Vertical+1);
  moveLayer('txtSubmenu', Centrat-20, Vertical + 540); 
 
  viewLayer('root','visible'); 
  viewLayer('Menu','visible'); 
  viewLayer('main','visible'); 
  viewLayer('txtSubmenu','visible'); 
  viewLayer('imatge','visible');

  posMenu = Centrat + AmpleTitol;
  
 	  

  if (!IE) document.captureEvents(Event.MOUSEMOVE)
    
  if (com != 'fix') {
	  setTimeout('NextImg(1)',4000);
  }
}

function init2(com) {
  AmpleMenu=parseInt(document.getElementById('root').offsetWidth);
  AmpleTitol=0;
  document.getElementById('root').style.clip = "rect(0px " + (AImatge-AmpleTitol) + "px 35px 0px)"
  //document.body.style.overflow='hidden';
  if (ns4) {
	var finestrax = window.innerWidth; 
	var finestray = window.innerHeight; 
  } else {
	var finestrax = document.body.clientWidth; 
	var finestray = document.body.clientHeight;
  }

  Centrat=Math.floor((finestrax - AImatge) /2); if (Centrat<0) Centrat=0;
  Vertical=((finestray - AltImatge) /2)+10; if (Vertical<0) Vertical=0;
  moveLayer('root', Centrat+AmpleTitol, 400+Vertical); 
  moveLayer('Menu', Centrat+40, 500+Vertical); 
  moveLayer('main', Centrat, Vertical);
  moveLayer('imatge', Centrat-20, Vertical+1);
  moveLayer('txtSubmenu', Centrat-20, Vertical + 540); 
  moveLayer('map',Centrat-10,Vertical+100)
  viewLayer('root','visible'); 
  viewLayer('Menu','visible'); 
  viewLayer('main','visible'); 
  viewLayer('txtSubmenu','visible'); 
  viewLayer('imatge','visible');

  posMenu = Centrat + AmpleTitol;
  
 	  

  if (!IE) document.captureEvents(Event.MOUSEMOVE)
    
  }



function NextImg(n) {
	n=aleatori+n;
	if (n > quants) {n=1}
	if (n < 1) {n=quants}
	var src = 'img/' + url + '_' + n + '.jpg';
  	document.getElementById('imatgeimatge').src=src;
  	aleatori=n;
  	if (loop) {
		kk=setTimeout('NextImg(1)',4000);
  	}
}



