// vim: set tabstop=4 shiftwidth=4 foldmethod=marker :

/**
 * Originally from Apple's iLife website. Modified for Plaxo's structure.
 * @depends basic.js (for plx_Browser)
 */
var fade = true; // emergency toggle
// {{{ - setOpacity(opacity)
/**
 * Modify the opacity style no matter what the browser is.
 * @param opacity an integer from 0 to 100.
 */
Object.prototype.setOpacity = function(opacity)
{
    //alert(this.id+": "+opacity);
    this.style.opacity = (opacity / 101);
    this.style.MozOpacity = (opacity / 100);
    this.style.KhtmlOpacity = (opacity / 100);
    this.style.filter = "alpha(opacity=" + opacity + ")";
}
// }}}

Object.prototype.cleanUpProperties = function() {
  var props = ['fade', 'bindWithArguments', 'setOpacity', 'cleanUpProperties'];

  var i = 0;
  for (i = 0; i < props.length; i++) {
    if (this[props[i]]) {
      this[props[i]] = null;
      // Deleting actually makes the properties get re-set.
    }
  }
}
//

// {{{ - fade(duration,startOpacity,endOpacity,interval,step,curve)
Object.prototype.fade = function(duration,startOpacity,endOpacity,interval,step,curve) {
    //if(fade) {

        this.interval = interval; 
        this.setOpacity(startOpacity);
 
        if(startOpacity == 0) {this.style.visibility = 'visible';}


        //if(Browser.isIE()) {
        if (brz.ie) {
            if(this.id == 'newfeatureinfo') {
                this.style.zIndex = '100';
                var movieframe = document.getElementById('movieframe');
                movieframe.style.height = this.offsetHeight + 'px';
            } else if(!(this.id == 'sharebug')&&!(this.id == 'newfeatureinfo')&&!(this.id == 'gallery')) {
                this.style.height = this.offsetHeight+'px';
            }
            this.style.zoom = '1';
            //step = step * 2;
        }
        this.changeOpacity = function (startOpacity,endOpacity) {
            var changeOpacityST = null;
            if (startOpacity < endOpacity) {
                if (startOpacity <= endOpacity) {
                    this.setOpacity(startOpacity);
                    startOpacity += step;
                    changeOpacityST = window.setTimeout(this.changeOpacity.bindWithArguments(this,startOpacity,endOpacity),this.interval);
                }
            } else if (startOpacity > endOpacity) {
                if (startOpacity >= endOpacity) {
                    this.setOpacity(startOpacity);
                    startOpacity -= step;
                    changeOpacityST = window.setTimeout(this.changeOpacity.bindWithArguments(this,startOpacity,endOpacity),this.interval);
                }       
            } else if (startOpacity == endOpacity) {
                this.setOpacity(startOpacity);
                clearTimeout(changeOpacityST);
            }
        };
        this.changeOpacity(startOpacity,endOpacity);

/*
    } else {
        this.style.visibility = 'visible';
        this.setOpacity = function () {
            this.style.opacity = (100 / 101);
            this.style.MozOpacity = (100 / 100);
            this.style.KhtmlOpacity = (100 / 100);
            this.style.filter = "alpha(opacity=100)";
        };
    }
*/
    return true;
};
// }}}
