/*
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/

$(document).ready(function() {
	var location;// = $(".menu_list li a").attr("href");
	var currentClass;
	var item;
	var derp = "derp";

	$("#slideshow img").attr('width', '492px');
	
	/*$(".portfolio_link a").click(function() {
		location = $(this).attr("href");
		$("#content").load(location + " #content");
		return false;
	});
	
	$(".menu_list li a").click(function() {
		location = $(this).attr("href");
		$("#content").load(location + " #content");
		return false;
	});*/
	
	
	$(".portfolio_link") 
    .livequery('click', function(event) { 
    	location = $(this).attr("href");
		$("#content").load(location + " #content", function(){
			$("#content #slideshow img").attr('width', '492px');
		}); 
        return false; 
    }); 
	
	$("#back a")
	.livequery('click', function(event) { 
    	location = $(this).attr("href");
		$("#content").load(location + " #content", function(){
			//$("#content #slideshow img").attr('width', '492px');
		}); 
        return false; 
    }); 
	//$(".portfolio_link").click(function() {
		/*location = $(this).attr("href");
		$("#content").load(location + " #content", function(){
			$("#content #slideshow img").attr('width', '492px');
		});*/
//		return false;
//	});
	
	
	$(".menu_list li a").click(function() {
		location = $(this).attr("href");
		$("#content").load(location + " #content", function(){
			$("#content #slideshow img").attr('width', '492px');
		});
		return false;
	});
	
});

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
     var $sibs  = $active.siblings();
     var rndNum = Math.floor(Math.random() * $sibs.length );
     var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 300, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 2000 );
});

