var load_tooltips = function(){
	$('#zune ul li img[alt]').qtip({
		content: {
        	text: false
      	},
	  	position: {
			corner: {
				tooltip: "bottomMiddle",
				target: "topMiddle"
			}
	  	},
    	style: {
			border: {
				width: 0
			},
			padding: 10, 
			textAlign: 'center',
			'background': '#000000',
			'color': '#FFFFFF',
			'font-size': '0.7em',
			'outline': '1px solid #669', 
			name: 'cream'
		}
	});
}

$(document).ready(function(){
	$.getJSON("http://cdn.luvofmine.com/scripts/zune_recent.php?jsoncallback=?", function(json){
		$.each(json.zCard.user.manifest.playlists.playlist[1].track,function(i,item) {
			var song = item.label;
			var artist = item.album.artist.label;
			var id = item.id;
			var url = item.album.url;
			var img = item.album.image[0].url;
			if(id != "00000000-0000-0000-0000-000000000000")
				$("#zune_recent").append("<li><a href='" + url + "'><img src='" + img + "' alt=\"" + song + " by " + artist + "\" height'75' width='75' /></a></li>"); 
			else 
				$("#zune_recent").append("<li><img src='" + img + "' alt=\"" + song + " by " + artist + "\" height'75' width='75' /></li>");
		});
		load_tooltips();
	});
	$("#ask").click(function(){
		$.facebox('<h1 style="color:#2F2F2F;">Ask me anything!</h1><p><iframe frameborder="0" border="0" scrolling="no" width="100%" height="149" allowtransparency="true" src="http://www.tumblr.com/ask_form/luvofmine.com" style="background-color:transparent; overflow:hidden;"></iframe></p>');
		return false;
	});
});

$(document).keypress( function(e) {
	if (e.keyCode === 37) {
		if ($('#prev-page').length > 0) location.href = $('#prev-page').attr("href");
	}
	else if (e.keyCode === 39) {
		if ($('#next-page').length > 0) location.href = $('#next-page').attr("href");
	}
});
