$(document).ready(function() {
//Bouncing Thumbnails
	
	$(".socials a").hover(function() {
	    $(this).stop().animate({ marginTop: "-10px" }, 200);
	},function(){
	    $(this).stop().animate({ marginTop: "0" }, 300);
	});
	
	
	$(".releases a").hover(function() {
	    $(this).stop().animate({ marginTop: "-10px" }, 200);
	},function(){
	    $(this).stop().animate({ marginTop: "0" }, 300);
	});
	
//Footer Button - Developer
    $('.slidebttn').hover(
		function () {
			$(".footer .button_aLeft span").html("www.Netveano.com");
			$(".footer .button_aLeft").css("background","url(images/dleft.png) no-repeat 0");
			$(".footer .button_bLeft").css("background","url(images/dright.png) no-repeat 100%");
			var $this 		= $(this);
			var $slidelem 	= $this.prev();
			$slidelem.stop().animate({'width':'210px'},200);
			$slidelem.find('span').stop(true,true).fadeIn();
			$this.addClass('button_c');
		},
		function () {
			$(".footer .button_aLeft span").html("");
			$(".footer .button_aLeft").css("background","none");
			$(".footer .button_bLeft").css("background","none");
			var $this 		= $(this);
			var $slidelem 	= $this.prev();
			$slidelem.stop().animate({'width':'91px'},300);
			$slidelem.find('span').stop(true,true).fadeOut();
			$this.removeClass('button_c');
		}
	);
	
	
//Coda Slider
    var $panels = $('#slider .scrollcontainer > div');
    var $container = $('#slider .scrollcontainer');

    // if false, we'll float all the panels left and fix the width 
    // of the container
    var horizontal = true;

    // float the panels left if we're going horizontal
    if (horizontal) {
        $panels.css({
            'float' : 'left',
            'position' : 'relative' // IE fix to ensure overflow is hidden
        });

        // calculate a new width for the container (so it holds all panels)
        $container.css('width', $panels[0].offsetWidth * $panels.length);
    }

    // collect the scroll object, at the same time apply the hidden overflow
    // to remove the default scrollbars that will appear
    var $scroll = $('#slider .scroll').css('overflow', 'hidden');

    // apply our left + right buttons
    $scroll 
        .after('<img class="scrollButtons right" style="display:none;" src="" />')
		.before('<img class="scrollButtons left" style="position:relative; left:-9999em;" src="" />')

    // handle nav selection
    function selectNav() {
        $(this)
            .parents('ul:first')
                .find('a')
                    .removeClass('selected')
                .end()
            .end()
            .addClass('selected');
    }

    $('#slider .navigation').find('a').click(selectNav);

    // go find the navigation link that has this target and select the nav
    function trigger(data) {
        var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
        selectNav.call(el);
    }

    if (window.location.hash) {
        trigger({ id : window.location.hash.substr(1) });
    } else {
        $('ul.navigation a:first').click();
    }

    // offset is used to move to *exactly* the right place, since I'm using
    // padding on my example, I need to subtract the amount of padding to
    // the offset.  Try removing this to get a good idea of the effect
    var offset = parseInt((horizontal ? 
        $container.css('paddingTop') : 
        $container.css('paddingLeft')) 
        || 0) * -1;


    var scrollOptions = {
        target: $scroll, // the element that has the overflow

        // can be a selector which will be relative to the target
        items: $panels,

        navigation: '.navigation a',

        // selectors are NOT relative to document, i.e. make sure they're unique
        prev: 'img.left', 
        next: 'img.right',

        // allow the scroll effect to run both directions
        axis: 'xy',

        onAfter: trigger, // our final callback

        offset: offset,

        // duration of the sliding effect
        duration: 500,

        // easing - can be used with the easing plugin: 
        // http://gsgd.co.uk/sandbox/jquery/easing/
        easing: 'swing'
    };

    // apply serialScroll to the slider - we chose this plugin because it 
    // supports// the indexed next and previous scroll along with hooking 
    // in to our navigation.
    $('#slider').serialScroll(scrollOptions);

    // now apply localScroll to hook any other arbitrary links to trigger 
    // the effect
    $.localScroll(scrollOptions);

    // finally, if the URL has a hash, move the slider in to position, 
    // setting the duration to 1 because I don't want it to scroll in the
    // very first page load.  We don't always need this, but it ensures
    // the positioning is absolutely spot on when the pages loads.
    scrollOptions.duration = 1;
    $.localScroll.hash(scrollOptions);
	

	
//Jplayer Initialization
		var playItem = 0;

		var myPlayList = [
			{name:"Thrilla",mp3:"http://dl.dropbox.com/u/6451398/OGG/Thrilla.mp3",ogg:" http://www.iamkrazya.com/beats/Thrilla.ogg"},
			{name:"Deja vu",mp3:"http://www.iamkrazya.com/beats/Deja%20Vu.mp3",ogg:"http://www.iamkrazya.com/beats/Deja%20Vu.ogg"},
			{name:"Flames",mp3:"beats/Flames.mp3",ogg:"http://www.iamkrazya.com/beats/Flames.ogg"},
			{name:"Club Scratch",mp3:"http://dl.dropbox.com/u/6451398/OGG/Club%20Scratch.mp3",ogg:"http://www.iamkrazya.com/beats/Club%20Scratch.ogg"},
			{name:"Livin' it up",mp3:"http://dl.dropbox.com/u/6451398/OGG/Livin%20it%20up.mp3",ogg:"http://www.iamkrazya.com/beats/Livin%20it%20up.ogg"},
			{name:"Gettin' with it",mp3:"http://db.tt/lWVnuNw",ogg:"http://www.iamkrazya.com/beats/Gettin%20With%20It.ogg"},
			{name:"Priceless",mp3:"http://dl.dropbox.com/u/6451398/OGG/Priceless.mp3",ogg:"http://www.iamkrazya.com/beats/Priceless.ogg"},
			{name:"Mamba Millenium",mp3:"http://www.iamkrazya.com/beats/Mamba%20Millenium.mp3",ogg:"http://www.iamkrazya.com/beats/Mamba%20Millenium.ogg"},
			{name:"No Worries",mp3:"http://dl.dropbox.com/u/6451398/OGG/No%20Worries.mp3",ogg:"http://www.iamkrazya.com/beats/No%20Worries.ogg"},
			{name:"She's a rida",mp3:"http://dl.dropbox.com/u/6451398/OGG/Shes%20a%20Rida.mp3",ogg:"http://www.iamkrazya.com/beats/Shes%20a%20Rida.ogg"}
		];

		// Local copy of jQuery selectors, for performance.
		var jpPlayTime = $("#jplayer_play_time");
		var jpTotalTime = $("#jplayer_total_time");

		$("#jquery_jplayer").jPlayer({
			ready: function() {
				displayPlayList();
				playListInit(false); // Parameter is a boolean for autoplay.
			},
			oggSupport: true
		})
		.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
			jpPlayTime.text($.jPlayer.convertTime(playedTime));
			jpTotalTime.text($.jPlayer.convertTime(totalTime));
		})
		.jPlayer("onSoundComplete", function() {
			playListNext();
		});

		$("#jplayer_previous").click( function() {
			playListPrev();
			$(this).blur();
			return false;
		});

		$("#jplayer_next").click( function() {
			playListNext();
			$(this).blur();
			return false;
		});
		
		$("#jpId").jPlayer( {
		  swfPath: "script/"
		});

		function displayPlayList() {
			$("#jplayer_playlist ul").empty();
			for (i=0; i < myPlayList.length; i++) {
				var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>";
				listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>";
				$("#jplayer_playlist ul").append(listItem);
				$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
					var index = $(this).data("index");
					if (playItem != index) {
						playListChange( index );
					} else {
						$("#jquery_jplayer").jPlayer("play");
					}
					$(this).blur();
					return false;
				});
			}
		}

		function playListInit(autoplay) {
			if(autoplay) {
				playListChange( playItem );
			} else {
				playListConfig( playItem );
			}
		}

		function playListConfig( index ) {
			$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current");
			$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current");
			playItem = index;
			$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3, myPlayList[playItem].ogg);
		}

		function playListChange( index ) {
			playListConfig( index );
			$("#jquery_jplayer").jPlayer("play");
		}

		function playListNext() {
			var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
			playListChange( index );
		}

		function playListPrev() {
			var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
			playListChange( index );
		}
			
});
