function statusMsg(msgStr){
 window.status=msgStr;
 return true;
}

function allCell(cella){
   cella.link=cella.getElementsByTagName("a")[0].href;
   if(cella.link.length>0){
      cella.className="liOver";
      cella.style.cursor="pointer";
      /*cella.getElementsByTagName("a")[0].style.color='orange';*/
      cella.onclick=function(){document.location.href=this.link};
      cella.onmouseout = function(){cella.className="";}
   }
}

var initwin;

function OpenPopup(winWID,winHEI,winURL,winSCR){
	var winLeft=(screen.availWidth-winWID)/2; 
  var winTop=(screen.availHeight-winHEI)/2; 
  
  if(initwin==null){opener=window;}
  
  if(opener.popwin!=null){opener.popwin.close();}
  
	opener.popwin = window.open(winURL,'zzz','status=no, menubar=no, toolbar=no, scrollbars=' + winSCR + ' , resizable=no,copyhistory=0,width=' + winWID + ',height=' + winHEI + ',top='+winTop+',left='+winLeft);
}

function checkFile(){
   var objForm=document.frmUpload;
   var fileUpl=objForm.txtUpload.value;
   var fileDesc=objForm.txtDesc.value;
   
   if(fileUpl.length==0 && objForm.action.indexOf('idFile')==-1 ){
      alert("Nessun elemento da caricare!");
      return;
   }
   
   if(fileUpl.length>=255){
      alert("Percorso non valido! Nome troppo lungo");
      return;
   }
   
   if(fileDesc.length==0){
      alert("Inserire la descrizione del file!");
      return;
   }
   
   objForm.txtTitle.value=document.getElementById('fileTitle').value;
   objForm.action=objForm.action+'&txtDesc='+fileDesc+'&txtTitle='+objForm.txtTitle.value+'&newfil='+fileUpl.length;
   
   objForm.submit();
   
}

function checkLink(){
   var lnkDesc=document.frmLink.txtDesc.value;
   
   if(lnkDesc.length==0){
      alert("Inserire la descrizione del file!");
      return;
   }
   
   frmLink.txtTitle.value=document.getElementById('lnkTitle').value;
   frmLink.submit();
   
}

function modFile(idf){
   var fdes=document.getElementById('fdes'+idf);
   var flnk=document.getElementById('flnk'+idf);
   var objShow=document.frmUpload;
   
   objShow.btnUpload.value='Modifica';
   
   if(objShow.action.indexOf("idFile")!=-1){
      objShow.action=objShow.action.substring(0,objShow.action.lastIndexOf('&'));
   }
   
   objShow.action=objShow.action+'&idFile='+idf;
   
   objShow.txtDesc.value=fdes.innerHTML;
}


function modLink(idf){
   var fdes=document.getElementById('fdes'+idf);
   var flnk=document.getElementById('flnk'+idf);
   var objShow=document.frmLink;
   
   objShow.btnUpload.value='Modifica';
   
   if(objShow.action.indexOf("idFile")!=-1){
      objShow.action=objShow.action.substring(0,objShow.action.lastIndexOf('&'));
   }
   
   objShow.action=objShow.action+'&idFile='+idf;
   
   objShow.txtDesc.value=fdes.innerHTML;
   objShow.txtLink.value=flnk.innerHTML.substring(7,flnk.innerHTML.length);      
}


function showDiv(showId,hideId){
   var divShow=document.getElementById(showId);
   var divHide=document.getElementById(hideId);
   
   divShow.style.display='';
   divHide.style.display='none';
}


/********************************************************************/
var listNews; 
var newsContainer; 
var interval = 10;
var showed = 5;

function parseNews(divId) {
  newsContainer = document.getElementById(divId);
  listNews = newsContainer.childNodes;
  
  for(var i=0;i<listNews.length;i++){
    var news = listNews[i];
    news.style.display='none';
  }
  
  showNews(0);
}

function showNews(cursor){
   
   if(cursor > 0){
      for(var i=0;i<showed;i++){
         if( typeof(listNews[(cursor-1)*showed+i])=='object'){
            listNews[(cursor-1)*showed+i].style.display='none';
         }else{
            cursor = 0;
            break;
        }
      }
   }
   
   if(cursor*showed>=listNews.length)
      cursor=0;
      
   for(var i=0;i<showed;i++){
      if( typeof(listNews[cursor*showed+i])=='object'){
         listNews[cursor*showed+i].style.display='';
      }else{
         break;
      }
   }
   
   cursor++;
   
   window.setTimeout("showNews('" + cursor + "')", interval*1000);
}

/********************************************************************/
