$(document).ready(function() {
	$(".nopic").vAlign();
	jQuery("#tweets").getTweet("vtcyt", 2);
	$('.slideshow').cycle({ 
    fx:    'fade',
    random: 1,
    speed:  2500,
    timeout: 8000,
		containerResize: 1,
		fit: 1,
		width: 460,
		pause: 1
 });

	$("#main-nav>ul>li>a").hover(
	  function () {
        $("ul").removeClass('hover');
	    $(this).siblings('ul').addClass('hover');
	  }
	);
	
	$(".hover").live("mouseleave", function(event) {
		$(this).removeClass('hover');
	});

    $("#header").live("mouseover", function(event) {
        $("ul").removeClass('hover');
    });

});

function fbFetch() {
    //Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
    var url = "https://graph.facebook.com/108838269150549/feed?access_token=112626472156304|0a970ae60301d619e22ffaba.1-100000940163997|NQYauLBdN3eCBfE2hXaSJkPfuZ4&limit=2&callback=?";

    //Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
    $.getJSON(url,
    function(json) {
        var html = '<ul>';

        //loop through and within data array's retrieve the message variable.
        $.each(json.data,
        function(i, fb) {
			html += '<li class="fb">';
			html += '<img class="fb-userpic" src="http://graph.facebook.com/' + fb.from.id + '/picture?type=square">';
            html += '<span class="fb-username">' + fb.from.name + ' </span>';
     		html += '<span class="fb-message">' + fb.message + '</span>';
	 		html += '</li>';
        });
        html += '</ul>';
        //A little animation once fetched
        $('#facebook div').animate({
            opacity: 0
        },
        500,
        function() {
            $('#facebook div').html(html);
        });
        $('#facebook div').animate({
            opacity: 1
        },
        500);
    });
};
