/**********************************************************
Sleight for PNG transparency
(c) 2001, Aaron Boodman
http://www.youngpup.net
**********************************************************/
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
    document.writeln('<style type="text/css">img, input.image { visibility:hidden; } </style>');
    window.attachEvent("onload", fnLoadPngs);
}
function fnLoadPngs() {
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var itsAllGood = (rslt != null && ( Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7.0 ));
    for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
        if (itsAllGood && img.src.match(/(.*)\/(.*)\/(.*)\.png/i) != null) {        
            fnFixPng(img);
            img.attachEvent("onpropertychange", fnPropertyChanged);
        }
        img.style.visibility = "visible";
    }
    var nl = document.getElementsByTagName("INPUT");
    for (var i = nl.length - 1, e = null; (e = nl[i]); i--) {
        if (e.className && e.className.match(/\bimage\b/i) != null) {
            if (e.src.match(/\.png$/i) != null) {
                fnFixPng(e);
                e.attachEvent("onpropertychange", fnPropertyChanged);
            }
            e.style.visibility = "visible";
        }
    }
}
function fnPropertyChanged() {
    if (window.event.propertyName == "src") {
        var el = window.event.srcElement;
	  if (!el.src.match(/x\.gif$/i)) {
            el.filters.item(0).src = el.src;
	  }
    }
}
function dbg(o) {
    var s = "";
    var i = 0;
    for (var p in o) {
        s += p + ": " + o[p] + "\n";
        if (++i % 10 == 0) {
            alert(s);
            s = "";
        }
    }
    alert(s);
}
function fnFixPng(img) {
    var src = img.src;
    img.style.width = img.width + "px";
    img.style.height = img.height + "px";
    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
    img.src = "components/com_virtuemart/shop_image/blank.gif"; 
}
/* xbMarquee-load.js */
function startMarquee(id, height, width, scrollAmount, scrollDelay, direction, behavior) {
  var html = '<img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/bdf7a7ca7ae9ce0a09c8d7825d5064f4.png"  width="150" alt="Line Voltage Recessed Lighting Fixture SERIES 300" border="0" /> <br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/00e57833d3a78984001e3513fc1af2b4.png"  width="150" alt="Pendant light With Metal Shade" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/4b81a0e3e4b080f59d8ed62b4ee94493.png"  width="150" alt="Pendant light With Glass Shade" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/df683c12092a8515a7553e1440ebfa74.png"  width="150" alt="Ceiling Light Fixture Series Nuance" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/256a99192edade04d9bab86470aa5168.png"  width="150" alt="Pendant Light With Metal Shades" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/6483730ee707f70fd22997b9bd65cfde.png"  width="150" alt="Ceiling Light Fixture With Four Spots" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/fe441539f9885db3b2be4d532cc032f4.png"  width="150" alt="Line Voltage Recessed Lighting Fixture SERIES 500" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/687304a4874805c4f9e45bc415f1e6aa.png"  width="150" alt="Flow Track Lighting Kit With Five Spots" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/512b522ffe8237460f6a197c80acecc5.png"  width="150" alt="Line Voltage Recessed Lighting Fixture SERIES 200" border="0" /><br /><br /><br /><br /><img src="http://www.lightingexperts.com/components/com_virtuemart/shop_image/product/8eaf978e1f7d526aab1cb8641dd25eef.png"  width="150" alt="Track Lighting Fixture With Double Spots" border="0" /><br /><br /><br /><br />';
  var marquee = new xbMarquee(id, height, width, scrollAmount, scrollDelay, direction, behavior, html);
  marquee.onmouseover = function () { this.stop(); };
  marquee.onmouseout  = function () { this.start(); };
  window.onload = function () {marquee.start();};
}
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * ***** END LICENSE BLOCK ***** */
function xbMarquee(id, height, width, scrollAmount, scrollDelay, direction, behavior, html) {
  this.id            = id;
  this.scrollAmount  = scrollAmount ? scrollAmount : 6;
  this.scrollDelay   = scrollDelay ? scrollDelay : 30;
  this.direction     = direction ? direction.toLowerCase() : 'left';  
  this.behavior      = behavior ? behavior.toLowerCase() : 'scroll';  
  this.name          = 'xbMarquee_' + (++xbMarquee._name);
  this.runId         = null;
  this.html          = html;
  this.isHorizontal = ('up,down'.indexOf(this.direction) == -1);
  // Huy adds to fix problems in firefox. 
  var browser = '';
  if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer") {
	browser = 'IE';
  }
  if (browser == 'IE') {
	this.scrollAmount  =  1;
	this.scrollDelay   =  30;
  } else {
	this.scrollAmount  =  1;
	this.scrollDelay   =  30;
  }
  // Huy ends
  if (typeof(height) == 'number') {
    this.height = height;
    this.heightUnit = 'px';
  }
  else if (typeof(height) == 'string') {
    this.height = parseInt('0' + height, 10);
    this.heightUnit = height.toLowerCase().replace(/^[0-9]+/, '');
  }
  else {
    this.height = 100;
    this.heightUnit = 'px';
  }
  if (typeof(width) == 'number') {
    this.width = width;
    this.widthUnit = 'px';
  }
  else if (typeof(width) == 'string') {
    this.width = parseInt('0' + width, 10);
    this.widthUnit = width.toLowerCase().replace(/^[0-9]+/, '');
  }
  else {
    this.width = 100;
    this.widthUnit = 'px';
  }
  // xbMarquee UI events
  this.onmouseover   = null;
  this.onmouseout    = null;
  this.onclick       = null;
  // xbMarquee state events
  this.onstart       = null;
  this.onbounce      = null;
  var markup = '';
  if (document.layers) {
    markup = '<ilayer id="' + this.id + 'container" name="' + this.id + 'container" ' +
             'height="' + height + '" ' +
             'width="' + width + '"  ' +
             'clip="' + width + ', ' + height + '" ' +
             '>' + 
             '<\/ilayer>';
  }
  else if (document.body && typeof(document.body.innerHTML) != 'string') {
    markup = '<div id="' + this.id + 'container" name="' + this.id + 'container" ' +
             'style="text-align: center;position: relative; overflow: scroll; ' + 
             'height: ' + this.height + this.heightUnit + '; ' +
             'width: ' + this.width + this.widthUnit + '; ' +
             'clip: rect(0px, ' + this.width + this.widthUnit + ', ' + this.height + this.heightUnit + ', 0px); ' +
             '">' + 
             '<div id="' + this.id + '" style="position:relative;' + 
             (this.isHorizontal ? 'width:0px;' : '') + // if we scroll horizontally, make the text container as small as possible
             '">' +
             (this.isHorizontal ? '<nobr>' : '') +
             this.html +
             (this.isHorizontal ? '<\/nobr>' : '') +
             '<\/div>' +
             '<\/div>';
  }
  else {
    markup = '<div id="' + this.id + 'container" name="' + 
             this.id + 'container" ' +
             'style="text-align: center;position: relative; overflow: hidden; ' + 
             'height: ' + this.height + this.heightUnit + '; ' +
             'width: ' + this.width + this.widthUnit + '; ' +
             'clip: rect(0px, ' + this.width + this.widthUnit + ', ' + this.height + this.heightUnit + ', 0px); ' +
             '">' + 
             '<\/div>';
  }
  document.write(markup);
  window[this.name] = this;
}
// Class Properties/Methods
xbMarquee._name = -1;
xbMarquee._getInnerSize = function(elm, propName) {
  var val = 0;
  if (document.layers) {
    // navigator 4
    val = elm.document[propName];
  }
  else if (elm.style && typeof(elm.style[propName]) == 'number') {
    // opera
    // bug in Opera 6 width/offsetWidth. Use clientWidth
    if (propName == 'width' && typeof(elm.clientWidth) == 'number')
      val = elm.clientWidth;
    else
      val =  elm.style[propName];
  }
  else {
    //mozilla and IE
    switch (propName) {
    case 'height':
       if (typeof(elm.offsetHeight) == 'number')
         val =  elm.offsetHeight;
       break;
    case 'width':
       if (typeof(elm.offsetWidth) == 'number')
         val = elm.offsetWidth;
       break;
    }
  }
  return val;
};
xbMarquee.getElm = function(id) {
  var elm = null;
  if (document.getElementById)
  {
    elm = document.getElementById(id);
  }
  else
  {
    elm = document.all[id];
  }
  return elm;
}
xbMarquee.dispatchUIEvent = function (event, marqueeName, eventName) {
  var marquee = window[marqueeName];
  var eventAttr = 'on' + eventName;
  if (!marquee)
  {
    return false;
  }
  if (!event && window.event)
  {
    event = window.event;
  }
  switch (eventName)
  {
  case 'mouseover':
  case 'mouseout':
  case 'click':
    if (marquee[eventAttr])
      return marquee['on' + eventName](event);
  }
  return false;
};
xbMarquee.createDispatchEventAttr = function (marqueeName, eventName) {
  return 'on' + eventName + '="xbMarquee.dispatchUIEvent(event, \'' + marqueeName + '\', \'' + eventName + '\')" ';
};
xbMarquee.prototype.start = function () {
  var markup = '';
  this.stop();
  if (!this.dirsign) {
    if (!document.layers) {
      this.containerDiv = xbMarquee.getElm(this.id + 'container');
      if (typeof(this.containerDiv.innerHTML) != 'string') {
        return;
      }
      var parentNode    = null;
      if (this.containerDiv.parentNode)
        parentNode = this.containerDiv.parentNode;
      else if (this.containerDiv.parentElement)
        parentNode = this.containerDiv.parentElement;
      if (parentNode && 
          typeof(parentNode.offsetHeight) == 'number' && 
          typeof(parentNode.offsetWidth) == 'number') {
        if (this.heightUnit == '%') {
          this.containerDiv.style.height = 
          parentNode.offsetHeight * (this.height/100) + 'px';
        }
        if (this.widthUnit == '%') {
          this.containerDiv.style.width = 
          parentNode.offsetWidth * (this.width/100) + 'px';
        }
      }
      markup += '<div id="' + this.id + '" name="' + this.id + '" ' +
        'style="position:relative; visibility: hidden;' +
        (this.isHorizontal ? 'width:0px;' : '') + // if we scroll horizontally, make the text container as small as possible
        '" ' +
        xbMarquee.createDispatchEventAttr(this.name, 'mouseover') +
        xbMarquee.createDispatchEventAttr(this.name, 'mouseout') +
        xbMarquee.createDispatchEventAttr(this.name, 'click') +
        '>' +
        (this.isHorizontal ? '<nobr>' : '') +
        this.html +
        (this.isHorizontal ? '<\/nobr>' : '') +
        '<\/div>';
      this.containerDiv.innerHTML = markup;
      this.div                    = xbMarquee.getElm(this.id);
      this.styleObj     = this.div.style;
    }
    else 
    {
      this.containerDiv = document.layers[this.id + 'container'];
      markup = 
        '<layer id="' + this.id + '" name="' + this.id + '" top="0" left="0" ' +
        xbMarquee.createDispatchEventAttr(this.name, 'mouseover') +
        xbMarquee.createDispatchEventAttr(this.name, 'mouseout') +
        xbMarquee.createDispatchEventAttr(this.name, 'click') +
        '>' +
        (this.isHorizontal ? '<nobr>' : '') + 
        this.html +
        (this.isHorizontal ? '<\/nobr>' : '') +
        '<\/layer>';
      this.containerDiv.document.write(markup);
      this.containerDiv.document.close();
      this.div          = this.containerDiv.document.layers[this.id];
      this.styleObj     = this.div;
    }
    switch (this.direction) {
    case 'down':
      this.dirsign = 1;
      this.startAt = -xbMarquee._getInnerSize(this.div, 'height');
      this._setTop(this.startAt);
      if (this.heightUnit == '%')
        this.stopAt = this.height * xbMarquee._getInnerSize(this.containerDiv, 'height') / 100;
      else
        this.stopAt  = this.height;
      break;
    case 'up':
      this.dirsign = -1;
      if (this.heightUnit == '%')
        this.startAt = this.height * xbMarquee._getInnerSize(this.containerDiv, 'height') / 100;
      else     
        this.startAt = this.height;
      this._setTop(this.startAt);
      this.stopAt  = -xbMarquee._getInnerSize(this.div, 'height');
      break;
    case 'right':
      this.dirsign = 1;
      this.startAt = -xbMarquee._getInnerSize(this.div, 'width');
      this._setLeft(this.startAt);
      if (this.widthUnit == '%')
        this.stopAt = this.width * xbMarquee._getInnerSize(this.containerDiv, 'width') / 100;
      else    
        this.stopAt  = this.width;
      break;
    case 'left':
    default:
      this.dirsign = -1;
      if (this.widthUnit == '%')
        this.startAt = this.width * xbMarquee._getInnerSize(this.containerDiv, 'width') / 100;
      else  
        this.startAt = this.width
      this._setLeft(this.startAt);
      this.stopAt  = -xbMarquee._getInnerSize(this.div,'width');
      break;
    }
    this.newPosition          = this.startAt;
    this.styleObj.visibility = 'visible'; 
  }
  this.newPosition += this.dirsign * this.scrollAmount;
  if ( (this.dirsign == 1  && this.newPosition > this.stopAt) ||
       (this.dirsign == -1 && this.newPosition < this.stopAt) ) {
    if (this.behavior == 'alternate') {
      if (this.onbounce) {
        // fire bounce when alternate changes directions
        this.onbounce();
      }
      this.dirsign = -this.dirsign;
      var temp     = this.stopAt;
      this.stopAt  = this.startAt;
      this.startAt = temp;
    }
    else {
      // fire start when position is a start
      if (this.onstart) {
        this.onstart();
      }
      this.newPosition = this.startAt;
    }
  }
  switch(this.direction) {
    case 'up': 
    case 'down':
      this._setTop(this.newPosition);
      break;
    case 'left': 
    case 'right':
    default:
      this._setLeft(this.newPosition);
      break;
  }
  this.runId = setTimeout(this.name + '.start()', this.scrollDelay);
};
xbMarquee.prototype.stop = function () {
  if (this.runId)
    clearTimeout(this.runId);
  this.runId = null;
};
xbMarquee.prototype.setInnerHTML = function (html) {
  if (typeof(this.div.innerHTML) != 'string') {
    return;
  }
  var running = false;
  if (this.runId) {
    running = true;
    this.stop();
  }
  this.html = html;
  this.dirsign = null;
  if (running) {
    this.start();
  }
};
if (document.layers) {
  xbMarquee.prototype._setLeft = function (left) {
    this.styleObj.left = left;
  };
  xbMarquee.prototype._setTop = function (top) {
    this.styleObj.top = top;
  };
}
else {
  xbMarquee.prototype._setLeft = function (left) {
    this.styleObj.left = left + 'px';
  };
  xbMarquee.prototype._setTop = function (top) {
    this.styleObj.top = top + 'px';
  };
}
/* popup.js */
function displayPolicies() {
	document.write('<a href="javascript:var w=window.open(\'http://www.lightingexperts.com/index2.php?option=com_virtuemart&page=shop.privacy&pop=1&Itemid=99999999\', \'win2\', \'top=0, left=0, status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=768,directories=no,location=no\');w.focus();" title="">Privacy Policy</a>');
	document.write(' - ');
	document.write('<a href="javascript:var w=window.open(\'http://www.lightingexperts.com/index2.php?option=com_virtuemart&page=shop.tos&pop=1&Itemid=99999999\', \'win2\', \'top=0, left=0, status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=768,directories=no,location=no\');w.focus();" title="">Terms of Service</a>');
	document.write(' - ');
	document.write('<a href="javascript:var w=window.open(\'http://www.lightingexperts.com/index2.php?option=com_virtuemart&page=shop.rp&pop=1&Itemid=99999999\', \'win2\', \'top=0, left=0, status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=800,directories=no,location=no\');w.focus();" title="">Shipping and Return Policy</a>');
}

