(function() {
	
jQuery.minmax = function( value, min, max )
{
	return value < 0 ? max : ( value > max ? 0 : value );
};

jQuery.urlencode = function( s )
{
	var code = "";
	for (var i = 0; i < s.length; i++)
	{
		if( s.charAt(i) == " " )
		{
			code += "+";
		}
		else if( s.charAt(i) == "+" )
		{
			code += "%2B";
		}
		else if( s.charCodeAt(i) > 127 )
		{
			code += encodeURI( s.charAt(i) );
		}
		else
		{
			code += escape( s.charAt(i) );
		}
	}
	return code;
};


/* Mozilla-specific opacity setting */

var to = document.createElement( 'div' );
if( typeof( to.style.MozOpacity ) != 'undefined' ) 
{
	jQuery.fn.opacity = function( o )
	{
		if( typeof( o ) == 'undefined' && this[0] )
			return this[0].style.MozOpacity * 100;
		
		this.each( function( i, ob )
		{
			// opacity values range from 0 to 1
			ob.style.MozOpacity = (o/100); // - .01;
		} );
	};
} 

/* CSS3 opacity setting */
else if ( typeof( to.style.opacity ) != 'undefined' ) 
{
	jQuery.fn.opacity = function( o )
	{
		if( typeof( o ) == 'undefined' && this[0] )
			return this[0].style.opacity * 100;

		this.each( function( i, item )
		{
			// opacity values range from 0 to 1
			item.style.opacity = (o/100); // - .01;
		} );
	}
} 

/* IE-specific opacity setting */
else if ( typeof( to.style.filter ) != 'undefined' ) 
{
	jQuery.fn.opacity = function( o )
	{
		if( typeof( o ) == 'undefined' && this[0] )
			return this[0].style.filter;

		this.each( function( i, item )
		{
			// opacity values range from 0 to 100
			item.style.filter = "alpha(opacity="+ o +")";
		} );
	}
}

else
	throw new Error( "Could not determine opacity-handling, sorry" );

})();