var badBrowser;
var pixel = new Image();

pixel.src = "images/pixel.gif";

$(document).ready(function() {
   $( "#slideshow" ).cycle( { time: 5000 } );
   $( "#navigation_top img:not( .separator ), #tell_a_friend img, #navigation_left ul img" ).mouseover( switchOn );
   $( "#navigation_top img:not( .separator ), #tell_a_friend img, #navigation_left ul img" ).mouseout( switchOff );

   badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");

   if( badBrowser ) {
      // get all pngs
      $( "img[src$=.png]" ).each( function() {
         if( !this.complete ) {
            this.onload = function() { fixPng( this ) };
         } else {
            fixPng( this );
         }
      } );
   }
} );

function fixPng( png ) {
   var src = png.src;
   if( !png.style.width ) { png.style.width = $( png ).width(); }
   if( !png.style.height ) { png.style.height = $( png ).height(); }
   
   // replace by pixel image
   png.onload = function() { };
   png.src = pixel.src;

   // set filter ( display original image )
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}

function switchOff() {
   if( badBrowser && ( this.src.indexOf( "pixel.gif" ) > -1 ) ) {
      newSrc = this.filters.item( "DXImageTransform.Microsoft.AlphaImageLoader").src.replace( "_on", "_off" );
      this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + newSrc + "',sizingMethod='scale')";
   }
   else {
      this.src = this.src.replace( "_on", "_off" );
   }
}

function switchOn() {
   if( badBrowser && ( this.src.indexOf( "pixel.gif" ) > -1 ) ) {
      newSrc = this.filters.item( "DXImageTransform.Microsoft.AlphaImageLoader").src.replace( "_off", "_on" );
      this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + newSrc + "',sizingMethod='scale')";
   }
   else {
      this.src = this.src.replace( "_off", "_on" );
   }
}

