	$(document).ready(function(){
		$("#display_cart_summary").slideDown();
		setTimeout('$("#display_cart_summary").slideUp()',2000);
	});	
	
	$.getJSON("http://suadmin.streetunitforum.com/json/home/?callback=?", function(data){
		
		// Remove home page content, replace with good information
		//==============================================================
		$("#content_area").css("background-color","#000000");
		$("#content_area").html($("#home_content").html());
		$("#content_area").show();

		// Build articles section
		//==============================================================
		$(data.articles).each(function(i,article){
			$("#home_news").append(
				'<div class="object" id="article_'+article.Article.id+'">'+
					'<div class="pointer">&raquo;</div>'+
					'<div class="name"><a href="javascript:void(0)">'+article.Article.name+' <i class="red">read &raquo;</i></a></div>'+
					'<div class="body">'+article.Article.body+'</div>'+
				'</div>'+
				'<div class="section_div"></div>'
			);
		});
		$("#home_news div.object:first div.body").show();
		$("#home_news div.object:first div.name a i").hide();
		

		// Build events section
		//==============================================================
		$(data.events).each(function(i,event){
			$("#home_events").append(
				'<div class="object" id="event_'+event.Event.id+'">'+
					'<div class="pointer">&raquo;</div>'+
					'<div class="name"><a href="javascript:void(0)">'+event.Event.name+' <i class="red">read &raquo;</i></a></div>'+
					'<div class="gray">'+event.Event.formatted_date+'</div>'+
					'<div class="body">'+event.Event.details+'</div>'+
				'</div>'+
				'<div class="section_div"></div>'
			);
		});
		

		// Manage sliding up/down of news and events
		//==============================================================
		$("#news_events div.object div.name a").click(function(){

			var idClicked = $(this).parent().parent().attr("id").replace("article_",""); // ID of the object clicked
			var objectTypeClicked = $(this).parent().parent().attr("id").replace("_"+idClicked,""); // Type of object clicked : event|article

			$(this).parent().parent().parent().children("div.object").each(function(){ // loop over objects of same type
				if($(this).attr("id").replace(objectTypeClicked+"_","") == idClicked){ // if this is the one we clicked
					if($(this).children("div.body:first").is(":hidden")){
						$(this).children("div.body:first").slideDown("slow"); // show if it's hidden
						$(this).children("div.name").children("a").children("i").fadeOut();
					}
				}else{ // if it's NOT the one we clicked
					if(!$(this).children("div.body:first").is(":hidden")){ // if it's NOT hidden
						$(this).children("div.body:first").slideUp("slow"); // hide it
						$(this).children("div.name").children("a").children("i").fadeIn();
					}
				}
			});
			$(this).blur(); // blur the link
		});
		

										
										


		// Add image slides to the carousel
		//==============================================================
//		$(data.slides).each(function(i,slide){
//			html = "<img src='http://suadmin.streetunitforum.com/img/slides/"+slide.Slide.original_image+"' alt='"+slide.Slide.name+"' width='700' height='250'>";
//			if(slide.Slide.url != ''){
//				html = "<a href='http://suadmin.streetunitforum.com/slides/click/"+slide.Slide.id+"' title='"+slide.Slide.name+"'>"+html+"</a>";
//			}
//			$("#carousel_ul").append("<li id='carousel_image_"+(i+1)+"'>"+html+"</li>");
//		});							


		// Add image slides to the carousel
		//==============================================================
		$(data.slides).each(function(i,slide){
			$("#carousel_ul").append("<li id='carousel_image_"+(i+1)+"'><a href='http://suadmin.streetunitforum.com/slides/click/"+slide.Slide.id+"' title='"+slide.Slide.name+"'><img src='http://suadmin.streetunitforum.com/img/slides/"+slide.Slide.original_image+"' alt='"+slide.Slide.name+"' width='700' height='250'></a></li>");
		});
		
		
		// Build Carousel
		//======================================
			var visibleSlides = $("#carousel_ul li").size()>=2?2:1;
		    $(".home_page_carousel").jCarouselLite({
		        btnPrev:".carousel_plus_buttons .next",
		        btnPause:".carousel_plus_buttons .pause",
		        btnNext:".carousel_plus_buttons .prev",
		        auto:7000,
		        circular:true,
		        visible:visibleSlides,
		        vertical:true,
		        speed:1000
		    });
		

										
		// Fade carousel controller in and out of hover
		//======================================
		$(".carousel_plus_buttons").hover(function(){
			$(this).children(".prev, .pause, .next").fadeIn(250);
		},function(){
			$(this).children(".prev, .pause, .next").fadeOut(250);
		});
		
		// Blur carousel controller links when clicked
		//======================================
		$(".carousel_plus_buttons a").click(function(){
			$(this).blur();
		});
		
		// Swap carousel controller arrow images on hover
		//======================================
		$(".carousel_plus_buttons .prev img, .carousel_plus_buttons .pause img, .carousel_plus_buttons .next img").hover(function(){
			$(this).attr("src", $(this).attr("src").replace("out","over"));
		},function(){
			$(this).attr("src", $(this).attr("src").replace("over","out"));
		});
	});
	
	