// JavaScript Document
yd.Tag = function( tagNameArray , worklist )
{
	this.tNameArray = tagNameArray ;
	this.worklist = worklist ;
	this.allLength = 0 ;
	this.ALL_STR = "all" ;
	this.parentRef = parent ;
	
	this.render() ;
} ;
	
yd.Tag.prototype={
	
	render:function()
	{
		/*$("<ul></ul>")
			.attr("id","tagList")
			.appendTo( $("#tagContainer") ) ;

		var self = this ;
		//カテゴリタグ
		for( var i=0; i< this.tNameArray.length; i++ )
		{
			var length = this.worklist.category[ this.tNameArray[i] ].length ;
			this.allLength += length ;
			
		
			$("<li></li>")
				
				//id,class
				.attr( "id", this.tNameArray[i] )
				.addClass("link tag")
				
				//Add
				
				.text( this.tNameArray[i] )
				.appendTo( $("#tagList") )
				
				//MouseEvent
				.hover(
					function(e){
					},
					function(e){
					}
				)
				.click( function( e )
				{
					self.onClickAction( $(e.target).attr( "id" ) ) ;
				}) ;*/
		
		var totalWidth = 0 ;
		var tagMgn = 20 ;

		var self = this ;
		//カテゴリタグ
		this.tNameArray.unshift( this.ALL_STR ) ;
		
		for( var i=0; i< this.tNameArray.length; i++ )
		{
			/*$("<a></a>")
				
				//id,class
				.attr( "id", this.tNameArray[i]  )
				.addClass("link tag")
				
				
				//Add
				.text( String( i==0 ? "ALL" : this.tNameArray[i] ) )
				.prepend(
					$("<img src='images/triangleMini.jpg'/ >")
				)
				
				.appendTo( $("#tagContainer") )
				
				//MouseEvent
				.hover(
					function(e){
					},
					function(e){
					}
				)
				.click( function( e )
				{
					self.onClickAction( $(e.target).attr( "id" ) ) ;
				}) 
				
			
			
				totalWidth += $( ".tag:eq(" + i + ")" ).width() +10 ;*/
			
			$("<a class='tag'></a>")
				
				//id,class
				
				.append(
					$("<img src='images/triangleMini.jpg'/ >")
				)
				.append(
					$("<span class='link'></span>")
						.attr( "id", this.tNameArray[i]  )
						.text( String( i==0 ? "ALL" : this.tNameArray[i] ) )
					
				)
				
				
				
				
				//Add
				.appendTo( $("#tagContainer") )
				
				//MouseEvent
				.hover(
					function(e){
					},
					function(e){
					}
				)
				.click( function( e )
				{
					if( $(e.target).attr( "id" ) )
					{
						self.onClickAction( $(e.target).attr( "id" ) ) ;
					}
				}) 
				
			
			
				totalWidth += $( ".tag:eq(" + i + ")" ).width() +10 ;
			
			
			
				
		} ;
		
		
		/*$(".tag").corner({
			tl: { radius: 4 },
			tr: false,
			bl: false,
			br: { radius: 4 },
			antiAlias: true,
			autoPad: true
		})
*/		
		
		
		
	},
	
	
	onClickAction:function( id )
	{
		$.cookie( "tagName", id ,{ path:"/" } ) ;
		
		yd.index.crtTagName = id ;
		
		this.setTag( id )  ;
		this.setThumbnail( id ) ;
	},
	
	setTag:function( id )
	{
		$( "#tagContainer #" + id ).addClass("selected") ;
		
		
		$( "#tagContainer :not( #" + id + ")"  ).removeClass("selected") ;
	},
	
	setThumbnail:function( theCategory )
	{
		if( theCategory == this.ALL_STR ){
			
			$( "#thumbContainer > div" ).show() ;
			
		}else{
			
			$( "#thumbContainer > div." + theCategory ).show();
			$( "#thumbContainer > div:not(." + theCategory + ")"  ).hide();
		};
		
		//yd.index.style.setIndex(yd.index.style.get()) ;
		yd.index.style.setBase(yd.index.style.get()) ;
	}
};

