/* =================================================================
  BIND EVENT LISTENERS
================================================================= */
$(document).ready(
	function() {
		/* INIT FLOATING WINDOW */
		bubble.init();

		/* ONCLICK - SAVE LISTING LINKS */
		$('div#listDetail div.tools ul li.save a').click( function(e) { saveListing(e, this); return false; } ).focus( function() { this.hideFocus = true; });

		/* ONCLICK - SAVE NOTE LINKS */
		$('div#listDetail div.tools ul li.note a').click( function(e) { saveNote(e, this); return false; } ).focus( function() { this.hideFocus = true; });

		/* ONCLICK - EMAIL LISTING LINKS */
		$('div#listDetail div.tools ul li.email a').click( function(e) { emailListing(e, this); return false; } ).focus( function() { this.hideFocus = true; });

		/* ONCLICK - MORTGAGE CALCULATORS */
		$('div#listDetail div.tools ul li.calc a').click( function(e) { mtgCalc.show(e, this); return false; } );

		/* ONCLICK - SAVE ALL RECENTLY VIEWED LISTINGS */
		$('div#yso_quickView a#saveRecent').click( function(e) { saveRecentListings(e, this); return false; } );

		/* ONCLICK - CONTACT AGENT ABOUT LISTING */
		$('div#listInfo div.contact a.contact').click( function(e) { listingInquiry(e, this); return false; } ).focus( function() { this.hideFocus = true; });

		/* ONCLICK - SCHEDULE VISIT */
		$('div#listInfo div.contact a.visit').click( function(e) { scheduleVisit(e, this); return false; } ).focus( function() { this.hideFocus = true; });

		/* UPDATE ORGANIZER
		getQuickView(); */

		/* IF DESCRIPTION IS ALL CAPS, FIX IT */
		var funkyDescr = $('div#listDetail div.description p');
		if (funkyDescr.size() > 0) {
			var funkyDescrHTML = funkyDescr.html();
			if (funkyDescrHTML.substring(0,20) == funkyDescrHTML.substring(0,20).toUpperCase()) {
				funkyDescr.html(toProperCase(funkyDescr.html()));
			}
		}

	}
);