var ns4=(document.layers)?true:false;
var ie=(document.all)?true:false;
var ns6=((document.getElementById)?true:false) && !ie;

setInterval('window.defaultStatus="http://www.corbins.net"',10);

if ( parent.location.href != window.location.href ) {
  parent.location.href = window.location.href;
}

window.moveTo(0,0)
var x = screen.availWidth
var y = screen.availHeight
if (ie) {
  window.resizeTo( x,y )
}
else {
  if ( window.outerWidth<x || window.outerHeight<y ){
    window.outerWidth = x
    window.outerHeight = y
  }
}


var llistapre = new Array("imatges/corbins.jpg", "imatges/bola1.gif", "imatges/bola2.gif", "imatges/capa2_1.jpg", "imatges/capa2_2.jpg", "imatges/capa2_3.jpg", "imatges/capa2_4.jpg", "imatges/c_1.gif", "imatges/c_0.gif", "imatges/pag.gif", "imatges/fletxa.gif", "imatges/gravat.gif", "imatges/silueta.gif", "imatges/corbins.net2.gif", "imatges/ban1.jpg", "imatges/google.gif", "http://www.gencat.net/servmet/previsio/graf/avui.gif", "http://www.gencat.net/servmet/previsio/graf/dema.gif");
var imatge= new Array();
for (var i=0; i<llistapre.length; i++) {
  imatge[i] = new Image();
  imatge[i].src= llistapre[i];
}

function anim() {
data();
loop2();
album1();
}


var nomMes="Gener Febrer Mar&ccedil; Abril Maig Juny Juliol Agost Setembre Octubre Novembre Desembre";
var nomDia="Diumenge Dilluns Dimarts Dimecres Dijous Divendres Dissabte";
nomMes = nomMes.split(" ");
nomDia = nomDia.split(" ");
function data(){
    var hh=ara.getHours();
    var mm=ara.getMinutes();
    var ss=ara.getSeconds();
    var cadena=nomDia[ara.getDay()] + ", " + ara.getDate() + ( ( ara.getMonth()==3 || ara.getMonth()==7 || ara.getMonth()==9 ) ? " d'" : " de " ) +nomMes[ara.getMonth()] + " de " + ara.getFullYear() + " &nbsp; &nbsp; &nbsp; " + ((hh<=9)?("0"+hh):hh)+":"+((mm<=9)?("0"+mm):mm)+":"+((ss<=9)?("0"+ss):ss);
    ara.setMilliseconds(ara.getMilliseconds() + 1000);
    escriuACapa('rellotge', cadena);
    setTimeout("data()",1000);
}


var menuesq = new Array (
   "separador", "&nbsp;",
   "separador", "<center><b>Serveis:</b></center>",
   "href=\"javascript:finestrareg();\" title=\"No actiu\" onClick=\"return false;\"", "Registre",
   "href=\"/cgi-bin/xatcorb/chat.cgi\" title=\"No actiu\" onClick=\"return false;\" target=\"_blank\"", "Xat",
   "href=\"./phpBB2/index.php\" title=\"No actiu\" onClick=\"return false;\" target=\"_blank\"", "Fòrum",
   "href=\"/cgi-bin/openwebmail/openwebmail.pl\" title=\"No actiu\" onClick=\"return false;\" target=\"_blank\"", "Correu Web",
   "href=\"javascript:finestrasug();\" title=\"No actiu\" onClick=\"return false;\"", "Sugerències",
   "href=\"javascript:finestrapla();\"", "Plànol de carrers",
   "href=\"javascript:finestrapla2();\"", "Vista aèria",
   "href=\"album1\"", "Fotos panor&agrave;miques",


   "separador", "&nbsp;",
   "separador", "<center><b>Adreces temàtiques:</b></center>",
   "href=\"http://www.gencat.cat/darp/\" target=\"_blank\"", "DARP",
   "href=\"http://www.mapya.es\" target=\"_blank\"", "MAPYA",
   "href=\"http://www.uniopagesos.org\" target=\"_blank\"", "Unió de Pagesos",
   "href=\"http://www.ruralialleida.com\" target=\"_blank\"", "Ruràlia Lleida",
   "href=\"http://www.actel.es\" target=\"_blank\"", "Actel",
   "href=\"http://www.meteocat.com\" target=\"_blank\"", "Meteocat",
   "href=\"http://www.ruralcat.net\" target=\"_blank\"", "RuralCat" );

var menudreta = new Array (
   "separador", "&nbsp;",
   "separador", "<center><b>Adreces d\'interés:</b></center>",
   "href=\"http://www.gencat.cat\" target=\"_blank\"", "Generalitat de Catalunya",
   "href=\"http://www.diputaciolleida.net\" target=\"_blank\"", "Diputació de Lleida",
   "href=\"http://www.lleida.com\" target=\"_blank\"", "Lleida.com",
   "href=\"http://www.lleida.org\" target=\"_blank\"", "Lleida.org",
   "href=\"http://www.softcatala.cat\" target=\"_blank\"", "SoftCatalà.org",
   "href=\"http://www.xtec.cat/centres/c5001424/\" target=\"_blank\"", "CEIP Sol Ixent",
   "href=\"http://corbins.ddl.net\" target=\"_blank\"", "corbins.ddl.net");

function menu(nmenu) {
 var i, url, nom;
 var cad='<table width="100%" border="0" cellspacing="2" cellpadding="0">';
 for ( i=0; i<eval(nmenu+".length"); i+=2 ) {
    url = eval(nmenu + "[i]");
    nom = eval(nmenu+"[i+1]");
    if (url=="separador") {
	 cad +='<tr><td>' + nom + '</td></tr>';
    }
    else {
              cad += '<tr><td class="menu"><a ' + url + ' ';
              cad += 'onMouseOver="' + nmenu + i + '.src=\'imatges/bola1.gif\'" ';
              cad += 'onMouseOut="' + nmenu + i + '.src=\'imatges/bola2.gif\'" ';
              cad += 'onClick="window.focus()">';
              cad += '<img name="' + nmenu + i + '" src="imatges/bola2.gif" border="0" ';
              cad += 'width="12" height="12" hspace="4">'
              cad += nom + '</a></td></tr>';
    }
 }
 cad += '</table>';
 return cad;
}

//  --------
var text= '<center><b><u>Festes locals</u></b></center><p><b>22 de Maig</b> Festa Major de Santa Quitèria<p><b>25 de Juliol</b> Sant Jaume<p><b>24 d\'agost</b> Sant Bertomeu <p><b>Octubre</b> Festa de la Poma<p><b>Febrer</b> Santa Àgueda';
var mw=175;
var mh=100;
var sp=1;
function scroller()
{
  var cad='';
  if (ie) cad='<marquee direction="up" scrollAmount='+sp+' style="border-width:1; border-style:ridge; border-color:#42A5A5; width:'+mw+';height:'+mh+'">'+text+'</marquee>';
  if (ns4) cad = '<ilayer width='+mw+'; height='+mh+'; name="marq"><layer name="marqEx" width='+mw+'; height='+mh+';></layer></ilayer>';
  //if (ns6) no funciona!;
  return cad;
}

function loop()
{
  window.location.reload();
}

function loop2()
{
  if (ns4) {
    setTimeout("window.onresize=loop",350);
    init();
  }
}

function init()
{
  document.marq.document.marqEx.document.write(text);
  document.marq.document.marqEx.document.close();
  thelength=document.marq.document.marqEx.document.height;
  runmarq();
}

function runmarq()
{
  if (document.marq.document.marqEx.top>=thelength*(-1)) {
    document.marq.document.marqEx.top-=sp;
    setTimeout("runmarq()",100);
  }
  else
  {
    document.marq.document.marqEx.top=mh;
    runmarq();
  }
}

//window.onload=loop2

// ------




var barraMenuFlot= '<a href="#" onMouseDown="mouMenuFlotDreta(); return false;" onClick="return false;"><img src="imatges/capa2_1.jpg" border="0"></a><a href="#" onClick="minMaxMenuFlotDreta(); return false;"><img src="imatges/capa2_2.jpg" border="0" id="imgMinMax" name="imgMinMax"></a><a href="#" onClick="tancaCapaFlotDreta(); return false;"><img src="imatges/capa2_3.jpg" border="0"></a><br>';


if (ns4||ns6) document.captureEvents(Event.ONMOUSEDOWN);
function menuflotdreta(e){
  if (ie) e=window.event;
  if((ns4||ns6) && (e.which==3||e.which==2)){

    if (ns4) {
      document.layers["capaflotdreta"].top = e.y;
      document.layers["capaflotdreta"].left = e.x;
      ocultaMostraCapa('capaflotdreta','v');
    }
    if (ns6) {
      document.getElementById("capaflotdreta").style.top = e.pageY;
      document.getElementById("capaflotdreta").style.left = e.pageX;
      ocultaMostraCapa('capaflotdreta','v');
    }
    obreTanca(-1);
  }
  if (ie && event.button==2) {
    capaflotdreta.style.top = e.y + document.body.scrollTop;
    capaflotdreta.style.left = e.x + document.body.scrollLeft;
    ocultaMostraCapa('capaflotdreta','v');
    obreTanca(-1);
  }
  return false;
}
document.onmousedown=menuflotdreta;
document.oncontextmenu=menuflotdreta;


function tancaCapaFlotDreta() {
      ocultaMostraCapa('capaflotdreta','o');
      for ( i=0; i<carpeta.length; i++ )  obert[i] = false;
}


var minMax = true;
function minMaxMenuFlotDreta()
{
 if (minMax == true) {
   escriuACapa('capaflotdreta', barraMenuFlot);
   if (ie) imgMinMax.src = "imatges/capa2_4.jpg";
   if (ns6) document.getElementById("imgMinMax").src = "imatges/capa2_4.jpg";
   if (ns4) document.capaflotdreta.document["imgMinMax"].src = "imatges/capa2_4.jpg";
   minMax = false;
 }
 else {
   obreTanca(-1);
   if (ie) imgMinMax.src = "imatges/capa2_2.jpg";
   if (ns6) document.getElementById("imgMinMax").src = "imatges/capa2_2.jpg";
   if (ns4) document.capaflotdreta.document.images["imgMinMax"].src = "imatges/capa2_2.jpg";
   minMax = true;
 }
}


var despX, despY;
var capEvent = true;
if (ns6 || ns4) document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
function mouMenuFlotDreta(ev)
{
 if (ie) ev = window.event;
 if(capEvent) {
 document.onmouseup = mouMenuFlotDreta;
 document.onmousemove = mouMenuFlotDreta;
 if(ev != null) {
   if (ns6) {
     despX = document.getElementById("capaflotdreta").offsetLeft - ev.pageX;
     despY = document.getElementById("capaflotdreta").offsetTop - ev.pageY;
   }
   if (ns4) {
     despX = document.layers["capaflotdreta"].left - ev.pageX;
     despY = document.layers["capaflotdreta"].top - ev.pageY;
   }
   if (ie) {
     despX = capaflotdreta.offsetLeft - ev.clientX;
     despY = capaflotdreta.offsetTop - ev.clientY;
   }
   capEvent = false;
 }
 }
 else {
   if(ev != null) {
     if (ev.type == 'mousemove') {
       if (ns6) {
         document.getElementById("capaflotdreta").style.left = ev.pageX + despX;
         document.getElementById("capaflotdreta").style.top = ev.pageY + despY;
       }
       if (ns4) {
         document.layers["capaflotdreta"].top = ev.pageY +despY;
         document.layers["capaflotdreta"].left = ev.pageX + despX;
       }
       if (ie) {
         document.all.capaflotdreta.style.left= ev.clientX + despX;
         document.all.capaflotdreta.style.top = ev.clientY + despY;
       }
     }
     if (ev.type == 'mouseup') {
       document.onmousemove = null;
       document.onmouseup = null;
       capEvent = true;
     }
   }
 }
}




var carpeta=new Array()
carpeta[0]='Serveis;'+
	'href="javascript:finestrareg()"|Registre;'+
	'href="/cgi-bin/xatcorb/chat.cgi" target="_blank"|Xat;'+
	'href="./multiforum/index.php3" target="_blank"|Fòrum;'+
	'href="/cgi-bin/openwebmail/openwebmail.pl" target="_blank"|Correu web;'+
	'href="javascript:finestrasug()"|Sugerències;'+
            'href="javascript:finestrapla()"|Plànol de carrers;'
carpeta[1]='Adreces temàtiques;'+
	'href="http://www.gencat.net/darp" target="_blank"|DARP;'+
	'href="http://www.mapya.es" target="_blank"|MAPYA;'+
	'href="http://www.uniodepagesos.org" target="_blank"|Unió de Pagesos;'+
	'href="http://www.ruralialleida.com" target="_blank"|Ruràlia Lleida;'+
	'href="http://www.ruralialleida.com/cat/actividades/informatica/manualsup/pagina2.php" target="_blank"|Manuals informàtica;'+
             'href="http://www.actel.es" target="_blank"|Actel;'+
	'href="http://www.meteocat.com" target="_blank"|Meteocat;'+
	'href="http://www.ruralcat.net" target="_blank"|RuralCat;'
carpeta[2]='Adreces d\'interés;'+
	'href="http://www.gencat.net" target="_blank"|Generalitat de Catalunya;'+
	'href="http://www.diputaciolleida.net" target="_blank"|Diputació de Lleida;'+
	'href="http://www.lleida.com" target="_blank"|Lleida.com;'+
	'href="http://www.lleida.org" target="_blank"|Lleida.org;'+
	'href="http://www.softcatala.org" target="_blank"|Softcatalà.org;'+
             'href="http://www.xtec.es/centres/c5001424/" target="_blank"|CEIP Sol Ixent;'+
	'href="http://corbins.ddl.net" target="_blank"|Corbins.ddl.net;'

var obert = new Array()
for ( i=0; i<carpeta.length; i++ ) obert[i] = false;

function obreTanca(visi) {
  var txt = barraMenuFlot;
  obert[visi] = !obert[visi];
  for ( i=0; i<carpeta.length; i++ ) {
    var item = carpeta[i].split(';');
    var url = item[0];
    txt += '<a href="javascript:obreTanca('+i+')"><img src="imatges/c_'+((obert[i])?'1':'0')+'.gif"';
    txt += ' border="0" width="16" height="13" hspace="6"><b>'+url+'</b></a><br>\n';
    if ( obert[i] ){
      for ( j=1; j<item.length-1; j++ ) {
	url = item[j].split('|');
	var c = 'i' + ((i*100)+j);
	txt += '&nbsp; &nbsp; <a '+url[0]+' onmouseout="'+c+'.src=\'imatges/pag.gif\'"';
	txt += ' onmouseover="'+c+'.src=\'imatges/fletxa.gif\'"><img name="'+c+'" src="imatges/pag.gif"';
	txt += ' border="0" width="14" height="12" hspace="6">'+url[1]+'</a><br>\n';
      }
    }
  }
  if (ie) document.all["capaflotdreta"].style.width=212;
  if (ns6) document.getElementById("capaflotdreta").style.width=208;
  if (ns4) document.layers["capaflotdreta"].width=208;
  escriuACapa('capaflotdreta', txt);
}


//  -----

function escriuACapa(pNomCapa, text) {
  if (ie) {
    //document.form1.capsa.value=text;
    eval( 'document.all.' + pNomCapa + '.innerHTML= text' );
  }
  if (ns4) {
    //document.form1.capsa.value=text;
    eval( 'document.' + pNomCapa + '.document.write(text)' );
    eval( 'document.' + pNomCapa + '.document.close()' );

  }
  if (ns6) {
    //document.form1.capsa.value=text;
    eval( 'document.getElementById("' + pNomCapa + '").innerHTML=text' );
  }
}

function ocultaMostraCapa(IdCapa,ocultaMostra) {
  if (ns4)  eval( 'document.layers["' + IdCapa + '"].visibility = ' + ((ocultaMostra=="v")?'"visible"':'"hidden"') );
  if (ns6)  eval( 'document.getElementById("' + IdCapa + '").style.visibility = ' + ((ocultaMostra=="v")?'"visible"':'"hidden"') );
  if (ie)   eval( 'document.all.' + IdCapa +'.style.visibility=' + ((ocultaMostra=="v")?'"visible"':'"hidden"') );
}

function refObj(obj) {
  if (ie) return (obj!=null)?("document.all." + obj) :("document.all");
  if (ns6) return (obj!=null)?("document.getElementById('" + obj + "')") : ("document");
}

function  finestrasug()
{
  var finesgran=null;
  finesgran=window.open('','fsuger','directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,height=475,width=475,left=20,top=10');
  if (finesgran == null)
  {
    alert("Compte!! Aquest navegador no serveix per aquestes pàgines.");
  }
  else
  {
    finesgran.document.write('<html><head><title>Aportacions.</title></head>\
                                       <body bgcolor="#ccddcc"><b>Omple el següent formulari per a comunicar-te amb el hostmaster:<hr><form action="/cgi-bin/aporta.cgi" method="POST"><input type=hidden name=Origen value="www.corbins.net/index.php">El teu nom:<br><input type=text name=Nom: size=55 value=""><p>El teu e-mail:<br><input type=text name=Email: size=55 value=""><p>Text:<br><textarea name=Descripcio rows=10 cols=50 wrap=virtual></textarea><p></b><center><input type=submit value="Enviar"></form></center>');
    finesgran.document.write('</body></html>');
  }
}

function  finestrareg()
{
  var finesgran=null;
  finesgran=window.open('registre.html','fregis','directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,height=475,width=575,left=20,top=10');
}

function  finestrapla()
{
  var finesgran=null;
  finesgran=window.open('http.www.gencat.net.sial.mapes.carrers.corbins.pdf','fplanol','directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,height=525,width=575,left=60,top=2');
}

function  finestrapla2()
{
  var finesgran=null;
  //finesgran=window.open('http://galileo.icc.es/website/mob/viewer.htm?ActiveLayerName=Cruilles&Query=BV5M.Carrer_Cruilles.ID_CRUILLA=30129&QueryZoom=Yes?CONSULTA=Corbins%20-%20Església%20(pl.%20de%20l$)%20/%20Església%20(c.%20de%20l$)&MUN=&NOMMUN=Corbins&','fplanol2','directories=no,location=no,status=no,menubar=no,copyhistory=no,resizable=yes,scrollbars=yes,height=525,width=775,left=60,top=2');
  finesgran=window.open('http://www.google.es/maphp?hl=ca&q=corbins&ie=UTF8&t=h&om=1&ll=41.691245,0.696688&spn=0.029419,0.085831','fplanol2','directories=no,location=no,status=no,menubar=no,copyhistory=no,resizable=yes,scrollbars=yes,height=525,width=775,left=60,top=2');
}


function obreCarpetaPersonal() {
  window.open('ftp://www.corbins.net','ftp','status=0,titlebar=no,location=no,toolbar=1,menubar=0,resizable=1,scrollbars=1,width=750,height=400,left=5,top=30');
}

function cercadorGoogle() {
  var cadena='\
      <form name="frmSearch" action="http://www.google.cat/search" target="_blank" method="get">\
        <table width="100%" border="0" cellspacing="0" cellpadding="0">\
         <tr bgcolor="#CCDDFF">\
           <td align="center" class="refranydata">\
             Cerca amb <a href="http://www.google.cat" target="_blank"><img src="imatges/google.gif" border="0" align="middle"></a>\
             <input type="text" name="q" size="16" maxlength="255" value="">\
             <input type="hidden" name="num" value="30">\
             <input type="hidden" name="hl" value="es">\
             <input type="hidden" name="lr" value="lang_es">\
           </td>\
         </tr>\
         <tr>\
           <td align="center" class="refranydata">\
             <input type="submit" name="btnG" value="&nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;">\
           </td>\
          </tr>\
         </table>\
       </form> ';
  return cadena;
}

function quadreElTemps() {
  var cadena ='\
      <table width="100%" border="0" cellspacing="0" cellpadding="0">\
        <tr>\
          <td class="refranydata" align="center"><b>El temps</b><td>\
        </tr>\
        <tr>\
          <td bgcolor="#bbeecc" align="center"><br><a href="http://www.meteo.cat" onMouseOver="imgcentre.src=\'http://www.meteo.cat/servmet/prediccio/ctermini/cat/img/avui.jpg\'; pinta(\'lnk1\',\'#ffddbb\');" onMouseOut="imgcentre.src=\'imatges/corbins.jpg\'; pinta(\'lnk1\',\'\');" target="_blank" onClick=""><span id="lnk1" style="position:relative"><b>Avui</b></span></a>&nbsp;&nbsp;&nbsp;<a href="http://www.meteo.cat" onMouseOver="imgcentre.src=\'http://www.meteo.cat/servmet/prediccio/ctermini/cat/img/dema.jpg\'; pinta(\'lnk2\',\'#ffddbb\');" onMouseOut="imgcentre.src=\'imatges/corbins.jpg\'; pinta(\'lnk2\',\'\');" target="_blank" onClick=""><span id="lnk2" style="position:relative"><b>Demà</b></span></a><br>&nbsp;</td>\
        </tr>\
      </table> ';
  return cadena;
}

function pinta(idSpan, clr) {
  if (ns4){
    if (clr=='') clr = null;
    document.layers[idSpan].bgColor = clr;
  }
  if (ns6) {
    if (clr=='') clr = null;
    document.getElementById(idSpan).style.background = clr;
  }
  if (ie) document.all[idSpan].style.background = clr;


}

function peu() {
 var cadena='\
      <table width="770" border="0" cellspacing="0" cellpadding="0">\
        <tr>\
          <td width="33%" valign="top" class="refranydata">&nbsp;</td>\
          <td width="33%" valign="top" class="refranydata">&nbsp;</td>\
          <td width="33%" valign="top" class="refranydata">&nbsp;</td>\
        </tr>\
      </table> ';
  return cadena;
}


var nImatge=0;
var retardInici=3000; //ms
var tempsCommutacio=20000; //ms
var imatge1=new Image();
function album1() {
       var aleat=Math.round(nfotos * Math.random()-0.5);
       if (aleat<10) aleat="000"+aleat;
       else if (aleat<100) aleat="00"+aleat;
       else if (aleat<1000) aleat="0"+aleat;
       var cad="./album1/corbins"+ aleat +".jpg";
       if (retardInici!=0) {
                imatge1.src=cad;
                retardInici=0;
                setTimeout("album1()", tempsCommutacio);
                return;        
       }
       if(imatge1.complete) {
                  eval(refObj()+'.img6.src='+refObj()+'.img5.src');
                  eval(refObj()+'.img5.src='+refObj()+'.img4.src');
                  eval(refObj()+'.img4.src='+refObj()+'.img3.src');
                  eval(refObj()+'.img3.src='+refObj()+'.img2.src');
                  eval(refObj()+'.img2.src='+refObj()+'.img1.src');
                  eval(refObj()+'.img1.src=imatge1.src');
                  imatge1.src=cad;
                  setTimeout("album1()",tempsCommutacio);
       }
       else {
              setTimeout("album1()",tempsCommutacio);      
       }
}

function mostrafoto(obj) {
  var finesfoto=null;
  finesfoto=window.open(obj,'ffoto','directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,height=510,width=670,left=20,top=10');

}




