﻿jQuery(function($) {
	
	$('#slideshow_imgs').cycle({timeout: 4000})
	
	// Random tip on home page
	
	function initTips() {
		var tips = $('.tips li');
		if (tips.length > 0) {
			var tipIndex = Math.ceil(Math.random() * 50000) % tips.length;
			tips.removeClass('active').eq(tipIndex).addClass('active');
		}
	};
	
	initTips();

  //	var pipeURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=6158bedce0931c698d80f36a88e86054&_render=json&_callback=?";

  	var feedSuccess = function(data, status){
  		count = 1;
  		num_allowed = 6;
  		var html = "<ol>";
  		$.each(data.value.items, function(i,item){
  			html += "<li><h3><a href=\""+item.link+"\" target=\"_blank\">" + item.title + "</a></h3></li>";
  			count++;
  			if (count == num_allowed) { return false; }
  		});
  		html += "</ol>";

  		//Add the feed to the page
  		$("#feed").empty().append(html);
  	};

  	/**
  	* Make the ajax call. You can also use $.getJSON.
  	*/
  	$.ajax({
  		dataType: "json",
  		url: pipeURL,
  		success: feedSuccess,
  		timeout: 4000
  	});
});
