/*
* File Name     : opacity.js
* Dependencies  : browser.js
* Description   : Enables transparent PNG images in IE.
* Version       : 1.0.1
* Date Modified : 8/9/2007
* Usage         : Copyright 2007 Craig Phares. All rights reserved.
*/

// if using Windows Internet Explorer, display PNGs with AlphaImageLoader
if (gBrowser.ie && gBrowser.win) {
	var pngAlpha = true;
}

/*
* OpacityObject
* Used to display a transparent PNG
*/
function OpacityObject(divId,strPath) {
	this.id = divId;
	this.path = strPath;
	this.layerObject = document.getElementById(divId);
	this.layerObject.parent = this;
	this.styleObject = this.layerObject.style;
	this.setBackground();
}

/*
* setBackground()
* Display the transparent background properly for the PNG
*/
OpacityObject.prototype.setBackground = function() {
	if (pngAlpha) {
		this.styleObject.backgroundImage = "none";
		this.styleObject.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+this.path+'",sizingMethod="image")';
	}
}

/*
* setRollover(rolloverPath)
* set a rollover state
*/
OpacityObject.prototype.setRollover = function(rolloverPath) {
	this.rolloverPath = rolloverPath;
	this.layerObject.onmouseover = function() {
		this.parent.layerObject.className = "over";
		if (pngAlpha) {
			this.parent.styleObject.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+this.parent.rolloverPath+'",sizingMethod="image")';
		} else {
			this.parent.styleObject.backgroundImage = "url("+this.parent.rolloverPath+")";
		}
	}
	this.layerObject.onmouseout = function() {
		if (pngAlpha) {
			this.parent.styleObject.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+this.parent.path+'",sizingMethod="image")';
		} else {
			this.parent.styleObject.backgroundImage = "url("+this.parent.path+")";
		}
	}
}

/*
* setLink(linkURL)
* set the click-through link
*/
OpacityObject.prototype.setLink = function(linkURL) {
	this.linkURL = linkURL;
	this.layerObject.onclick = function() {
		location.href = this.parent.linkURL;
	}
}


