


	init_height = 0;
	init_width  = 0;
	function window_resize_f(){
		
		new_width = $(window).width() - 40 ;
		if( !init_width ){ init_width = $("#bg").width(); }  
		if( new_width > init_width ) $("#bg").width( $(window).width() - 40 );
		
		new_height = $(window).height() - 40 ;
		if( !init_height ){ init_height = $("#site").height(); }
		if( new_height > init_height ) $("#bg").height( $(window).height() - 40 );
		
	}
	
	
	km_slider_li_width 	= 0;
	km_current_page		= 1;
	km_num_pages		= 0;
	km_can_animate		= 1;
	function km_slider_init(){
		
		// init
		km_slider_li_width 	= $("#work_panel UL LI").width();
		km_num_pages 		= $("#work_panel UL LI").size();
		
		// generate nav
		$("#detail_nav").append('<ul></ul>');
		for(i = 1; i <= km_num_pages; i++){ $("#detail_nav UL").append('<li><a href="#"></a></li>'); }
		$("#detail_nav UL LI A").bind('click', km_goto_page );
		
		// nav
		$("#detail_nav UL LI A:first").addClass('active');
		
	}
	
	
	function km_goto_page(){
		
		if( km_can_animate ){
			this_index = $( $("#detail_nav UL LI A") ).index( $(this) );
			goto_page  = this_index + 1;
			km_can_animate 	= 0;
			new_left 		= ((goto_page-1)*km_slider_li_width);
			km_current_page = goto_page - 1;
			km_animate_panel(new_left, "this");		
			
					
		}

		
		return false;
		
	}
	
	
	
	function update_img_desc_text( num ){

		text = $("#nav_desc UL LI").eq(num).html();
		
		$("#img_desc span").html(text);
		
	}
	
	
	function km_update_page_text(km_current_page){
		
		// span text
		$("#page_num").html(km_current_page + '/' + km_num_pages);
		
		// nav		
		$("#detail_nav UL LI A").removeClass('active');
		$("#detail_nav UL LI A").eq(km_current_page-1).addClass('active');
		
	}
	
	
	function km_animate_panel(new_left, type_plus_minus){
		
		$("#work_panel").animate({
			left: "-" + new_left + "px"
		}, 1000, 'easeInOutExpo', function(){
			
			if( type_plus_minus == "minus" ) km_current_page--;
			else km_current_page++;
			
			km_can_animate = 1;
			km_update_page_text(km_current_page);
			
			//update_img_desc_text( $("#work_panel img").eq(km_current_page-1).attr('title') );
			update_img_desc_text( km_current_page-1 );

				
		});	
		
	}
	
	function km_slider_goto_prev(){
		
		/*if( km_can_animate ){
			km_can_animate = 0;*/
			goto_page = 0;
			// $("#work_panel img:first").attr('title')
			
			if( (km_current_page > 1) && km_can_animate ){
				km_can_animate = 0;
				goto_page = km_current_page - 2;
				new_left = (goto_page*km_slider_li_width);
				km_animate_panel(new_left, "minus");
				/*$("#work_panel").animate({
					left: "-" + new_left + "px"
				}, 1000, 'easeInOutExpo', function(){
					km_current_page--;
					km_can_animate = 1;
					km_update_page_text(km_current_page);
				});	*/		
			}	
			else if( km_can_animate ) {
				
				/* goto last */
				km_current_page = km_num_pages - 1;
				km_can_animate = 0;
				goto_page = km_current_page;
				new_left  = (km_current_page*km_slider_li_width);
				km_animate_panel(new_left, "plus");
				
			}	

			
			//update_img_desc_text( $("#work_panel img").eq(goto_page).attr('title') );
			
		//}

		return false;
		
	}
	
	function km_slider_goto_next(){
		
		/*if( km_can_animate ){
			km_can_animate = 0;*/
			
			goto_page = 0;
			
			if( (km_current_page < km_num_pages) && km_can_animate  ){
				km_can_animate = 0;
				goto_page = km_current_page;
				new_left  = (km_current_page*km_slider_li_width);
				km_animate_panel(new_left, "plus");
				/*$("#work_panel").animate({
					left: "-" + new_left + "px"
				}, 1000, 'easeInOutExpo', function(){
					km_current_page++;
					km_can_animate = 1;
					km_update_page_text(km_current_page);
				});	*/		
			}
			else if( km_can_animate ) {
				
				/* goto first */
				km_current_page = 0;
				km_can_animate = 0;
				goto_page = km_current_page;
				new_left  = (km_current_page*km_slider_li_width);
				km_animate_panel(new_left, "plus");
				
			}
			
			//update_img_desc_text( $("#work_panel img").eq(goto_page).attr('title') );
			
		//}


		return false;
		
		
	}
