Allshows = {
    showsList: {},
    init: function(){
        $.ajax({
            url: "global/feeds/allShows.js",
            dataType: "json",
            async: false,
            success: function(A){
                $.extend(Allshows.showsList, A.allShows);
                Allshows.populateMenus(A.allShows);
                Allshows.initSlideshow(A.allShows)
            }
        });
        $(".showsList select").change(function(){
            window.location = $(this).val()
        });
        //Tracker.track("All Shows Page", "Shows")
    },
    populateMenus: function(B){
        var A = ["comedy", "action"];
        $.each(A, function(C){
            $.each(B[A[C]], function(D){
                $("<option />").attr("value", B[A[C]][D].directory).html(B[A[C]][D].showName).appendTo("#" + A[C] + " select")
            })
        })
    },
	randOrd: function (){
		// Get a random number between 0 and 10
		var temp = parseInt( Math.random() * 10 );
	    // Get 1 or 0, whether temp is odd or even
	    var isOddOrEven = temp%2;
	    // Get +1 or -1, whether temp greater or smaller than 5
	    var isPosOrNeg = temp > 5 ? 1 : -1;
	    // Return -1, 0, or +1
	    return( isOddOrEven*isPosOrNeg ); 
	},
    initSlideshow: function(C){
        var B = {
            jumbotron: []
        };
        var A = ["comedy", "action"];
        $.each(A, function(D){
            $.each(C[A[D]], function(E){
                var F = C[A[D]][E];
                B.jumbotron[B.jumbotron.length] = {
                    slideTitle: F.showName,
                    slideDate: "",
                    slideType: -1,
                    slideUrl: F.directory,
                    jumboNailUrl: F.directory + "/imgs/showJumboNail.jpg"
                }
            })
        });
		B.jumbotron.sort(Allshows.randOrd);
        Slideshow.init(B.jumbotron, Math.floor(Math.random()*41));
        Slideshow.start("next", true)
    }
};
$(document).ready(function(){
    Navs.init();
    Allshows.init()
});
