// JavaScript Document
function pageselectCallback(page_index, jq){
	var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
	$('#Searchresult').empty().append(new_content);
	return false;
}
           
/** 
 * Callback function for the AJAX content loader.
 */
function initPagination() {
	var num_entries = $('#hiddenresult div.result').length;
	// Create pagination element
	$("#Pagination").pagination(num_entries, {
		num_edge_entries: 2,
		num_display_entries: 8,
		callback: pageselectCallback,
		items_per_page:1
	});
}
 
$(document).ready(function(){
	
	// face box	
	$('div.pannel a').click(function(){
			
			
		var id 	= $(this).parents().parents().parents().attr('id');
		
		//alert(id);
		var current_limit = $('#'+id+' li.show').length;
		
		//alert (current_limit);
		
		switch($(this).attr('class')){
		
			case 'add':
				$('#'+id+' li.hide:first').addClass('show');
				$('#'+id+' li.hide:first').removeClass('hide');
				//current_limit ++;				
				break;
			
			case 'remove':			
			
				if(current_limit < 5) {
					return false;
				}
				$('#'+id+' li.show:last').addClass('hide');
				$('#'+id+' li.show:last').removeClass('show');
				//current_limit --;				
				break;
				
		}
		
		return false;
		
	});	
	
	// section tools
	//$("#accordion").accordion({ header: "h3" });
	
	
	// schedule
	$('div.schedule_').hide();
		$('#schedule_1').show();
		
		$('#left div').filter(".link, .link_active").click(function() {
			
			$('div.schedule_').hide();
			
			
			$('#left div').filter(".link, .link_active").addClass('link');			
			$('#left div').filter(".link, .link_active").removeClass('link_active');
			
			$(this).addClass('link_active');
			
						
			$('#left .link .arr img').attr({ src: "../images/frontend/arr_whtbg.jpg"});
			$('#left .link_active .arr img').attr({ src: "../images/frontend/arr_graybg.jpg"});
			
			
			var id = $(this).attr('id');
			var d = 'schedule_'+id;
			
			  $('#'+d).show('slow');
				return false;
	});
	
	
	// content section images
	$(".read_image_box .picha").addClass('hide');		
	$('.read_image_box #0').removeClass('hide').addClass('show');
	$('#box_0 img').attr("src","../images/frontend/box_on.jpg");
	
	$('.more').click(function(){
	
		
		//number of images
		var n	= --$(".read_image_box .picha").length;
		
		var id	= $(".read_image_box .show").attr('id');
		if(id == n){
			return;
		}
		
		$('#box_'+id+' img').attr("src","../images/frontend/box_off.jpg");
		$('#'+id++).removeClass('show').addClass('hide');						
		$('#'+id).removeClass('hide').addClass('show');
		$('#box_'+id+' img').attr("src","../images/frontend/box_on.jpg");
	
	});
		
	$('.less').click(function(){
	
		//number of images
		var n	= --$(".read_image_box .picha").length;
			
		var id	= $(".read_image_box .show").attr('id');
		if(id == 0){
			return;
		}
		
		$('#box_'+id+' img').attr("src","../images/frontend/box_off.jpg");
		$('#'+id--).removeClass('show').addClass('hide');			
		$('#'+id).removeClass('hide').addClass('show');
		$('#box_'+id+' img').attr("src","../images/frontend/box_on.jpg");
		
		
	});
	
	
});


