var test      = (document.getElementById)?true:false;
var Gecko     = ((navigator.userAgent.indexOf("Gecko")>-1)&&test)?true:false;
var MSIE      = ((navigator.userAgent.indexOf("MSIE")>-1)&&test)?true:false;
var NS4       = (document.layers&&!test)?true:false;
var IE4       = (document.all&&!test)?true:false;
test          = (!Gecko&&!MSIE&&!NS4&&!IE4)?true:false;
var dispImage = false;
var ns4Width,ns4Height,supported,imgStyle,delay1,delay2;

window.onload = doFX;

if(NS4){
  ns4Width  = window.innerWidth;
  ns4Height = window.innerHeight;
  window.onresize = function(){
    if ((window.innerWidth != ns4Width) || (window.innerHeight != ns4Height)) history.go(0);
  }
}

function doFX() {
  if (!test) {
    supported = (((NS4)?document.imgSwatch.document:(IE4))?document.all['imgSwatch']:(MSIE||Gecko))?document.getElementById('imgSwatch'):null;
    imgStyle  = (NS4)?document.imgSwatch:supported.style;
  }
}

function showSwatch(imageSrc) {
  if (supported) {
    dispImage = true;
    if (Gecko||MSIE||IE4) {
      supported.innerHTML = '<img src="' + imageSrc + '">';
    } else if(NS4){
      supported.write('<img src="' + imageSrc + '">');
      supported.close();
    }
    imgStyle.top  = "-10px";
    imgStyle.left = "-255px";
    if (delay1) clearTimeout(delay1);
    if (delay2) clearTimeout(delay2);
    delay1 = setTimeout("imgStyle.visibility = 'visible'",100);
  }
}

function hideSwatch() {
  if (supported) {
    delay2 = setTimeout("imgStyle.visibility = 'hidden'",100);
    dispImage = false;
  }
}

