var toCalendar, toDialog;
function init()
{
	positionOverlay();
	
	toCalendar = new YAHOO.widget.Calendar("toContainer", {
        iframe:false,          // Turn iframe off, since container has iframe support.
        hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
    });
    toDialog = new YAHOO.widget.Dialog("toSelectorContainer", {
        context:["moveInIcon", "tl", "bl"],
        zindex:20000,
        width:"16em",  // Sam Skin dialog needs to have a width defined (7*2em + 2*1em = 16em).
        draggable:false,
        close:true
    });
    toCalendar.render();
    toDialog.render();
    toDialog.hide();
    toCalendar.selectEvent.subscribe(toOkHandler, toCalendar, true);
	toCalendar.renderEvent.subscribe(function() {
        // Tell Dialog it's contents have changed, Currently used by container for IE6/Safari2 to sync underlay size
        dialog.fireEvent("changeContent");
    });
	YAHOO.util.Event.on("moveInIcon", "click", function() {
		if (YAHOO.util.Dom.get("moveInDate").value != "")
		{
			var selDateVal = YAHOO.util.Dom.get("moveInDate").value;
			if (toCalendar.select(selDateVal) != "Invalid Date")
			{
				var selectedDates = toCalendar.getSelectedDates(); 
		        if (selectedDates.length > 0) { 
		            var firstDate = selectedDates[0]; 
		            toCalendar.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear()); 
		            toCalendar.render();
		        }
	        }
			else
				YAHOO.util.Dom.get("moveInDate").value = "";
			toCalendar.render();
		}
		toDialog.show();
		if (YAHOO.env.ua.opera && document.documentElement) {
			// Opera needs to force a repaint
			document.documentElement.className += "";
		} 
	});
}
function toOkHandler(type,args,obj) {
    var selected = args[0];
	var selDate = this.toDate(selected[0]);

    // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
    var dStr = selDate.getDate();
    var mStr = selDate.getMonth() + 1;
    var yStr = selDate.getFullYear();

    YAHOO.util.Dom.get("moveInDate").value = mStr + "/" + dStr + "/" + yStr;
    toDialog.hide();
}
function positionOverlay()
{
	var xy = findPos(YAHOO.util.Dom.get("main-photo"));

	YAHOO.util.Dom.setStyle("main-photo-cover", "display", "block");
	YAHOO.util.Dom.setStyle("main-photo-cover", "left", xy[0] + "px");
	YAHOO.util.Dom.setStyle("main-photo-cover", "top", xy[1] + "px");
}		
function highlightListingRow(oThis)
{
	YAHOO.util.Dom.setStyle(oThis, "background-color", "#c3e1ff");
	YAHOO.util.Dom.setStyle(oThis, "color", "orange");
}
function unhighlightListingRow(oThis)
{
	YAHOO.util.Dom.setStyle(oThis, "background-color", "");
	YAHOO.util.Dom.setStyle(oThis, "color", "");
}

function hideLandlordContact() { }
function showListingDetails(oThis, contact) { }
