// JavaScript Document
yd.Thumbnail = function( tagNameArray, parsedArray )
{
	this.tNameArray = tagNameArray ;
	this.parsedArray = parsedArray ;
	
	this.render() ;
};
	
yd.Thumbnail.prototype={
	
	render:function()
	{
		
		var self = this ;
		
		for( var i=0; i<this.parsedArray.length; i++ )
		{
			
			var workObj = this.parsedArray[i] ;
			
			
			
			
			$("<div class='link thumbUnit'></div>")
			
			//id, class
			.attr ("id", workObj.category + "_" + workObj.folder )
			.addClass( workObj.category )
			
			
			//add
			.append(
				   
				$("<div class='thumbImg' alt='image'></div>")
					
					.append( 
							
						$("<img />")
							.loadImg( "works/" + workObj.category + "/" + workObj.folder + "/thumbnail.jpg" )
							
					)
					
			)
			
			.append(			
				
				$("<div class='thumbInfo'></div>")
					//.addClass("thumbInfo")
					//.html( workObj.year + "<br />" + workObj.titleJ + "<br />" + workObj.titleE )
					.append( 
						$( "<p class='en'>" + workObj.titleE  + "</p>" )
					)
					.append( 
					
						$( "<p class='ja'>" + workObj.titleJ  + "</p>" )
					)
					.append( 
						$( "<p class='year'>" + workObj.year  + "</p>" )
					)
					
					
					
					
					
			)
			
			.appendTo( $("#thumbContainer") )
			
			
			//MouseEvent
			.hover(
				function(e){
				},
				function(e){
				}
			)
			
			.click( function(e)
			{
				self.onClickAction( e.currentTarget );
			}) ;
				
				
		
		};
		
		
		
		
		
		
		
	},
	
	
	onClickAction:function( elem )
	{
		var category = $(elem).attr("id").match( /[^_]+/ ) ;
 		var folder = $(elem).attr("id").match( /[^_]+$/ ) ;
		
		
		//.cookie( "crtPath", $(elem).attr("id") ) ;
		$.cookie( "crtPath", category + "/"+ folder ,{ path:"/" }) ;
		//alert( $.cookie( "crtPath" ))
		$.cookie( "pathArray", yd.index.parser.getPathArray( $.cookie( "tagName") ) ,{ path:"/" } ) ;
		
		location.href = "works/" + category + "/"+ folder + "/" + folder + ".html" ;
		//alert($.cookie( "crtPath" ))
		
		
		//[ho06is,ho06is,ho06is,ho06is,ho06is,ho06is]
		//クッキーの容量は4kb
		
		//workPageで
		//$.cookie( "crtFolder")
	}
	
};
