


$(document).ready(function(){
	
	// fix PNGs for IE6
	$(document).pngFix();
	
	// home special "close" button
	$("a#home-special-close").click(function(){
		$("#home-special").hide("fast");
		return false;
	});
	
	// multiple columns
	$(".multicol").columnize({columns:2});
	$(".multicol p").addClass("dontsplit");
	$(".multicol").css({margin:'10px'});
	
	// gallery slideshow rollovers
	$("a.floorplan-thumb").fadeTo('slow',0.7);
	$("a.floorplan-thumb").hover(function(){
		$(this).fadeTo('fast',1);
	},function(){
		$(this).fadeTo('slow',0.7);
	});
	
	// floorplan fancybox
	$("a.floorplan-thumb").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	
	// gallery slideshow rollovers
	//$("a.gallery-thumb").fadeTo('slow',0.5);
	$("a.gallery-thumb").hover(function(){
		$(this).fadeTo('slow',0.3);
	},function(){
		$(this).fadeTo('slow',1);
	});
	
	// gallery fancybox
	$("a.gallery-thumb").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	
});

function onAfterGallery(curr,next,opts) {
	var curSlide = opts.currSlide + 1;
	$(".gallery-thumb").removeClass("active");
	$(".gallery-thumb-"+curSlide).addClass("active");
}

function zeroPad(num, places) {
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
}

function getCounterNumbers(){
	$("#counterNumbers li").html("<img src='http://campusparkapartments.com/wp-content/themes/blankSlate3.0/img/counter_nbr_blr.png'>");
	$.ajax({
		url:"http://campusparkapartments.com/counter/getCount.php?s=fd",
		dataType: "json",
		success:function(data){
			var theCountPadded = zeroPad(data.count, 3);
			$("#counterNumbers li:nth-child(1)").html(theCountPadded.substring(0,1));
			$("#counterNumbers li:nth-child(2)").html(theCountPadded.substring(1,2));
			$("#counterNumbers li:nth-child(3)").html(theCountPadded.substring(2,3));
			$("#counterDate").html("(As of " + data.date + ")");
		}
	});
}
