/**
 * Main JS file of www.tomgreuter.nl
 * 
 * @author Tom Greuter
 */

/**
 * @class Tom
 */
Tom = function() {

	var gost;
	
	function Gost(name) {
		this.name = name;
	}

	/* PRIVATE METHODS */
	/**
	 * Gets a JSON-datafeed of the last photos of a certain user id
	 * Thnx to: http://www.viget.com/inspire/pulling-your-flickr-feed-with-jquery/
	 * @param {String} flickr_user_id Flickr user id
	 */
	function getFlickrPhotos(flickr_user_id) {
	  var urrel = "http://api.flickr.com/services/feeds/photos_public.gne?id=" + flickr_user_id + "&format=json&jsoncallback=?";
		$.getJSON(urrel, 
			function(data){
  			if (data.items.length > 0) { $("#images").html("") }
  		  $.each(data.items, function(i,item){
  		    $("<img/>").attr("src", item.media.m).appendTo("#images")
  		      .wrap("<a href='" + item.link + "'></a>");
  				// if (i==1) return false; // WHILE TESTING
  		  });
  		  // $("#link").html("<a href='"+data.link+"'>of bekijk wat van mijn flickr-foto's:</a>");
  			// Nu even toveren met de cycle-plugin
  		  $('#images').cycle({
  		    fx: 'fade',
  		    speed: 1000,
  		    timeout: 5000,
  		    next: '#next',
  		    prev: '#prev'
  		  });
  		});
	} // getFlickrPhotos
	
	function ruimop() {
		$("#ruimop").click( function() {
			$("#footer").hide();
			$("#wrapper")
				.css("border", "10px solid #000")
				.animate({"left": "40%", "right": "60%", "top": "40%", "bottom": "60%"}, 4000, function() {
					$(this).fadeOut(500, function() {
						$("head title").html("foetsie");
						$("body").remove();
					});
				});
		});
	}
	
	function startRazgovor() {
		gost = new Gost;
		$("#q1 input").blur( function() {
			console.log("blur")
//			if($("#q1 input").val()<> "") {
				gost.name = $("#q1 input").val();
				console.log(gost.name);
				$(".q1").html(gost.name);
	//		}
		});
	}
	
	/* PUBLIC METHODS */
	return {
		/**
		 * The sort-of constructor of this class Tom
		 */
		init: function(){
      // ruimop();
      // startRazgovor();
      getFlickrPhotos("43537544@N00"); // my personal user id on flickr
		}		
	}; // return
}();

/**
 * Start application on DOMContentLoaded
 */
$(document).ready(function(){
  Tom.init();
});

