function preloadImages(imglist)
{
  for(var i=0; i<imglist.length; i++)
  {
    var img = imglist[i].replace(/^.*?([^\/]+?)\.(?:jpg|gif|png)$/g, '$1');
    window[img] = new Image();
    window[img].src = imglist[i];
  }
}

function changeImg(target, img)
{
  if(target && img)
  {
    target.src = img.src;
  }
}

function changeImgAuto(target, mode)
{
  if(target && mode)
  {
    var img = target.src.replace(/^.*?([^\/]+?)_(?:over|out|on|off)\.(?:jpg|gif|png)$/g, '$1');
    target.src = eval(img+'_'+mode).src;
  }
}

function replaceIE6PNGs()
{
  var Body = document.getElementsByTagName('body')[0];
  var BodyChilds = Body.getElementsByTagName('*');
  
  for(var i=0; i < BodyChilds.length; i++)
  {
    var Child = BodyChilds[i];
    
    if(Child.nodeType != 1)
      continue;
    
    var matchstr = /[a-zA-Z]+[a-zA-Z0-9_-]*\.png/gi;
    var PNGImage = null;
    
    if(Child.style.backgroundImage.match(matchstr))
    {
      PNGImage = Child.style.backgroundImage.match(matchstr);
    }
    else if(Child.style.background.match(matchstr))
    {
      PNGImage = Child.style.background.match(matchstr);
    }
    
    if(PNGImage)
    {
      Child.style.background = '';
      Child.style.backgroundImage = '';
      Child.style.backgroundPosition = '';
      Child.style.backgroundRepeat = '';
      Child.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/'+PNGImage+'", sizingMethod="scale")';
    }
  }
}
