// lift-vimeo.js
// Author: Eli Dupuis, Greg Crossfield
// Date: Aug 23, 2011
// 
// Dependancies:
// jQuery 1.6.2
// Vimeo JSON feed
//
// Documentation:
// http://vimeo.com/api/docs/simple-api


$(function(){         

  // looks for a specific json feed based on some variables "channel/user/type/etc."

  var url = 'http://vimeo.com/api/v2/abnawmp/videos.json'
  if(window.console) window.console.log("requesting", url);
  $.ajax({
    url: url,
    get: 'GET',
    dataType: 'jsonp',
    success: function(data){
      if(window.console) window.console.log('success', data);
      var videos = data;
      var theHtml = '';
      
      for (var i=0; i < 1; i++) {
        var video = videos[i];
        
        //sends information to the console

        if(window.console) window.console.log( video.url, video.description, video.duration, video.thumbnail_small, video.title );

        //generates the HTML

        theHtml += '<div class="videothumb">';
        theHtml += '<h2>' + "Video" + '</h2>';
        theHtml += '<img src="' + video.thumbnail_small + '" alt="" />';
        theHtml += '<h3>' + '<a href="/video/" class="titlebtn">' + video.title + '</a>' + '</h3>';
        theHtml += '<p>' + video.description + '</p>';
        theHtml += '</div>';
        
      };
      
      //output to HTML

      $('#videowidget').html(theHtml); 

    },

	//error messages
	
    error: function(jqXHR, textStatus, errorThrown){
      if(window.console) window.console.log('AJAX error', jqXHR, textStatus, errorThrown);
    }

  });
  
});



