/**
 * (C) KAYAC Inc. <http://www.kayac.com/>
 * License: MIT License <http://www.opensource.org/licenses/mit-license.php>
 */

(function($) {
	$.fn.roll = function(o) {
		o = o || '_o';
		return this.each(function() {
			if (!this.src) return;
			var self = this;
			var out  = this.src;
			var over = this.src.replace(/(\.[^.]+$)/, o+'$1');
			$('<img src="'+over+'"/>').load(function() {
				$(self).hover(
					function() { this.src = over; },
					function() { this.src = out; }
				);
			});
		});
	};
})(jQuery);



$(function() {
	$('.btn').roll();

	$('#badgeRegister').submit(function() {
		var aid = $('#aid').val();
		aid = aid ? '?aid='+ aid : '';

		$('#badgeCode')
			.val('<script type="text/javascript" src="http://kaibutsukun.in/js/kaibutsukun.js'+aid+'" charset="UTF-8"></script>')
			[0].focus();

		return false;
	});
});
