var AL_ACTIVE_PREFIX='<img src="http://myoga.co.il/zope/gfx/active-bullet.gif" alt="" title="" height="6" width="4" style="padding:0 0 1px 4px" border="0" />';
var AL_LOADING_PREFIX='<img src="http://myoga.co.il/zope/gfx/loading-bullet.gif" alt="" title="" height="6" width="4" style="padding:0 0 1px 4px" border="0" />';
var AL_ACTIVE_CLASS='active-link';
var AL_INACTIVE_CLASS='reverse-hover-underline';

function alDeprefix(s) {
 // remove <img> prefix
 if (s.charAt(0)=='<')
  return s.slice(s.lastIndexOf('>')+1);
 return s;
}

// ----- al_links are ids of links, al_iframes are ids of iframes that might contain active links

var al_links=new Array();
var al_iframes=new Array();

function addActiveLink(id) {
 al_links.push(id)
}

function addActiveLinkIframe(id) {
 al_iframes.push(id)
}

function ActiveLinkHilite(id,prefix) {
 // id can be '' if you want to turn all off
 // recurses into all al_iframes
 // default prefix is AL_ACTIVE_PREFIX
 if (!prefix)
  prefix=AL_ACTIVE_PREFIX;
 for (i=0 ; i<al_links.length ; i++) {
  var the_id=al_links[i];
  var the_link=document.getElementById(the_id);
  var the_text='';
  var the_text=the_link.innerHTML;
  if (the_id==id) {
   if (the_text) {
    the_link.innerHTML=prefix+alDeprefix(the_text);
    the_link.className=AL_ACTIVE_CLASS;
   }
  } else {
   if (the_text) {
    the_link.innerHTML=alDeprefix(the_text);
    the_link.className=AL_INACTIVE_CLASS;
   }
  }
 }
 for (i=0 ; i<al_iframes.length ; i++) {
  document.getElementById(al_iframes[i]).contentWindow.ActiveLinkHilite(id,prefix);
 }
}

window.al_current='';

function ActiveLinkHiliteParent(id) {
 // called from skin=iframe
 // Note that calling window's ActiveLinkHilite(id)
 // also be invoked, but would do nothing, unless we come up with a really weird skin ;)
 // timeout voodoo is against race-condition. Ugly as life, but so's life
 window.parent.al_current=id;
 window.parent.ActiveLinkHilite(id); 
}

function alFlick(link) {
 // called to as onClick to set "loading" state. Name is historical.
 window.parent.ActiveLinkHilite(link.id,AL_LOADING_PREFIX);
}

function alRefresh() {
 // called by iframe_item_list
 if (window.parent.al_current)
  window.parent.ActiveLinkHilite(window.parent.al_current);
}
