/*	JS Document 
 *	Author: Tashreek Jackson
 *	Overview: jQuery Functions.	
*/

$(document).ready(function() {
    $.ajax({
        type: 'GET',
        url: 'http://gdata.youtube.com/feeds/api/videos?max-results=6&orderby=published&author=JackParow&alt=json',
        dataType: 'jsonp',
        success: function(data){
            $('#youtube-vids').html('');
            $.each(data.feed.entry, function(i, val) {
                    $('#youtube-vids').append('<li><a href="' + val.link[0].href + '" rel="prettyPhoto"><img src="' + val.media$group.media$thumbnail[0].url + '" width="98" height="55" alt="' + val.title.$t + '" /></a></li>');
            });
            $("a[rel^='prettyPhoto']").prettyPhoto({
                theme: 'dark_rounded',
                show_title: false,
                opacity: 0.70,
                default_width: 700,
                allow_resize: false,
                changepicturecallback: function(){Cufon.refresh();}
            });
        },
        beforeSend: function(data){
            $('#youtube-vids').html('<li>loading...</li>');
        }
    });
    
    $("ul#nav a").hover(
        function () {
            $(this).css("opacity","0.5");
            $(this).stop().animate({
                opacity: 1
            }, "slow");
        },
        function () {
            $(this).css("opacity","1");
        });
	
    $(".block-left ul li a").live('mouseover', function () {
        $(this).css("opacity","0.5");
    });

    $(".block-left ul li a").live('mouseout', function () {
        $(this).css("opacity","1");
    });


    $('ul#nav a').click(function(){
        $("ul#nav li").removeClass("active");
        $(this).parent().addClass("active");
        $('#viewport').scrollTo( $($(this).attr('href')), 800 );
        return false;
    });

    
    $("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'dark_rounded',
        show_title: false,
        opacity: 0.70,
        default_width: 700,
        allow_resize: false,
        callback: function(){Cufon.refresh();}
    });

    $(".tweet, .tweet_box").tweet({
        username: "JackParow",
        join_text: "auto",
        count: 1,
        auto_join_text_default: "I said,",
        auto_join_text_ed: "I",
        auto_join_text_ing: "I was",
        auto_join_text_reply: "I replied to",
        auto_join_text_url: "I was checking out",
        loading_text: "loading tweets..."
    });
	
	$.getJSON("http://myspace.jochemschutte.nl/api/?format=json&myspace_id=427139548", function(data){
		$.each(data, function(i,item){
			$("#shows").append("<li><strong> " + date(item.date) + "</strong> " + item.city + ", " + item.venue + "</li>");
		});
		alert('sss');
	}); 
	
	$.ajax({
        type: 'GET',
        url: 'http://myspace.jochemschutte.nl/api/?format=json&myspace_id=427139548',
        dataType: 'jsonp',
        success: function(data){
           	$(".gigs-table").html('');
		    $.each(data, function(i, val) {
            	$(".gigs-table").append("<tr><td class='col1'>" + date(val.date) + "</td><td class='col2'>" + val.venue + "</td><td class='col3'><a target='_blank' href='http://www.myspace.com/therealjackparow/shows'>Buy tickets</a></td></tr>");
			});
            $('#nxt').html(data[0].venue);
        },
        beforeSend: function(data){
            $(".gigs-table").html('<tr><td colspan="3">loading...</td></tr>');
        }
    });
     
	

});

function date(ts)
{
	/* do anything with the date you want, the date is formatted in a timestamp. */ 
	return ts.substring(0, 10);
}

Cufon.replace('h1, h2, h3, .coming-soon, .home-comp', {
    fontFamily: 'marker-felt',
    hover: true
});

