(function($){
	$.fn.folderswitch=function(setting){
	
		$.fn.folderswitch.version = '0.01-beta-2';
		$.fn.folderswitch.url     = 'http://jsgt.org/mt/01/';
		$.fn.folderswitch.author  = 'Toshiro Takahashi';
		$.fn.folderswitch.lisence = 'Public Domain';
		
		var contents=this,
		    topElm="topElm"+(new Date()).getTime();
	
		setting=$.extend({
			msg          : '',
			iniDisplay   : 'none',
			plusImg      : 'http://jsgt.org/mt/js/o2.png',
			minusImg     : 'http://jsgt.org/mt/js/x2.png',
			plusClicked  : function(li,contents){$(contents).css("display","none")},
			minusClicked : function(li,contents){$(contents).css("display","block")}
		},setting);

		if(setting.iniDisplay=='none'){
			setting.currImg=setting.plusImg;
			setting.currClass='plus';
		} else { 
			setting.currImg=setting.minusImg;
			setting.currClass='minus';
		}
		
		$(contents)
			.wrap(
				$("<div class='topElms'>") 
				.attr("id",topElm)
			)
			.before(
				$("<img class='opncls'>")
					.attr("src",setting.currImg)
					.attr("width","30")
					.attr("height","17")
					.addClass(setting.currClass)
					
			)
			.before(setting.msg)
			.css("display",setting.iniDisplay) 
			
		$.fn.folderswitch.myrec=[];
		$.fn.folderswitch.myrec['zmcnt']=0;
		
		function zoomUp(img,wh){
			$.fn.folderswitch.myrec['orig']=wh;
			$(img).animate({ width:'100px',height:'56px',"opacity": 0.6},"easein");
			$.fn.folderswitch.myrec['zmcnt']++;
		}
		function zoomDown(img){
			if($.fn.folderswitch.myrec['zmcnt']>=2)return;
			$(img).animate({ 
				width:$.fn.folderswitch.myrec['orig'].w+'px',
				height:$.fn.folderswitch.myrec['orig'].h+'px',
				opacity:$.fn.folderswitch.myrec['orig'].o 
			},"easein")
		}

		return $("img.opncls","#"+topElm)
			/*.hover(
				function(){ zoomUp(this,{
						//w:this.width,h:this.height,o:1
						w:30,h:17,o:1
					}
				)},
				function(){ zoomDown(this)}
			)*/
			.click(function(){
				if($(this).hasClass("plus")){
					$(this)
						.removeClass("plus")
						.addClass("minus")
						.attr("src",setting.minusImg);
					setting.minusClicked(this,contents);
					$.fn.folderswitch.myrec['zmcnt']=0;
					//zoomDown(this);
				} else {
					$(this)
						.removeClass("minus")
						.addClass("plus")
						.attr("src",setting.plusImg);
					setting.plusClicked(this,contents);
					$.fn.folderswitch.myrec['zmcnt']=0;
					//zoomDown(this);
				}
			})
	}

})(jQuery)