/*
	<script type="text/javascript" >
	$(function(){
		$(ANCHOR_SELECTOR).Img_switch(IMG_SELECTOR,EVENT,IMG_SIZE);
	});
	</script>
	
	ANCHOR_SELECTOR     : Set CSS selector ( exp : '.switch' )
	IMG_SELECTOR        : Set IMG selector ( exp : 'IMG#imgNumber1' )
	EVENT(optional)     : Default Value : click
			Set Switch Event ( exp : 'click') 
			-- Possible event values (Same as "Jquery bind" event values)--
			blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick,  mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select,  submit, keydown, keypress, keyup, error
	IMG_SIZE(optional)  : Default Value : false
			false : The new image width and height inherit from first one. 
			true  : The new image width and height are replaced with the original size.
			do not enclose in quotation marks.
*/

(function($){
$.fn.Img_switch = function(img_id,event,overwrite){
	if(overwrite=='undefined'){overwrite=false}
	if(event=='undefined'){event='click'}
	return this.each(function(){
		var el = $(this);
		var pre = new Image(); pre.src = el.attr('href');/*Preload*/
		pre.title = el.find('img').attr('alt');
		el.bind(event, function(){
			$(".active").removeClass("active");
			el.closest("div").addClass("active");
			$(img_id).attr('src',pre.src).attr('title','').attr('alt',pre.title);
			if(overwrite==true){$(img_id).width(pre.width).height(pre.height)}
			return false;
		});
	});
}
})(jQuery);

$(function(){
	$('.switch').Img_switch('#imgNumber1','click');
	$('.switch').Img_switch('#imgNumber1','focus');
});
/*
	$(ANCHOR_SELECTOR).Img_switch(IMG_SELECTOR,EVENT,IMG_SIZE);
	ANCHOR_SELECTOR : クリックを監視するセレクタを指定
	IMG_SELECTOR : 切り替え先の画像のセレクタを指定
	EVENT（オプション） : クリックなどのイベント（jqueryのイベントと同じ）を指定。
	                      指定なしの場合はクリック
			例 : click,mouseover,focus,
			このほか、使用頻度は低いと思いますが、以下のイベントが指定できます。
			blur, load, resize, scroll, unload, beforeunload, dblclick, mousedown, mouseup, mousemove, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error
	IMG_SIZE（オプション） : デフォルトはfalse。
				false：切り替わる画像は、切り替え前の画像サイズにリサイズされます。
				true：切り替わる画像は、切り替え前の画像サイズにリサイズされません。（切り替わる画像は原寸のまま）
*/


