var myOffline = document.location.href.substring(0,(document.location.href.lastIndexOf("/cat/"))+5);
var myOnline = document.location.pathname.substring(0,(document.location.pathname.lastIndexOf("/cat/"))+5); 
var blankImg0 = 12;
var blankImg0e = 12;
var webname = "Subweb Principal"

function dbopc(id,nom,tit,url) {
  this.id = id; this.nom = nom; this.url = url;
//  if (tit=="") { this.tit = nom; } else { this.tit = tit; } 
  this.tit = tit;
  return this;
}
var opcmenu = new Array();
var opcsubmenu = new Array();



/* opcions de menu */

opcmenu[1] = new Array();
opcmenu[1][0] = new dbopc("H_instituto","Institut","","../../sw_instituto/l_ca/home.php");

opcmenu[2] = new Array();
opcmenu[2][0] = new dbopc("H_studies","Studies on Ramon Llull","","../../sw_studies/l_ca/home.php");

opcmenu[3] = new Array();
opcmenu[3][0] = new dbopc("H_dialogo","Diàleg inter-religiós","","../../sw_dialogo/l_ca/home.php");

opcmenu[4] = new Array();
opcmenu[4][0] = new dbopc("H_cursos","Cursos","","../../sw_cursos/l_ca/home.php");

opcmenu[5] = new Array();
opcmenu[5][0] = new dbopc("H_Comunidade","Comunitat Virtual ","","../../sw_comvirt/index.php");

opcmenu[6] = new Array();
opcmenu[6][0] = new dbopc("H_patrocinadores","Patrocinadors ","","patrocinadores.php");

opcmenu[7] = new Array();
opcmenu[7][0] = new dbopc("H_megaloja","Botiga Virtual","","http://www.ramonllull.net/lojaweb");

// determina inx segons id
var socainx = new Array();
function buscarinx() {
  if (soca[0]=="") {
    socainx[0]=0; socainx[1]=0;
  } else {
    for (inxi=1; inxi<opcmenu.length; inxi++) {
      if (opcmenu[inxi][0].id==soca[0]) {
	    socainx[0]=inxi;
		if (soca[1]=="") {
		  socainx[1]=0;
		} else {
  	      for (inxj=1; inxj<opcmenu[inxi].length; inxj++) {
	        if (opcmenu[inxi][inxj].id==soca[1]) {
		      socainx[1] = inxj;
		      break;
		    }
	      }
	      break;  
		}
	  }
    }
  }
} 
buscarinx();

function escriumenu() {

  document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
  document.writeln('  <tr>');
  document.writeln('    <td><img src="../../comum/img/pix.gif" width="8" height="20" border="0"></td>');
    for (i=1; i<opcmenu.length; i++) {
	  if (socainx[0] == i) { estil = "Level0act" }
	  else { estil = "Level0" }
  document.writeln('    <td valign="middle" class="clLevel0"><a href="' + opcmenu[i][0].url + '" class="' + estil + '" title="' + opcmenu[i][0].tit + '">' + opcmenu[i][0].nom + '</a></td>');
  document.writeln('    <td><img src="../../comum/img/pix.gif" width="' + blankImg0 + '" height="20" alt="" border="0"></td>');
    }
  document.writeln('  </tr>');
  document.writeln('</table>');

}

function escriumenue() {

  document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
  document.writeln('  <tr>');
  document.writeln('    <td><img src="../../comum/img/pix.gif" width="8" height="20" border="0"></td>');
    if (socainx[0]!=0) {
      for (i=1; i<opcmenu[socainx[0]].length; i++) {
	    if (socainx[1] == i) { estil = "Level0eact" }
		else { estil = "Level0e" }
  document.writeln('    <td valign="middle" class="clLevel0e"><a href="' + opcmenu[socainx[0]][i].url + '" class="' + estil + '" title="' + opcmenu[socainx[0]][i].tit + '">' + opcmenu[socainx[0]][i].nom + '</a></td>');
  document.writeln('    <td><img src="../../comum/img/pix.gif" width="' + blankImg0e + '" height="20" alt="" border="0"></td>');
	  }
	}
  document.writeln('  </tr>');
  document.writeln('</table>');

}

function escriuopcio(i) {

  document.write('<a href="' + opcmenu[i][0].url + '" class="link" title="' + opcmenu[i][0].tit + '">' + opcmenu[i][0].nom + '</a>');

}

function escriufil() {

  if (socainx[0]==0) {
    txt1 = soca[1]; txt2 = ''; 
  } else {
    if (opcmenu[socainx[0]][0].tit == "") {
      txt1 = opcmenu[socainx[0]][0].nom;
	} else {
      txt1 = opcmenu[socainx[0]][0].tit;
	}
    if (socainx[1]!=0) {
	  if (opcmenu[socainx[0]][socainx[1]].tit == "") {
	    txt2 = " > " + opcmenu[socainx[0]][socainx[1]].nom
	  } else {
	    txt2 = " > " + opcmenu[socainx[0]][socainx[1]].tit
	  }
	} else { txt2 = ''}
  }
//gpd  document.write(webname + " > " + txt1 + txt2);
  document.write(webname + " > " + txt1 + txt2);
//gpd  document.title = (txt1 + txt2);

}

function escriumapa() {

document.write('<table border="0" cellspacing="0" cellpadding="0">');
  for (j=1; j<opcmenu.length; j++) {
    if ((opcmenu[j].length-1)==0) {
document.write('  <tr>');
document.write('    <td align="right" valign="middle" class="clLevel0e"><a href="' + opcmenu[j][0].url + '" class="Level0e">' + opcmenu[j][0].nom + '</a></td>');
document.write('    <td valign="middle"><img src="../../comum/img/pix.gif" width="4" height="1"></td>');
document.write('    <td valign="middle"><img src=".../../comum/img/pix.gif" width="12" height="1"></td>');
document.write('    <td>&nbsp;</td>');
document.write('  </tr>');
    } else {
      for (i=1; i<opcmenu[j].length; i++) {
	    if (opcmenu[j][i].url=="") {
		  txt = '<b>' + opcmenu[j][i].nom + '</b>';
		} else {
		  txt = '<a href="' + opcmenu[j][i].url + '" class="Level0e">' + opcmenu[j][i].nom + '</a>';
		}
		img = 'm'; if (i==1) img = 't';  if (i==(opcmenu[j].length-1)) img = 'b';
document.write('  <tr>');
	    if (i==1) {
document.write('    <td align="right" valign="middle" rowspan="' + (opcmenu[j].length-1) + '" class="clLevel0e"><a href="' + opcmenu[j][0].url + '" class="Level0e">' + opcmenu[j][0].nom + '</a></td>');
document.write('    <td valign="middle" rowspan="' + (opcmenu[j].length-1) + '"><img src="../../comum/img/pix.gif" width="4" height="1"></td>');
document.write('    <td valign="middle" rowspan="' + (opcmenu[j].length-1) + '"><img src="../../comum/img/pix.gif" width="12" height="1"></td>');
	    }
document.write('    <td>');
document.write('      <table border="0" cellspacing="0" cellpadding="0">');
document.write('        <tr>');
document.write('          <td><img src="../../img/punt_' + img + '.gif" width="18" height="16"></td>');
document.write('          <td valign="middle" class="clLevel0e"><b>' + txt + '</b></td>');
document.write('        </tr>');
document.write('      </table>');
document.write('    </td>');
document.write('  </tr>');
      }
	}
  }
document.write('</table>');		

}

