var fadeTimer = null;

jQuery(function(){ 
    
    $('a[rel="external"]').click(function(e){
        
        window.open($(this).attr('href'));
        e.preventDefault();
        return false; 
    });
	
 	$('#p-content')
 	.cycle ({
        fx: 'fade',
        timeout: 7000,
        delay: 15000,
        pager: '#p-thumbs',
        next: '#forward',
        prev: '#back',
        pause: 1
    });
    
    $('#p-thumbs a').each(function() {

        var self = this;
        
        $('#p-thumbs li').each(function(){
            
            if(!$(this).find('a').length) {
            
                $(self).html($(this).html());
                $(this).html('');
                $(self).appendTo($(this));
                return false;                
            }           
        });
        
    	//$('#p-content').cycle('pause');
    });
    
    /*var split = new Array();
    var index = 0;
    var index2 = 0;
    
    $('#p-thumbs li').each(function(){
        
        if(index2 > 28) {
            
            index++;
            index2 = 0;
        }
        
        if(typeof(split[index])=='undefined') {
            
            split[index] = new Array();
        }
        
        split[index][index2++] = this;
        
    });
    
    for(var i=0;i<split.length;i++) {
        
        for(var j=0;j<split[i].length;j++) {
            
            
        }
    }*/
    
    $('#site-wrapper').height($(document).height());
    $('#p-content').cycle('resume');
    
    $('#p-thumbs').qvivoScroll();
    $('.scroll_track').attributes.add(this.style.cursor = 'hand');
});   
