function G(id){
  return document.getElementById(id);
}

function showhide(id){
  if(G(id).style.visibility == 'visible' && G(id).style.display == 'block'){
    G(id).style.visibility = 'hidden';
    G(id).style.display = 'none';
  }else{
    G(id).style.visibility = 'visible';
    G(id).style.display = 'block';    
  }
}

function hidele(id){
    G(id).style.visibility = 'hidden';
    G(id).style.display = 'none';  
}

function hideleTimer(id){
  setTimeout("showhide('"+id+"')",1000);
}

function favmenushow(){
  showhide('favmenu');
  hidele('mediamenu');
  hidele('uploadmenu');
}

function mediamenushow(){
  hidele('favmenu');
  showhide('mediamenu');
  hidele('uploadmenu');
}

function uploadmenushow(){
  hidele('favmenu');
  hidele('mediamenu');
  showhide('uploadmenu');
}

 /*
   TextScroller 1.1i <improved>
   Licence: GNU/GPL
   Link http://www.davidonzo.com/post/798/javascript-text-scroller-10/
 */

  var orientamento = 'DT'; //TD = TopDown; DT = DonwTop; LR = LeftRight; RL = RightLeft
  var parent = 'rss_prev'; //The ID containing the scrolling text
  var duration = 50; //The scroll speed. Smaller means faster
  var h = '100'; //Height of the id (assume it as pixel only value)
  var w = '255'; //Width of the id (assume it as pixel only value)

function letsGo(){
  if(document.getElementById(parent)){	
    initScroll();
  }  
}

function initScroll(){
  creatediv();
  DIV = document.getElementById('child'+parent);
  par = document.getElementById(parent);
  PaddAndOver();
  switch(orientamento){
    case 'RL':
      topo = par.offsetWidth;
    break;
    case 'LR':
      topo = -left;
    break;
    
    case 'TD':
      topo = -19-DIV.offsetHeight;
    break;

    case 'DT':
     topo = 0;
    break;
  }
  
  x = setInterval("scroll()",duration);
  DIV.onmouseover = function scroll(){
       clearInterval(x);
  }

  DIV.onmouseout = function scroll(){
    x = setInterval("scroll()",duration);
  }
}

function scroll(){
  DIV = document.getElementById('child-'+parent);
  par = document.getElementById(parent);
  switch(orientamento){
   case 'RL':
   case 'LR':
    altezza = DIV.offsetWidth;
    DIV.style.marginLeft = topo+'px';

    switch(orientamento){
      case 'RL':
       topo--;
       if(left < w){
         if(topo == -left-1){
           topo = w;
         }
       }else{
        if(Math.abs(topo) > left){
         topo = w;
        }
       }
      break;

      case 'LR':
       topo++;
       larg = par.offsetWidth;
       if(topo > larg){
         par = document.getElementById(parent);
         topo = -left;
       }
      break;
    }
   break;

   case 'DT':
   case 'TD':
    altezza = DIV.offsetHeight;
    DIV.style.marginTop = topo+'px';

    switch(orientamento){
      case 'DT':
       topo--;
       if(Math.abs(topo) > altezza){
         topo = 0;
       }
      break;
      
      case 'TD':
       topo++;
       retop = DIV.offsetTop;
       altic = par.offsetHeight;
       if(topo > altic){
       topo = -19-DIV.offsetHeight;
       }
      break;
    }

    break;
  }
}

function creatediv(){
   par = document.getElementById(parent);
   text = par.innerHTML
   par.innerHTML = '';
   newdiv = document.createElement("div");
   newdiv.setAttribute('id','child-'+parent);
   par.appendChild(newdiv);
   newdiv.innerHTML = text;
}

function PaddAndOver(){
  DIV = document.getElementById('child-'+parent);
  par = document.getElementById(parent);
  alt = par.offsetWidth;
  elt = par.offsetHeight;
  olt = DIV.offsetHeight;

   switch(orientamento){
    case 'RL':
      DIV.style.position = 'absolute';
      left = DIV.offsetWidth;
      DIV.style.whiteSpace = 'nowrap';
      par.style.position = 'relative';
      DIV.style.position = 'relative';
      DIV.style.marginLeft = w+'px';
    break;
    
    case 'LR':
      DIV.style.position = 'absolute';
      left = DIV.offsetWidth;
      DIV.style.whiteSpace = 'nowrap';
      par.style.position = 'relative';
      DIV.style.position = 'relative';
      DIV.style.marginLeft = -(left)+'px';
    break;
    
    case 'DT':
      DIV.style.paddingTop = h+'px';
    break;
    
    case 'TD':
      DIV.style.marginTop = -20-DIV.offsetHeight+'px';
    break;
   }

   par.style.overflow = 'hidden';
   par.style.height = h+'px';
   par.style.width = w+'px';
}

function setTD(){
   r = G('rssp');
   m = G('scrollimg');
   if(r.direction == "up"){
     r.direction = "down";
     m.src = 'images/updown2.png';
     m.title='Scrolla in alto';
   }else{
     r.direction = "up";
     m.src = 'images/updown.png';
     m.title='Scrolla in basso';     
   }
}
