// returns a string of today's date in the format: February 7, 2010
function today_string()
{
	var today = new Date();
	var month = new Array(7);

	month[0] = "January";
	month[1] = "February";
	month[2] = "March";
	month[3] = "April";
	month[4] = "May";
	month[5] = "June";
	month[6] = "July";  
	month[7] = "August";
	month[8] = "September"; 
	month[9] = "October";
	month[10] = "November";
	month[11] = "December";

	var year = today.getYear();
	if (year < 2000) {
		year+=1900;
	}

	return month[ today.getMonth() ] + " " + today.getDate() + ", " + year;
}

// image preloading / swapping functions
// REQUIRES inline js setup of preload_images[] array with paths
// to images to be preloaded.
function preload()
{
	var tmp = null;
	for (var i = 0; i < preload_images.length; i++) {
		tmp = preload_images[i];
		preload_images[i] = new Image();
		preload_images[i].src = tmp;
	}
}

function imgSwap(img, swap) {
	img.src = preload_images[swap].src;
}

function toggle_hidden_status(id) {
	new Ajax.Request('/rentals/toggle_hidden_listing/' + id, { method: 'post' });
}

function toggle_apt_week_status(id) {
	new Ajax.Request('/rentals/toggle_apartment_of_the_week/' + id, { method: 'post' });
}

function toggle_apt_month_status(id) {
	new Ajax.Request('/rentals/toggle_apartment_of_the_month/' + id, { method: 'post' });
}
