function Menu(link,url,sel)
{
  document.write('<div class="menut">');
  if(sel == link)
    document.write('<div class="menulink">'+link+'</div>');
  else
    document.write('<a class="menulink" href="'+url+'">'+link+'</a>');
  document.write('</div>');
}

function Header(sel)
{
  document.write('<div class="logo"></div>');
  document.write('<div class="menu">');
  document.write('<div class="menul"></div>');
  
  document.write('<div class="menuc">');
  document.write('<div class="menucc">');

  Menu('Home','/index.html',sel);
  Menu('Gallery','/gallery.html',sel);
  Menu('Mostre','/mostre.html',sel);
  Menu('Premi','/premi.html',sel);
  Menu('Links','/links.html',sel);
  Menu('Stampa','/stampa',sel);
  
  document.write('</div>');
  document.write('</div>');
  
  document.write('<div class="menur"></div>');
  document.write('</div>');
  
  document.write('<div class="page">');
  document.write('<div class="body">');
}

function Footer(sel)
{
  document.write('</div><div class="copyright">&copy; 2007-2010 M.S.C.</div>');
  document.write('</div>');
  document.write('<img src="/count.php?page='+sel+'" width="1" height="1">');
}

function Riquadro_inizio_color(classe,titolo,immagine,imgclass,color)
{
  var c = parseInt(color, 16);
  var i;
  var cc = new Array(5);
  var ccdiv = [16,10,6,4,3];
  
  for(i=0; i<5; i++)
  {
    var r = ((0xff0000 - (c & 0xff0000))/ccdiv[i]) & 0xff0000;
    var g = ((0x00ff00 - (c & 0x00ff00))/ccdiv[i]) & 0x00ff00;
    var b = ((0x0000ff - (c & 0x0000ff))/ccdiv[i]) & 0x0000ff;
  
    cc[i] = Number(c + r + g + b).toString(16);
    while (cc[i].length < 6) {cc[i] = '0' + cc[i];}
  }
  
  document.write('<div class="'+classe+'">');
  
  document.write('<div class="b4"><div class="be" style="border-color: #'+cc[4]+';"></div></div>');
  document.write('<div class="b3"><div class="be" style="border-color: #'+cc[3]+';"></div></div>');
  document.write('<div class="b2"><div class="be" style="border-color: #'+cc[2]+';"></div></div>');
  document.write('<div class="b1"><div class="be" style="border-color: #'+cc[1]+';"></div></div>');
  document.write('<div class="b1"><div class="be" style="border-color: #'+cc[0]+';"></div></div>');
  
  if(classe == 'socio')
    document.write('<div class="nomesocio" style="background: #'+color+';">'+titolo+'</div>');
  else
    document.write('<div class="titolo" style="background: #'+color+';">'+titolo+'</div>');
  document.write('<div class="testo" style="border-color: #'+color+';">');
  if(classe == 'stampa')
    document.write('<div>');
  else
    document.write('<div class="maxwidth">');
  if(immagine != '') document.write('<img class="'+imgclass+'" src="'+immagine+'">');
}

function Riquadro_fine_color(color)
{
  document.write('</div>');
  document.write('<div class="fondo"></div>');
  document.write('</div>');
  
  document.write('<div class="b1"><div class="b" style="border-color: #'+color+';"></div></div>');
  document.write('<div class="b1"><div class="b" style="border-color: #'+color+';"></div></div>');
  document.write('<div class="b2"><div class="b" style="border-color: #'+color+';"></div></div>');
  document.write('<div class="b3"><div class="bb" style="border-color: #'+color+';"></div></div>');
  document.write('<div class="b4"><div class="be" style="border-color: #'+color+';"></div></div>');
  
  document.write('</div>');
}

function Socio(nome,foto,nick,interessi,dir)
{  
  Riquadro_inizio_color('socio',nome,'','','4359AA')
  
  document.write('<a href="/gallery/'+dir+'"><img class="socio" src="/images/'+foto+'"></a>');
  document.write('<div class="datisocio"><b>Nick forum</b>: '+nick+'<br><b>Interessi</b>: '+interessi+'</div>');
  document.write('<div class="gallerylink"><a href="/gallery/'+dir+'"><img src="/images/vai.png">Gallery</a></div>');
  
  Riquadro_fine_color('4359AA');
}

function News_inizio()
{
  document.write('<table>');
}

function News_fine()
{
  document.write('</table>');
}

function News(data,notizia)
{
  document.write('<tr><td><div class="date_n">'+data+'</div></td><td>'+notizia+'</td></tr>');
}

function Inserimento(data,user,model)
{
  document.write('<div class="inserimento">');
  document.write('<a href="gallery/'+user+'">');
  document.write('<img class="inserimento" src="gallery/'+user+'/'+model+'"></a>');
  document.write('<div>'+data+'</div>');
  document.write('</div>');
}

function Link(url,link,descr)
{
  document.write('<a href="'+url+'">'+link+'</a><br>');
  document.write('<div class="linkdesc">'+descr+'</div>');
}

function Apri(nome,descr,w,h)
{
  document.getElementById('image').innerHTML = '<IMG STYLE="width:'+w+';height:'+h+'" SRC="'+nome+'">';
  document.getElementById('descr').innerHTML=descr;
  var pos;
  if(navigator.appName.indexOf("Netscape") != -1)
  {
    pos = (window.innerHeight-h)/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.top=window.pageYOffset+pos;
    pos = (window.innerWidth-w)/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.left=pos;
  }
  else
  {
    pos = (document.body.clientHeight-h)/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.top=document.body.scrollTop+pos;
    pos = (document.body.clientWidth-w)/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.left=pos;
  }
  document.getElementById('foto').style.width=w;
  document.getElementById('foto').style.visibility='visible';
}

function ApriNum(num)
{
  document.getElementById('image').innerHTML = '<IMG STYLE="width:'+Images[num][2]+';height:'+Images[num][3]+'" SRC="'+Images[num][0]+'">';
  document.getElementById('descr').innerHTML = Images[num][1];
  if(num > 0)
    document.getElementById('prev').href = 'javascript:ApriNum('+(num-1)+')';
  else
    document.getElementById('prev').href = 'javascript:void(0)';
  if(num < NumImages-1)
    document.getElementById('next').href = 'javascript:ApriNum('+(num+1)+')';
  else
    document.getElementById('next').href = 'javascript:void(0)';
  var pos;
  if(navigator.appName.indexOf("Netscape") != -1)
  {
    pos = (window.innerHeight-Images[num][3])/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.top = window.pageYOffset+pos;
    pos = (window.innerWidth-Images[num][2])/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.left = pos;
  }
  else
  {
    pos = (document.body.clientHeight-Images[num][3])/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.top = document.body.scrollTop+pos;
    pos = (document.body.clientWidth-Images[num][2])/2;
    if(pos < 0) pos = 0;
    document.getElementById('foto').style.left = pos;
  }
  document.getElementById('foto').style.width = Images[num][2];
  document.getElementById('foto').style.visibility = 'visible';
}

function Chiudi()
{
  document.getElementById('foto').style.visibility='hidden';
  document.getElementById('image').innerHTML = '';
}

function Premio(nome,user,modello,image,premio)
{
  document.write('<div class="premio" style="white-space: nowrap">');
  document.write('<a href="gallery/'+user+'">');
  if(image == '')
    document.write('<img class="premio" src="images/nofoto.jpg"></a>');
  else
    document.write('<img class="premio" src="gallery/'+user+'/'+image+'"></a>');
  document.write('<div style="float:left">'+nome+'<br><b>'+modello+'</b><br>'+premio+'</div>');
  document.write('</div>');
}

function Premio_anno(anno)
{
  document.write('<div id="'+anno+'"></div>');
}

function BR()
{
  document.write('<div class="clear"></div>');
}

