

// resets page with new variable from dropdown menu
function loadPage(theselect,prevars,otherselect) {
	//theform = document.getElementById(theselect).form;
	show = document.getElementById(theselect).value;
	if (show!="") {
		if(prevars) {
			prefix = "?"+prevars+"&";
		} else {
			prefix = "?";
		} // if else prevars
		add = "";
		if(otherselect) {
			add = "&"+otherselect+"="+document.getElementById(otherselect).value;
		} // if other
		newpage = window.location.pathname+prefix+theselect+"="+show+add;
		//alert(newpage);
		window.location = newpage;
	} // if show
}

// script for spawning new window
function openWindow(page,windowName,width,height,tools) {
	switch (tools) {
		case "all":
			showTools = ",resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes";
			break;
		case "none":
			showTools = ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no";
			break;
		case "size":
			showTools = ",resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes";
			break;
		default:
			showTools = ",resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes";
	}

    myWin = window.open(page,'windowName','width=' + width + ',height=' + height + showTools);
    
    // if window has already been opened and is behind main window, bring to front
	if (!myWin.focus()) {
		myWin.focus();
	}
}

function loadParent(url) {
  var parentWin = window.opener
  if (window.opener.closed) {
    window.open(url,"parentWin");
  } else {
    parentWin.location = url;
    if (window.focus) {
      parentWin.focus();
    }
  }
}

// ----------------------------------------------
// Real estate description page:
// Change source of main image after user
// clicks on thumbnail
// ----------------------------------------------

function changeImgSrc(id,filename) {
	document.getElementById(id).src = filename;
} // function


// taken from Wired (wired.com -- thanks) taken from:

// ----------------------------------------------
// Date functions
// ----------------------------------------------

function isValidDay(iMonth, iDay, iYear) {

	//if selected exceeds max days in the month, returns max

	//set the days of the month array
	var aMonthDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

	//if it's a leap year, add a day to feb
	if (iYear%4 == 0) {
		aMonthDays[1] = 29;
	}

	var iMonthIndex = iMonth-1;
	var iMaxDays = aMonthDays[iMonthIndex];
	
	//if the day exceeds the max, return the max
	if (iDay > iMaxDays) {
		return iMaxDays;
	} else {
		return iDay;
	}

}

































































































































































































