// JavaScript Document


jQuery.fn.rollover  = function(suffix){
	this.each( function(){
		if(this.src.indexOf(suffix) != -1) return;				
		var extension = this.src.substr( this.src.lastIndexOf('.'), 4 );
		new Image().src = this.src.replace( extension, suffix + extension );
		$(this).attr({
			'rollover' : 'enabled',
			'newsrc' : this.src.replace( extension, suffix + extension ),
			'oldsrc' : this.src
		});
		$(this).bind('mouseover', function(e){
			var el = $(this);
			if(el.attr('rollover') && el.attr('rollover') == "enabled" && this.src.indexOf('_active') == -1)	this.src = el.attr('newsrc');
		});
		$(this).bind('mouseout', function(e){
			var el = $(this);
			if(el.attr('rollover') && el.attr('rollover') == "enabled")	this.src = el.attr('oldsrc');
		});
	});
	return this;
};

jQuery.fn.disableRollover = function(){
	this.each( function(){
		var el = $(this);
		if(el.attr('rollover') && el.attr('rollover') == "enabled")	el.attr('rollover', 'disabled');
	});
	return this;
};

jQuery.fn.enableRollover = function(){
	this.each( function(){
		var el = $(this);
		if(el.attr('rollover') && el.attr('rollover') == "disabled")	el.attr('rollover', 'enabled');
	});
	return this;
};

jQuery.fn.toggleRollover = function(){
	this.each( function(){
		var el = $(this);
		if(el.attr('rollover') && el.attr('rollover') == "enabled"){
			el.attr('rollover', 'disabled');
		}else if(el.attr('rollover') && el.attr('rollover') == "disabled"){
			el.attr('rollover', 'enabled');
		}
	});
	return this;
};
