$(document).ready(function(){
	
		// Replace HRs with Divs in IE
		// This is necessary because IE doesn't let you style the HR element, and we use it extensively on the site.
	  if (jQuery.browser.msie) {
			$("hr").each(function() {
				var hrClass = $(this).attr("class")
				$(this).wrap("<div class='hr " + hrClass +"'></div>");
			});
		}
		
		// Add utility first/last/alt classes to LIs.
		$("ul li:first-child").addClass("first");
		$("ul li:last-child").addClass("last");
		$("ul li:nth-child(even), table tr:nth-child(even)").addClass("alt");
		
		//Input focus and blur
		$("input[type='text'], textarea").focus(function(){
			$(this).addClass("focus");
		});
		$("input[type='text'], textarea").blur(function(){
			$(this).removeClass("focus");
		});
		
		// Hover effect at the top
		$("#menu ul li ").hover(
			function() {
       $(this).find("ul").css({"left" : "0px"});
     }, 
     function () {
       $(this).find("ul").css({"left" : "-9999px"});
     }
		);
		$("#menu ul li ul").hover(
			function() {
       $(this).css({"left" : "0px"});
     }, 
     function () {
       $(this).css({"left" : "-9999px"});
     }
		);
		
		// Set us up the carousel
//		$('#home-carousel') 
//		.before('<ul id="home-carousel-captions">') 
//		.cycle({ 
//			 	cleartype:  1,
//		    fx:     'fade', 
//		    speed:  'fast', 
//		    timeout: 15000, 
//		    pager:  '#home-carousel-captions',
//				pagerEvent:   'click',
//				pause:         true,
//		    pagerAnchorBuilder: function(idx, slide) { 
//		        return '<li><a href="#">' + $(slide).attr("class") + '</a></li>'; 
//		    }
//		});
//
//		$('#home-carousel-captions a').click(function() { $('#home_carousel').cycle('pause'); });
//		
		
		// $.getJSON("http://api.flickr.com/services/feeds/photoset.gne?set=72157611960731959&nsid=26853664@N03&lang=en-us&display=latest&format=json&jsoncallback=?",
		// 		function(data){
		// 	    	$.each(data.items, function(i,item){
		// 					$("<img/>").attr({
		// 						src: item.media.m,
		// 						title: item.title,
		// 						alt: item.title
		// 					}).appendTo("#home-gallery").wrap("<a href='" + item.link + "' target=\"_blank\"></a>");
		// 
		// 					$("#title").html(data.title);
		// 					$("#description").html(data.description);
		// 					$("#photoset").html("<a href='"+data.link+"' target=\"_blank\">Click to visit the photoset</a>");
		// });
		
		
		
		$.getJSON("http://api.flickr.com/services/feeds/groups_pool.gne?id=1514737@N20&lang=en-us&format=json&jsoncallback=?",
				function(data){
			    	$.each(data.items, function(i,item){
							$("<img/>").attr({
								src: item.media.m,
								title: item.title,
								alt: item.title
							}).appendTo("#home-gallery").wrap("<a href='" + item.link + "' target=\"_blank\"></a>");
		
							$("#title").html(data.title);
							$("#description").html(data.description);
							$("#photoset").html("<a href='"+data.link+"' target=\"_blank\">Click to visit the photoset</a>");
		});

		
		
		// $.getJSON("http://api.flickr.com/services/rest/?format=json&method=flickr.photos.search&tags=launchbox08&tag_mode=all&api_key=e1f975c3eff32439dd6032b38550bd04",
		// 		function(data){
		// 	    	$.each(data.items, function(i,item){
		// 					$("<img/>").attr({
		// 						src: item.media.m,
		// 						title: item.title,
		// 						alt: item.title
		// 					}).appendTo("#home-gallery").wrap("<a href='" + item.link + "' target=\"_blank\"></a>");
		// 
		// 					$("#title").html(data.title);
		// 					$("#description").html(data.description);
		// 					$("#photoset").html("<a href='"+data.link+"' target=\"_blank\">Click to visit the photoset</a>");
		//                // alert(i);
		//                // if ( i == 3 ) return false;
		// });
		
		

		$('#home-gallery').cycle({ 
				fx:     'fade', 
				speed:    'normal', 
				timeout:  5000,
				next:   '#next',
			  prev:   '#prev'
			});
	  });


});



