//-------------------------MOUSEOVER-------------------------------//

function changeImages() 
{
  if (document.images) 
  {
    for (var i=0; i < changeImages.arguments.length; i+=2) 
    {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

//-------------------------POPUPS-------------------------------//

function popurl(link, width, height)
{
  var externalWindow;

  externalWindow = window.open(link,"external",'toolbar,location,directories,status,menubar,scrollbars,resizable,left=0,top=0,width='+width+',height='+height);
 // externalWindow.resizeTo(width,height);
  externalWindow.focus();
}


function popup(link, width, height)
{
  var photoWindow;

  photoWindow = window.open(link,"viewer",'toolbar=0,location=0,directories=0,status,menubar=0,scrollbars=0,resizable=0,left=0,top=0,width='+width+',height='+height);
  photoWindow.resizeTo(width,height);
  photoWindow.focus();
}

//-------------------------MENUS-------------------------------//


var currentRootElement = '';
var currentImgId = '';


function showMenu(rootElement, imgId) 
{
  if (currentRootElement != '') 
  {
    hideMenu(currentRootElement, currentImgId);
  }

  currentRootElement = rootElement;
  currentImgId = imgId;

  // highlight(document.getElementById(imgId), 'images', true);

  var blank = getBlankMenu(rootElement);

  if (blank != null) 
  {
    blank.style.width='150px';
  }

  var submenu = document.getElementById(imgId + '_menu');

  if (submenu != null) 
  {
    submenu.style.display="block";
  }
}


function showMenu2(element, name, msg) 
{
  document.getElementById(name).style.display='block';
}	


function hideMenu(rootElement, imgId) 
{
  // highlight(document.getElementById(imgId), 'images',  false);

  var blank = getBlankMenu(rootElement);

  if (blank != null) 
  {
    blank.style.width='';
  }

  var submenu = document.getElementById(imgId + '_menu');

  if (submenu != null) 
  {
    submenu.style.display="none";
  }
}


function hideMenu2(element, name) 
{
  document.getElementById(name).style.display='none';	
}


function getBlankMenu(element) 
{
  var divs = element.getElementsByTagName('div');

  if (divs != null) 
  {
    var dlen = divs.length;

    for (var i=0; i < dlen; i++) 
    {
      attr = divs[i].className;

      if (attr != null && attr != undefined && attr == 'vmenu_blank') 
      {
        return divs[i];
      }
    }
  }
}


function highlight(imgElement, imgDirectory, doHighlight) 
{
  if (doHighlight) 
  {
    if (currentRootElement != '') 
    {
      hideMenu(currentRootElement, currentImgId);
    }  

    imgElement.src = imgDirectory + "/" + imgElement.id + "_o.gif";
  } 
  else 
  {
    imgElement.src = imgDirectory + "/" + imgElement.id + ".gif";
  }
}

