/**
 * jQuery.imgAlphaChange - Easy img alpha changer using jQuery.
 * Copyright (c) 2010 Satoshi Miwa 310430@gmail.com | http://310430.org
 * Date: 05/16/2011
 * @author Satoshi Miwa
 * @version 2.0.0
 */

(function($){

	function formatCodes(locale) {
	};

 	jQuery.fn.imgAlphaChange = function(options){

	var options = jQuery.extend({
		returnBasic: true,
		fadeOut: 0.7,
		fadeIn: 1,
		fadeOutLevel: 0,
		fadeInLevel: 0
	}, options);

		return this.each(function(){
			var tagName = $(this)[0].tagName;
			switch(tagName) {
				case 'A':
					alphaMotion($(this).find('img'));
					break;
				case 'IMG':
					alphaMotion($(this));
					break;
				case 'INPUT':
					if($(this).attr('type') == 'image')	alphaMotion($(this));
					break;
			};
		});

		function alphaMotion(imgTag) {

			if(options.returnBasic) {
				imgTag.mouseout(changeAlphaBasic);
			}
			imgTag.mouseover(changeAlphaChange);

			function changeAlphaBasic() {
				$(this).fadeTo(options.fadeInLevel,options.fadeIn);
			}
			function changeAlphaChange() {
				$(this).fadeTo(options.fadeOutLevel,options.fadeOut);
			}
		}
	}
})(jQuery);

$(document).ready(function(){

	$('a.alpha').imgAlphaChange();
	$('img.alpha').imgAlphaChange();
	$('input.alpha').imgAlphaChange();

});

