willow.coverTimeout = "";
willow.socialTimeout = "";


willow.ready(function($) {

	$("#bg-photos").cycle();
	
	willow.setSitePosition();
	
	$(".sites li").bind("mouseenter mouseleave",function(e){
		var $obj = $(this),$cover = $(".cover");
		
		if($obj.children(".stuff").length > 0){
			if(e.type === "mouseenter"){
				clearTimeout(willow.coverTimeout);
				willow.killAllContent();
				$cover.show();
				$(".overlay").show();
				$obj.children(".stuff").show();
			}else{
				willow.coverTimeout = setTimeout(function(){
					willow.hideCovers();
				},250);
			}
		}
	});
	
	$(window).resize(function(){
		willow.setSitePosition();
	});
	
	$("#social li").bind("mouseenter mouseleave",function(e){
		
		if(e.type === "mouseenter"){
				clearTimeout(willow.socialTimeout);
				$(".sites").css("z-index","100");
			}else{
				willow.socialTimeout = setTimeout(function(){
					$(".sites").css("z-index","120");
				},250);
				
			}
		
	});
	
	/*wordpress JSON pull*/
	willow.eventCount = 0;
	willow.getSepCount = 0;
	$.getJSON("http://stowe.walnuthillarts.org/?feed=json&jsonp=?",function(data){
		$("#rssTemplate").tmpl(data,{
			getCount : function(){
				willow.eventCount++;
				if(willow.eventCount < 4){
					return true;
				}
				return false;
			},
			getSepCount : function(){
				willow.getSepCount++;
				if(willow.getSepCount < 3) {
					return true;
				}
				return false;
			}
		}).appendTo("#site-three .holder");
    });
	
	//willow.getText(99840,function(data){
	////willow.getText(99810,function(data){
	//	$("#footer_SEO_text").append(data.body);
	//});
  	   	
});

willow.setSitePosition = function(){
	var offset = $(".site-placeholder .offset").offset();
	$(".sites").css({"top":offset.top+"px","left":offset.left+"px","display":"block"});
	//$("#social li ul").css({"position":"absolute","z-index":"130"});
}

willow.hideCovers = function(){
	$(".cover").hide();
	$(".overlay").hide();
	willow.killAllContent();
}

willow.killAllContent = function(){
	$(".stuff").hide();
}
