/* nice function that gives each admin-icon a nice mouseover */
function iconSwitcher()
{
  for(i=0;i<document.images.length;i++)
  {
    var imgobj = document.images[i];
    if(imgobj.src.indexOf("/resources/images/icons/")>-1 && imgobj.parentNode.tagName.toUpperCase()=='A')
    {
      imgobj.style.margin = '0px 0px 1px 1px';
      imgobj.onmouseover = function()
      {
        this.style.margin = '1px 1px 0px 0px';
      }
      imgobj.onmouseout = function()
      {
        this.style.margin = '0px 0px 1px 1px';
      }
    }
  }
}

addLoadEvent(iconSwitcher);

//cleanup the directorynames
function cleanDirname(dest,val)
{
  if(dest.value.length==0)
  {
    var cleaned = val.toLowerCase();
    var repl = ["їїїїїабвгдезийклмнопстуфхцшщъыьэя","-----aaaaaaceeeeiiiinoooooouuuuyy"];
    
    cleaned = cleaned.replace(/[\!\?\$#\(\)\*\&\^\%\@\'\/\"\]\[\;]/gi, "");
    cleaned = cleaned.replace(/[ _\-]+/gi, "-");

    cleaned = cleaned.split("");
    
    for(var i=0;i<cleaned.length;i++)
    {
      var fnd = repl[0].indexOf(cleaned[i]);
      if(fnd>=0)
      {
        cleaned[i] = repl[1].split("")[fnd];
      }
    }
    dest.value = cleaned.join("");
  }
}

function DoConfirm(message, url) {
	if(confirm(message)) window.open(url);
}