/*	name			: ClassBehaviours, the javascript framework based on class-name parsing	update			: 9.2.2	author			: Maurice van Creij	dependencies	: jquery.classbehaviours.js	info			: http://www.classbehaviours.com/

    This file is part of jQuery.classBehaviours.
    
    ClassBehaviours is a javascript framework based on class-name parsing.
    Copyright (C) 2008  Maurice van Creij

    ClassBehaviours is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClassBehaviours is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ClassBehaviours. If not, see http://www.gnu.org/licenses/gpl.html.*/

	// create the jQuery object if it doesn't already exist
	if(typeof(jQuery)=='undefined') jQuery = function(){};
	
	// create the root classbehaviours object if it doesn't already exist
	if(typeof(jQuery.classBehaviours)=='undefined') jQuery.classBehaviours = function(){};
	
	// create the handlers child object if it doesn't already exist
	if(typeof(jQuery.classBehaviours.handlers)=='undefined') jQuery.classBehaviours.handlers = function(){}

	// preload cosmetic tweak
	if(document.all && (navigator.userAgent.indexOf('MSIE 6.0')>-1 || navigator.userAgent.indexOf('MSIE 5')>-1) && navigator.userAgent.indexOf('Opera')<0)
			document.writeln("<style>img.pngAlpha {visibility:hidden;}</style>");
			
	// replace image with transparent version, invoke activeX background loader
	jQuery.classBehaviours.handlers.pngAlpha = {
		// properties
		name: 'pngAlpha',
		// methods
		start: function(node){
			this.process(node);
			node.onload = this.process;
		},
		// events
		process: function(that){
			var objNode = (typeof(this.nodeName)=='undefined') ? that : this ;
			// for the downlevel browser MSIE and the image has not been processed before
			if(
				typeof(objNode.style.filter)!='undefined'
				&& (navigator.userAgent.indexOf('MSIE 6.0')>-1 || navigator.userAgent.indexOf('MSIE 5')>-1)
				&& navigator.userAgent.indexOf('Opera')<0
				&& objNode.src.indexOf('.png')>-1
			){
				// change the image styles
				objNode.style.width		= objNode.width + 'px';
				objNode.style.height	= objNode.height + 'px';
				objNode.style.filter	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + objNode.src + "', sizingMethod='crop')";
				// replace the original with the alpha variant
				objNode.src = objNode.src.replace('.png', '.gif');
				objNode.style.visibility = 'visible';
			}
		}
	}
			
	// add this addon to the jQuery object
	if(typeof(jQuery.fn)!='undefined'){
		// extend jQuery with this method
		jQuery.fn.pngAlpha = function(){
			return this.each(
				function(){
					jQuery.classBehaviours.handlers.pngAlpha.start(this);
				}
			);
		};
		// set the event handler for this jQuery method
		$(document).ready(
			function(){
				$(".pngAlpha").pngAlpha();
			}
		);
	}

