    // we will add our javascript code here             
$(document).ready(function() {
    $("#twitter").getTwitter({
        userName: "ScottSongwriter",
        numTweets: 4,
        loaderText: "Loading tweets...",
        slideIn: false,
        showHeading: true,
        headingText: "Latest tweets",
        showProfileLink: false
    });
});


$(document).ready(function() {
    $("#home").fadeIn("slow");

    $('#homelink').click(function() {
        togglefade("home");
    });

    $('#songslink').click(function() {
        togglefade("songs");
    });

    $('#awardslink').click(function() {
        togglefade("awards");
    });

    $('#contactlink').click(function() {
        togglefade("contact");
    });
});

function togglefade(divtofadeIn) {
    $("#home").hide();
    $("#songs").hide();
    $("#awards").hide();
    $("#contact").hide();
    $("#contact").hide(function() {
        $("#" + divtofadeIn).fadeIn("slow");
        //$("#"+divtofadeIn+"link").attr({ class: divtofadeIn+"current"});
    });
}
   




$(document).ready(function(){

	var playItem = 0;

	var myPlayList = [
		{name:"Holding Out",filename:"tracks/Holding Out.mp3"},
		{name:"Sex Drug",filename:"tracks/Sex_Drug.mp3"},
		{name:"One Colour",filename:"tracks/One_Colour.mp3"},
		{name:"I'll Always Be There For You",filename:"tracks/Ill Always Be There For You_(Country).mp3"}
	];
    	$("#holdingOut").click(function() {
		$("#trackname").text("Holding Out");
        $("#jquery_jplayer").setFile('tracks/Holding Out.mp3').play();
        return false;
    });

		$("#sexdrug").click(function() {
		$("#trackname").text("Sex Drug");
        $("#jquery_jplayer").setFile('tracks/Sex_Drug.mp3').play();
        return false;
    });
    $("#onecolour").click(function() {
		$("#trackname").text("One Colour");
        $("#jquery_jplayer").setFile('tracks/One_Colour.mp3').play();
        return false;
    });
    $("#bethere").click(function() {
		$("#trackname").text("I'll Always Be There For You");
        $("#jquery_jplayer").setFile('tracks/Ill Always Be There For You_(Country).mp3').play();
        return false;
    });
    $("#sexdrug1").click(function() {
		$("#trackname").text("Sex Drug");
        $("#jquery_jplayer").setFile('tracks/Sex_Drug.mp3').play();
        return false;
    });
    $("#onecolour1").click(function() {
		$("#trackname").text("One Colour");
        $("#jquery_jplayer").setFile('tracks/One_Colour.mp3').play();
        return false;
    });
    $("#bethere1").click(function() {
		$("#trackname").text("I'll Always Be There For You");
        $("#jquery_jplayer").setFile('tracks/Ill Always Be There For You_(Country).mp3').play();
        return false;
    });

	$("#jquery_jplayer").jPlayer({
		ready: function() {
			playListEnable(true);
		}
	});

	$("#jquery_jplayer").jPlayerId("play", "player_play");
	$("#jquery_jplayer").jPlayerId("pause", "player_pause");
	$("#jquery_jplayer").jPlayerId("stop", "player_stop");
	$("#jquery_jplayer").jPlayerId("loadBar", "player_progress_load_bar");
	$("#jquery_jplayer").jPlayerId("playBar", "player_progress_play_bar");
	$("#jquery_jplayer").jPlayerId("volumeMin", "player_volume_min");
	$("#jquery_jplayer").jPlayerId("volumeMax", "player_volume_max");
	$("#jquery_jplayer").jPlayerId("volumeBar", "player_volume_bar");
	$("#jquery_jplayer").jPlayerId("volumeBarValue", "player_volume_bar_value");

	$("#jquery_jplayer").onProgressChange( function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		var myPlayedTime = new Date(playedTime);
		var ptMin = (myPlayedTime.getMinutes() < 10) ? "0" + myPlayedTime.getMinutes() : myPlayedTime.getMinutes();
		var ptSec = (myPlayedTime.getSeconds() < 10) ? "0" + myPlayedTime.getSeconds() : myPlayedTime.getSeconds();
		$("#play_time").text(ptMin+":"+ptSec);

		var myTotalTime = new Date(totalTime);
		var ttMin = (myTotalTime.getMinutes() < 10) ? "0" + myTotalTime.getMinutes() : myTotalTime.getMinutes();
		var ttSec = (myTotalTime.getSeconds() < 10) ? "0" + myTotalTime.getSeconds() : myTotalTime.getSeconds();
		$("#total_time").text(ttMin+":"+ttSec);
	});

	$("#jquery_jplayer").onSoundComplete(endOfSong);

	$("#ctrl_prev").click( function() {
		playListPrev();
		return false;
	});

	$("#ctrl_next").click( function() {
		playListNext();
		return false;
	});

	function endOfSong() {
		if(usePlayList) {
			playListNext();
		}
	}

	function playListEnable(e) {
		usePlayList = e;
		if(usePlayList) {
			playListChange( playItem );
		} else {
			$("#jquery_jplayer").stop();
		}
	}

	function playListChange( index ) {
		playItem = index;
		$("#jquery_jplayer").setFile(myPlayList[playItem].filename).play();
	    $("#trackname").text(myPlayList[playItem].name);
}

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

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

