function $(id)   { return document.getElementById(id); }
function go(url) { self.location.href = url } 

function preload_images()
{
  var img = new Object(); 

  arguments = preload_images.arguments;

  for( i=0; i < arguments.length; i++) 
  {
    img[i]     = new Image();
    img[i].src = arguments[i];
  }

  i = 0;
  images = document.getElementsByTagName('img')
  while( image = images[i++] )
  {
    if( image.className.match(/over/, "") )
    {
      image.onmouseover = function() { this.src = get_over_src(this.src); } 
      image.onmouseout  = function() { this.src = get_normal_src(this.src); }  
    } 

    /* blur if require */
    image.parentNode.onfocus = function() { this.blur() }
  }
}

function get_current_page()
{
  var re = new RegExp("([0-9]+)\.page$","i");

  result = re.exec( location );

  if( result ) 
    return RegExp.$1;

  return 0;
}

function fix_png_images()
{ 
  var blank_src = "/i/n.gif";

  if( !(/MSIE (5|6).+Win/.test(navigator.userAgent)) )
    return;

  i = 0;
  images = document.getElementsByTagName('img');

  while( image = images[i++] )
  {
    if( /\.png$/.test( image.src.toLowerCase() ) ) 
    {
      src = image.src ;
      
      w = image.width ;
      h = image.height ;

      // set blank image
      image.src = blank_src;

      // set filter
      image.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";

      // set width & height
      image.runtimeStyle.width  = w ;
      image.runtimeStyle.height = h ;
    }
  }
} 

if (window.attachEvent && navigator.userAgent.indexOf("Opera")==-1) 
  window.attachEvent("onload", fix_png_images);

onload = function() { ondload_function() }

ondload_function = function() 
{
  preload_images('/i/bg_products1_over.png','/i/bg_products2_over.png','/i/bg_products4_over.png','/i/bg_products3_over.png','/i/bg_products5_over.png','/i/bg_products6_over.png','/i/bg_products7_over.png','/i/bg_products8_over.png');

  if( $('products-header') )
  {
    var a = $('products-header').getElementsByTagName('A');

    for (var i=0; i< a.length; i++) 
    {
      a[i].onfocus = function() { this.blur() }
      a[i].onmouseover = function() { set_current_visible(false); this.className += " over"}
      a[i].onmouseout  = function() { set_current_visible(true); this.className = this.className.replace(new RegExp(" over"), ""); } 
    } 
  }

  document.onkeydown = function(e) 
  {
    if (!e) e = window.event;
    var k = e.keyCode;

    if (e.ctrlKey && $('news') )  
    {
      var cp = get_current_page();

      if (k == 37 && $('prevpagelnk') ) 
        go( $('prevpagelnk').href ); 

      if (k == 39 && $('nextpagelnk') ) 
        go( $('nextpagelnk').href ); 
    }
  }
}

function set_current_visible( state )
{
  var a = $('products-header').getElementsByTagName('A');

  for (var i=0; i< a.length; i++) 
    if( a[i].className.match(/current/) )
    {
      if( state == false )
        a[i].className = a[i].className.replace(new RegExp("current"), "hidden_current");
      else
        a[i].className = a[i].className.replace(new RegExp("hidden_current"), "current");
    }

  var s = $('products-header').getElementsByTagName('STRONG');

  for (var i=0; i< s.length; i++) 
    if( s[i].className.match(/current/) )
    {
      if( state == false )
        s[i].className = s[i].className.replace(new RegExp("current"), "hidden_current");
      else
        s[i].className = s[i].className.replace(new RegExp("hidden_current"), "current");
    }
}
