/**
 * Start all the scripts that require initializing when jQuery is ready
 * For exclusive use with the startEvo theme
 *
 * Author: Oscar Alcala
 * Website: http://www.themeforest.net?ref=BioXD
**/

jQuery(document).ready(function($) {
	//reweite jquery again just in case...
	var $ = jQuery;
	// Start the sliders
	var slides = $('.slider_thumbnail').size() - 1;
	var ts_slider_speed = $('#ts_slider_speed').attr('value') * 1000;
	
	$('.nivo-controlNav a:eq(0)').css({ opacity: 0.6});
	//$('.nivo-controlNav a:eq(0) .nivo-caption').fadeIn(1200);
	var bInited = false;
	//cycle
	$('#slider').cycle({
		fx: 'fade',
		timeout: ts_slider_speed,
		speed: 1200,
		pause: 1,
		skipInitializationCallbacks: true,
		before: function(curr, next, opts){
			$('.nivo-controlNav a:eq(' + opts.currSlide + ')').animate({ opacity: 1 }, 1000);
			$('.nivo-controlNav a:eq(' + opts.nextSlide + ')').animate({ opacity: 0.6 }, 1000);
		},
		after: function(curr, next, opts){			
		},
    	pagerAnchorBuilder: function(idx, slide) {
			return '.nivo-controlNav a:eq(' + idx + ')'; 
		} 
			
	});	
	/*
	$('#slider').nivoSlider({
		effect: 'fade',
		animSpeed: 1200,
		slices:2,
		pauseTime: ts_slider_speed,
		pauseOnHover: false, 
		controlNav: false, 
		directionNav: false, 
		beforeChange: function() {
			jQuery('.current_slide').animate({
				opacity: 1 
			}, 1000);
		}, 
		afterChange: function() {
			jQuery('.slider_thumbnail[rel=' + currentSlide + ']').animate({
				opacity: 0.8 
			}, 600);
			jQuery('.current_slide').removeClass('current_slide');
			jQuery('.slider_thumbnail[rel=' + currentSlide + ']').addClass('current_slide');
		}
	});
	*/
	// Start Cufon
	Cufon.now();
	Cufon.refresh();
	
	$("#categories_menu li").hover(function(event) {
		$('.sub-menu', this).slideToggle(300);
	});
	
	// Start the gallery 
	$(".gallery a").attr('rel', 'gallery');
	$("a[rel^='gallery']").prettyPhoto({
				animationSpeed: 'normal', 
				opacity: 0.75, 
				showTitle: false, 
				allowresize: true, 
				counter_separator_label: '/', 
				theme: 'dark_rounded', 
				hideflash: false, 
				modal: false, 
				changepicturecallback: function(){}, 
				callback: function(){} 
			});	

});
