/**
 * MULTICOL.js
 * version 1.1
 * Kotaro Imai : HOKYPOKY.(http://hokypoky.info)
 * (c) Licensed GNU General Public License.
 */
if(typeof info=="undefined"){
	var info={}
}

if(typeof info.hokypoky=="undefined"){
	info.hokypoky={}
}

info.hokypoky.Multicol=new function(){//-----
	jQuery.fn.extend({//----
		//スタイル適用
		multicol:function(a){//---[*]
			this.each(function(){//--
				var b=parseInt($(this).css("line-height"));
				var c=(a.colNum?a.colNum:2);
				var l=(a.colMargin?a.colMargin:10);
				var d=parseInt($(this).width());
				var g=($(this).width()-l*(c-1))/c-0.1;
				
				$(this).find("> *:last").css({marginBottom:0}).end().find("img").each(
					/* img用の処理 */
					function(){
						$(this).css({width:g})
						var i=this.height%b;
						if(i!=0){
							i=(i<b/2?-i:b-i)
						}
						$(this).css({marginBottom:b})
						$(this).css({marginTop:i})
						
					}
				).end().css({width:g}).end();
		
				var k=parseInt($(this).height());
				var j=(parseInt(k)/parseInt(b))%parseInt(c);
				
				if(j!=0){
					k=k+b*(c-j)
				}
				
				
				
				$(this).css({
					height:k+"px",overflow:"hidden"}
					).wrapInner("<div class='multicolInner'></div>").end();
				
				var h=$(this).html();
				
		
				$(this).css({height:k/c+"px",width:d}).html("").end();
		
				for(var f=2;f>=0;f--){
					var e=$(h).css({"float":f!=(c-1)?"right":"right",marginTop:-($(this).height()*f)+"px",width:g,marginRight:f!=(c-1)?l+"px":0+"px",overflow:"hidden"});
					$(this).append(e);
					
					}
			}//--
		);
		return this
		}//---[*]
		
		
	}//----
	)
};//-----
