(function($){

	$(window).load(function(){

		// rollover.
		/*$('img.over, input.over').each(function(){
			// preload image.
			var img = new Image();
			img.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1_over$2');
			$(this)
				// store the image sources.
				.data('image', {
					defaultSrc: this.src,
					hoverSrc: img.src
				})
				.hover(
					function(){
						this.src = $(this).data('image').hoverSrc;
					},
					function(){
						this.src = $(this).data('image').defaultSrc;
					}
				);
		});*/

		// status current.
		$('img.now').each(function(){
			this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1_on$2');
		});

		// open link as '_blank'.
		$('a[rel=external]').click(function(){					
			window.open(this.href, '_blank');
			return false;
		});

		
		
		// remove gt 6 items.
		$('#gnav-lists li:gt(5)').remove();
		$('#sitemap .sm-li1:gt(5)').remove()
		
		
		// setup child nav.
		$('#gnav-lists li')
			.each(function(i){
			
				//delete first item
				$('#sitemap .sm-ul2 li:first').remove();
				
				$(this)
					// copy nav.
					
					.append($('#sitemap .sm-ul2:first').clone())
					.find('ul')
						.hide()
					.end()
					// hover handler.
					.hover(
						function(){
						
							$(this).find('ul').stop(true, true).fadeIn();
						},
						function(){
							$(this).find('ul').stop(true, true).fadeOut();
						}
					)
				;
				// delete original.
				$('#sitemap .sm-ul2:first').remove();
				
			})
		;
		
		$('#gnav .sm-ul1').remove();
		
		

		// current status in aside nav.
		/*$('#aside div.nav li.now').each(function(){
			var level = $(this).attr('class').split(' ')[0];
			$(this).addClass(level.replace(/level/i, 'now'));
		});*/
		
		// 
		$('#foot_nav .nav ul').each(function(){
			$(this).children('li:last').addClass('last');
		});
		
		//
		$('.block_input').each(function(){
			var width_percent=$(this).children('.width_input').children('.width_percent').text();
			
			$(this).attr('style','width:'+width_percent+'%;');
			$(this).children('.width_input').remove();
		});
		
		//
		$('.pdf_select').each(function(){
		
			
			$(this).append('<img src="/chuko/library/8.gif" alt="PDFアイコン" width="16" height="16" />')
			
		});
		
		//
		$('.null_file_link').each(function(){
		
			
			$(this).remove();
			
		});
		
	});
	
	

})(jQuery);

