
//var yd = new Object() ;

yd.Style = function()
{
	
	/*this.LOCAL_Y = 140;*/
	this.LOCAL_Y = $( "#localWrap" ).offset().top ;
	//alert(this.LOCAL_Y)
	//alert( $("#localWrap").offset().top );
	this.CONTENTS_Y = 40;
	this.FOOTER_H = 80;
	

	this.GLOBAL_MGN = 50 ;
	
	this.GLOBAL_MAX_W = 1400 ;
	this.GLOBAL_MIN_W = 800 ;
	
	
	
	this.THUMBUNIT_W = 300 ;
	/*this.THUMBUNIT_H = 70 ;*/
	this.THUMBUNIT_H = 70 ;
	
	this.THUMBIMG_H = 50 ;
	
	
	
	this.unitRow ;
	this.unitCol ;
	this.unitColTaller = 0 ;
	
	this.thumbCnt_W_array = [] ;
	for(var i=0; i<10; i++)
	{
		this.thumbCnt_W_array.push( this.THUMBUNIT_W*i ) ;
	} ;
	
	
	$("body").css({
		"visibility":"hidden"
	}) ;
	
};


yd.Style.prototype={

	get:function(){
		
		var o = { } ;
		
		o.w = $( window ).width() ;
		o.h = $( window ).height() ;
		
		o.global_Mgn = this.GLOBAL_MGN ;
		o.global_W = o.w-( this.GLOBAL_MGN*2 ) ;
		
		
		if( o.global_W <= this.GLOBAL_MIN_W)
		{
			o.global_Mgn = this.GLOBAL_MGN ;
			o.global_W = this.GLOBAL_MIN_W ;
			
		
		}else if( o.global_W >= this.GLOBAL_MAX_W )
		{
			o.global_Mgn = ( o.w  - this.GLOBAL_MAX_W ) /2;
			o.global_W = this.GLOBAL_MAX_W ;
		}
		
		
		return o ; 
	},
	
	showBody:function()
	{
		$("body").css({
			"visibility":"visible"
		}) ;
		//$("body").show("normal");
	},
	
	
	setBase:function( o )
	{
		
		
		
		$("#header").css({
			"width":o.global_W+"px"
			
		});
		
		
		
		$("#localWrap").css({
			/*"top":this.LOCAL_Y + "px",*/
			
			"width":o.global_W + "px"
		});
		
		$("#contents").css({
						   
			"top":this.CONTENTS_Y + "px"
		});
		
		
		var contents_H  = this.setContents( o ) ;
		
		/*global_H = this.LOCAL_Y +  this.CONTENTS_Y + contents_H + this.FOOTER_H ;
		global_H = Math.max( global_H , o.h) ;*/
		
		/*$("#footer").css({
			"top": global_H - this.FOOTER_H/2 + "px"
		});*/
		
		$("#globalWrap").css({
			"width":o.global_W +"px",
			"left":o.global_Mgn + "px"/*,
			"height":global_H + "px"*/
		});
		
	
	},
	
	
	
	
	setContents:function( o ){
		
	
		
		if($("#thumbContainer").length){
			
			var thumbCnt_W = o.global_W ;
			
			for(var i=0; i<10; i++ ){
			
				if( thumbCnt_W <= this.thumbCnt_W_array[2]){
					this.unitRow = 2 ;
				
				}else if( thumbCnt_W > this.thumbCnt_W_array[i] ){
					this.unitRow = i ;
				};
			}
			
			this.unitCol = Math.floor( $( "#thumbContainer .thumbUnit:visible" ).length / this.unitRow ) ;
			
			var lastRowLength = $( "#thumbContainer .thumbUnit:visible" ).length % this.unitRow ;
			if( lastRowLength != 0 )
			{
				this.unitCol++ ;
			};
			
			
			
			for(var i=0; i<$( "#thumbContainer .thumbUnit:visible" ).length; i++)
			{	
				$("#thumbContainer .thumbUnit:visible:eq("+ i+ ")").css({
					"left": thumbCnt_W/this.unitRow * (i % this.unitRow) +"px",
					"top" : ( this.THUMBUNIT_H )*( Math.floor(i/this.unitRow) ) +"px"
				});
			};
			
			
			
			$("#thumbContainer").css({
				"width":thumbCnt_W + "px",
				"height":this.THUMBUNIT_H*this.unitCol + 50 + "px"
			});
			
			
			
			
			
			if( this.unitCol > this.unitColTaller )
			{
				this.unitColTaller = this.unitCol ;
			};
			
			
			return this.THUMBUNIT_H*this.unitColTaller ;
		
		
			
		}
		else if( $( "#imgContainer" ).length ){
			
			return Math.max( $( "#textContainer" ).height(), $( "#imgContainer" ).height() ) ;
		}
		
		
		
	}
	
}
	
	
