$(document).ready(function(){	

// Sidebar Naviation Animation
    $('ul li a').hover(function(){
		if (!$(this).hasClass('active')){
	        $(this).stop().animate({color:"white"});
		}
    }, function(){
		if (!$(this).hasClass('active')){
	        $(this).stop().animate({color:"#9c8f72"});
		}
    });
    $('.sub_nav li a').each(function(){
        $(this).append('<span>&nbsp;</span>')
    })
    .hover(function(){
		if (!$(this).hasClass('active')){
        	$(this).find('span').stop().animate({backgroundColor:"white"});
		}
    }, function(){
		if (!$(this).hasClass('active')){
        	$(this).find('span').stop().animate({backgroundColor:"#9c8f72"});
		}
    });

// Job Toggles
    $('#photos a').click(function(){
    	var currentjob = $(this).attr('class');
    	// What job is currently clicked on?
    	var str = $(this).attr('class');
    	var num = parseInt(str.charAt(3));
    	if(num > 0 && num <= $('#thumbs a').length - 1){
			job = num;  // otherwise it must be next button.    	
    	}
    	
    	nextjob = 0;
    	// If number is 5, set it back to 1, otherwise increment by 1.
		if(job == $('#thumbs a').length - 1){
			nextjob = 1;
		}else{
			nextjob = job + 1;
		}
	    // Special case for next button.
    	if(currentjob == "nextBtn"){	
	    	currentjob = "job" + nextjob;
	    	job = nextjob;
    	}
    	
    	
        $('#photos a').removeClass('active');
        $('#jobPhotos img').hide();
        $('.jobContent').hide();
        $('#' + currentjob).show();
        $('#jobPhotos img.' + currentjob).show();
        $('#thumbs a.' + currentjob).addClass('active');
        $('#photos a.' + currentjob).addClass('active');
        return false;
    });
});

// Preload rollover images for Photo Naviation
fulllist = new Image(); 
fulllist.src="/images/full_list_on.gif";

newbutton= new Image(); 
newbutton.src="/images/next_job_on.gif"; 

// Variable for holding currently viewing job
var job = 1;