/**
 * function js
 */

/**
 * cufon font replace
 */
Cufon.set('fontFamily', 'timess').replace('h1, h2, h3, #tabs ul li a, #nav ul li a');

/*
 * navi items
 */
$(document).ready(function () {
	//transitions
	//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
	var style = 'easeOutExpo';

	//Retrieve the selected item position and width
	var default_left = Math.round($('#nav li.current_page_item, #nav li.current_page_parent').offset().left - $('#nav').offset().left - 2);
	var default_width = $('#nav li.current_page_item, #nav li.current_page_parent').width();

	//Set the floating bar position and width
	$('#nav-box').css({left: default_left});
	$('#nav-box .nav-head').css({width: default_width});

	//if mouseover the menu item
	$('#nav li').hover(function () {
		
		//Get the position and width of the menu item
		left = Math.round($(this).offset().left - $('#nav').offset().left - 2);
		width = $(this).width(); 
	$('#debug').html(left);
		//Set the floating bar position, width and transition
		$('#nav-box').stop(false, true).animate({left: left},{duration:1000, easing: style});	
		$('#nav-box .nav-head').stop(false, true).animate({width:width},{duration:1000, easing: style});	
	
	//if user click on the menu
	}).click(function () {
		
		//reset the selected item
		$('#nav li').removeClass('current_page_item');	
		$('#nav li').removeClass('current_page_parent');
		
		//select the current item
		$(this).addClass('current_page_item');
		$(this).addClass('current_page_parent');

	});
	
	//If the mouse leave the menu, reset the floating bar to the selected item
	$('#nav').mouseleave(function () {

		//Retrieve the selected item position and width
		default_left = Math.round($('#nav li.current_page_item, #nav li.current_page_parent').offset().left - $('#nav').offset().left - 2);
		default_width = $('#nav li.current_page_item, #nav li.current_page_parent').width();
		
		//Set the floating bar position, width and transition
		$('#nav-box').stop(false, true).animate({left: default_left},{duration:1500, easing: style});	
		$('#nav-box .nav-head').stop(false, true).animate({width:default_width},{duration:1500, easing: style});		
		
	});
	
});

/*
 * gallery slider
 */
jQuery(function() {       
    jQuery('#slider-gallery').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 5000,
		prev:   '#slider-prev',
		next:   '#slider-next'
    });
});

