$(document).ready(function() {
    


/*  Home page - 
s, photos, news
------------------------------------------------------------------------ */

    $("#homePage .item a").click(function(){
        swfobject.embedSWF( $(this).attr("href"), "sectionScreenObj" , "320", "265", "9.0.0");
        return false;
    });

    $("#vidPage .item a").click(function(){
        var t = $(this).children("img").attr("alt");
        swfobject.embedSWF( $(this).attr("href"), "sectionScreenObj" , "380", "289", "9.0.0");
        $("#nowPlaying h3").after('<h3>' + t + '</h3>').remove();
        return false;
    });
/*  OLD CODE - DOESN'T WORK IN IE8
    $(".item a").click(function(){
        var ytHTML = $("#sectionScreen").html();
        $("#sectionScreen").html(ytHTML);
        var tubeURL = $(this).attr("href");
        $("#sectionScreen param:first").attr("movie", tubeURL);
        $("#sectionScreen embed").attr("src", tubeURL);
        return false;
    })
*/

/*  Photo Gallery
------------------------------------------------------------------------ */
    
    // Preload images
    $("#photoCarousel ul li a").each(function(){
        var preload = new Image();
        preload.src = this;
    });
    
    // Set main image when you click a thumbnail
    $("#photoCarousel ul li a").click(function(){
        var i = $(this).attr("title");
        $("#photoGallery img").attr("src", this);
         $("#photoCaption").html(i);
        return false;
    });
    
    // Scroll the thumbnails
    $("#photoCarousel").jCarouselLite({
        btnNext: "#nextPhoto",
        btnPrev: "#prevPhoto",
        scroll: 1,
        visible: 7,
        circular: false
    });
    
/*  Sittin' Artists videos
------------------------------------------------------------------------ */

    $(".sittin-vid").click(function(){
            swfobject.embedSWF( $(this).attr("href"), "sectionVid" , "676", "407", "9.0.0");
            $("#sittin-popup").fadeIn("fast");
            return false;
        });

    $(".sittinclose").click(function(){
        $("#sittin-popup").hide();
        $("#sectionVid").after('<div id="sectionVid"></div>').remove();
        return false;
    });


/*  Snazzify nav
------------------------------------------------------------------------ */

    $("#nav li").hover(
        function(){
            $("a",this).addClass("navSelected");
            $("ul", this).fadeIn("fast");
        },
        function(){
            $(this).removeClass("navSelected");
            $("ul", this).hide();
        }
    );

/*  Elist
------------------------------------------------------------------------ */

    $("#showElist").click(function(){
        $("#elist").fadeIn();
    });

    $("#showElistclose").click(function(){
        $("#elist").fadeOut();
    });
    
    $("#elist").submit(function(){
        var name = $("input#cm-name").val();
          var email = $("input#cm-iduiit-iduiit").val();
          var checkboxes = $("input:checked").length;

          if ((name == "") || (email == "")) {
      		$("p#errorMsg").html("Please fill out all fields.");
      		return false;
      	}

          if (checkboxes == "0") {
      		$("p#errorMsg").html("Please select a city.");
      		return false;
      	}
    });
	
    
/*  About cycle
------------------------------------------------------------------------ */

    $("#cycleAbout div").cycle();

/*  Songlist
------------------------------------------------------------------------ */

    $("#songList").click(function(){
        $("#songlist").fadeIn();
    });

    $("#songListclose").click(function(){
        $("#songlist").fadeOut();
    });


});// end ready function






/*  Window onload function - things you want to load after everything else
------------------------------------------------------------------------ */

$(window).load(function(){
    
/*  Twitter Feed
------------------------------------------------------------------------ */

    $("#twitterFeed div").getTwitter({
		userName: "milliondquartet",
		numTweets: 4,
		loaderText: "Loading tweets...",
		slideIn: false,
		//slideDuration: 750,
		showHeading: false,
		//headingText: "Latest Tweets",
		showProfileLink: false,
		showTimestamp: false
	});
	
	$("#twitterFeedVid div").getTwitter({
		userName: "milliondquartet",
		numTweets: 3,
		loaderText: "Loading tweets...",
		slideIn: false,
		//slideDuration: 750,
		showHeading: false,
		//headingText: "Latest Tweets",
		showProfileLink: false,
		showTimestamp: false
	});
	
	$("#twitterFeed2 div").getTwitter({
		userName: "milliondquartet",
		numTweets: 7,
		loaderText: "Loading tweets...",
		slideIn: false,
		//slideDuration: 750,
		showHeading: false,
		//headingText: "Latest Tweets",
		showProfileLink: false,
		showTimestamp: false
	});
	
/*  Open external links in a new window
------------------------------------------------------------------------ */

    $("a[href^='http:']").not("[href*=window.location.host]").attr('target','_blank');
    
/*  JScrollPane
------------------------------------------------------------------------ */

    $(".scrollPane").jScrollPane({
        scrollbarWidth: 13,
        showArrows: false,
        dragMinHeight:63,
        dragMaxHeight:63
    });

/*  Hall of Fame
------------------------------------------------------------------------ */

$('#slideshow').nivoSlider({
	effect:'fold',
	slices:8,
	animSpeed:500,
	pauseTime:5000,
	startSlide:0, //Set starting Slide (0 index)
	directionNav:true, //Next & Prev
	directionNavHide: false, //Only show on hover
	controlNav:true, //1,2,3...
	controlNavThumbs:true, //Use thumbnails for Control Nav
	controlNavThumbsSearch: '.jpg', //Replace this with...
	controlNavThumbsReplace: '-thumb.jpg', //...this in thumb Image src
	keyboardNav:false, //Use left & right arrows
	pauseOnHover:true, //Stop animation while hovering
	manualAdvance:false, //Force manual transitions
	captionOpacity:0.8, //Universal caption opacity
	beforeChange: function(){},
	afterChange: function(){},
	slideshowEnd: function(){} //Triggers after all slides have been shown
});
	
}); // end window load
