
var navigation=null;
var navigation_close=false;
var waiting=2000;
var scrollbar;

function navigation_init()
{
  navigation=document.getElementById('navigation');
  navigation.onmouseover=navigation_start;
  navigation.onmouseout=set_navigation_close;
  navigation.style.visibility='hidden';
  
  var tmp=document.getElementById('navigation_start');
  tmp.onmouseover=navigation_start;
  tmp.onmouseout=set_navigation_close;
  tmp.href='#';
  
  navigation.innerHTML='<div id="navigation_content">'+
  '<div id="navigation_content_link"></div>'+
  '<a href="#" id="navigation_left" class="navigation_arrow" onclick="navigation_prev();">&lt;</a>'+
  '<div id="navigation_scrollbar"></div>'+
  '<a href="#" id="navigation_right" class="navigation_arrow" onclick="navigation_next();">&gt;</div></a>';
  
  Drag.init(document.getElementById("navigation_scrollbar"), null, 25, 170, 290, 290);
  navigation_scroll(25);
}

function navigation_scroll(left)
{
  //25-170
  max=6;
  left=left-25;
  start=Math.floor(left/(145/(navigationLink.length-max)));
  
  text='<table cellpadding="0" cellspacing="0" id="navigation_table">';
  for(i=start; i<start+max && i<navigationLink.length; ++i)
  {
    text+='<tr>'+
          '<td width="3"> </td>'+
          '<td width="18" valign="top" id="number">'+navigationLink[i][1]+' &nbsp;</td>'+
          '<td valign="top">'+
          '<a target="_parent" href="./project/'+navigationLink[i][2]+'/" id="link">'+navigationLink[i][0]+'</a>'+
          '</td>'+
          '</tr>'+
          '<tr>'+
          '<td height="5" colspan="3"> </td>'+
          '</tr>';
  }
  text+='</table>';
  
  if(start==0)
  {
    document.getElementById('navigation_left').className='navigation_arrow navigation_invalid_arrow';
  }
  else
  {
    document.getElementById('navigation_left').className='navigation_arrow';
  }
  
  if(start==navigationLink.length-max)
  {
    document.getElementById('navigation_right').className='navigation_arrow navigation_invalid_arrow';
  }
  else
  {
    document.getElementById('navigation_right').className='navigation_arrow';
  }
  
  document.getElementById('navigation_scrollbar').innerHTML=''+(navigationLink.length-start)+'-'+(navigationLink.length+1-start-max);
  document.getElementById('navigation_content_link').innerHTML=text;
}

function navigation_next()
{
  tmp2=parseInt(document.getElementById('navigation_scrollbar').style.left);
  if(tmp2>=170)
    return false;
  
  tmp3=(145/(navigationLink.length-max));
  tmp=Math.floor(tmp2+tmp3);
  
  start1=Math.floor((tmp2-25)/(145/(navigationLink.length-max)));
  start2=Math.floor((tmp-25)/(145/(navigationLink.length-max)));
  
  if(start1==start2)
    tmp+=1;
  
  if(tmp>170)
    tmp=170;
  
  navigation_scroll(tmp);
  document.getElementById('navigation_scrollbar').style.left=''+tmp+'px';
}

function navigation_prev()
{
  tmp2=parseInt(document.getElementById('navigation_scrollbar').style.left);
  if(tmp2<=25)
    return false;
  
  tmp=(145/(navigationLink.length-max));
  tmp=Math.floor(tmp2-tmp);
  
  start1=Math.floor((tmp2-25)/(145/(navigationLink.length-max)));
  start2=Math.floor((tmp-25)/(145/(navigationLink.length-max)));
  
  if(start1!=start2+1)
    tmp+=1;
  
  if(tmp<25)
    tmp=25;
  
  navigation_scroll(tmp);
  document.getElementById('navigation_scrollbar').style.left=''+tmp+'px';
}

function navigation_start()
{
  navigation.style.visibility="visible";
  
  navigation_close=false;
}

function navigation_end()
{
  if(navigation_close)
    navigation.style.visibility="hidden";
}

function set_navigation_close()
{
  navigation_close=true;
  setTimeout("navigation_end()", waiting);
}
