// Perform the camper status polling
$(document).ready(function(){
	pollvector = -1;
	pollUpdates();
	
	var pollStatus = setInterval("pollUpdates()",15000);

});


function pollUpdates() {
	// Performs the pollupdates
	$.get(APPNAME+"services.php?pollupdates=1&__pv="+pollvector,
		  function(data){
		  	data = $.trim(data).replace(/\r\n\r\n/g, '').split("|");
		  	
		  	if(data != "0") {
		  		$("#campers-wall-updates ul").html(data[0])
		  		pollvector = data[1];
		  		
		  		
		  	}
		  	
		  	refreshHeight();
		  });
}


function refreshHeight() {
	var mainColumn = $(".main").outerHeight(true);
	var sideColumn = $(".sidebar").outerHeight(true)+33;
	
	// If the side column is greater that the main column
	// adjust the main column height to balance out
	if(sideColumn > mainColumn) {
		// ADD the displacement to the existing height of the container
		$(".intro-text").height($(".intro-text div").outerHeight(true)+(sideColumn-mainColumn)+35);
	}
}
