jQuery(document).ready(function($){

    // slider on main page
    if (jQuery('#characters-list').length) {
        jQuery('.navigation').css('z-index', 100);

        jQuery('#characters-list').cycle({
            timeout: 0,
            next: '#next',
            prev: '#prev',
            fx: 'fade'
        });
    }

    // characters page
    if ( jQuery('#characters-nav').length ) {
        
        var current = jQuery('#character-1');

        var effects_arr = new Array(5);
        effects_arr[0] = 'blind';
        effects_arr[1] = 'blind';
        effects_arr[2] = 'blind';
        effects_arr[3] = 'blind';
        effects_arr[4] = 'blind';

        jQuery('#character-main').css({
            position: 'relative',
            height: current.height()
        });
        jQuery('#character-main .character-details').css({
            position: 'absolute',
            top: '0', left: '0', width: '100%'
        });
        jQuery('#characters-nav li a').click(function() {
            if ( !jQuery(this).hasClass('current') ) {
                jQuery('#characters-nav .current').removeClass('current');
                jQuery(this).addClass('current');
                var id = jQuery(this).attr('href');

                var options = {};

                var rand_eff = effects_arr[Math.floor(Math.random()*5)];

                function callback(){
                    jQuery(id).slideDown(500);
                }
                
                jQuery('#character-main .character-details:visible').effect(rand_eff, options, 500, callback);
                window.location.hash=jQuery(this).attr('href').slice(1);
            }
            return false;
        });
        
        if (window.location.hash != '') {
            var whash = window.location.hash;
            whash=whash.slice(1);
            
            jQuery('#characters-nav .current').removeClass('current');
            jQuery('#characters-nav .nav-'+whash.slice(-1)).addClass('current');
            jQuery('#character-main .character-details:visible').css('display', 'none');
            jQuery('#'+whash).css('display', 'block');
            
        }
    } // characters page scripts end

    

});

