// get today's date
today = new Date();
date = today.getDate();
var sDay;
var sMonth;
var dayNames = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var monthNames = new Array ('January','February','March','April','May','June','July','August','September','October','November','December');
sDay = dayNames[today.getDay()];
sMonth = monthNames[today.getMonth()];
finalDate =  sDay + ", " + sMonth + " " + date;


function openPopUp(theURL,winName,features) { //v2.0
  mapWin = window.open(theURL,winName,features);
  mapWin.focus();
}

// Our URL used for terms of use.
strUrl = 'codebase/termsOfUse.asp?url=www.moncrieffrealty.com';
function openTerms(sUrl) {
	openPopUp(sUrl, "ca", "scrollbars=yes, menubar=no, width=450, height=500, resizable=yes");
}

// open VT Window
function openVT(sUrl) {
	openPopUp(sUrl, "vt","scrollbars=no, status=yes, menubar=no, width=720, height=520, resizable=yes");
}
// open more photos
function openMorePhotos(sUrl) {
	openPopUp(sUrl, "mp","scrollbars=yes, menubar=no, width=350, height=310, resizable=yes");
}
// open visualInfo (property.asp)
function openVisualInfo(sUrl) {
	openPopUp(sUrl, "vi","scrollbars=yes, menubar=no, width=350, height=350, resizable=yes");
}

// open  plans (property.asp - large, fp, lp)
function openPlans(sUrl) {
	openPopUp(sUrl, "pl","scrollbars=yes, menubar=no, toolbar=yes, width=600, height=500, resizable=yes");
}

// open Brochure
function openBrochure(sUrl) {
	openPopUp(sUrl, "br","scrollbars=yes, menubar=no, toolbar=yes, width=700, height=500, resizable=yes");
}
// open Rentals
function openRentals(sUrl) {
	openPopUp(sUrl, "br","scrollbars=yes, menubar=no, toolbar=yes, width=700, height=500, resizable=yes");
}
// open suburb info (property.asp, building.asp)
function openSuburb(sUrl) {
	openPopUp(sUrl, "su","scrollbars=yes, menubar=no, width=450, height=350, resizable=yes");
}

// open Call Me
function openCallMe(sUrl) {
	openPopUp(sUrl, "cm","scrollbars=no, menubar=no, width=280, height=450, resizable=yes");
}

function openCalc(sUrl) {
	openPopUp(sUrl, "ca", "scrollbars=yes, menubar=no, width=450, height=500, resizable=yes");
}

// open agent window
function openAgent(sUrl) {
	openPopUp(sUrl, "ag","scrollbars=no, menubar=no, width=320, height=360, resizable=yes");
}

// open chart
function openChart(sUrl) {
	openPopUp(sUrl, "ch","scrollbars=no, menubar=no, width=975, height=800, resizable=yes");
}

//pass a form name an array of itmes and an array of descriptive names - for the alert messages.
function checkFormItems(form, items, messages) {
	for (var i=0; i<items.length; i++) {				
		formItem = eval(form + "." + items[i]);
		formItemValue = eval(form + "." + items[i] + ".value");
		if (formItemValue == "" || formItemValue == "any") {
			alert("Please fill in the field: " + "\"" + messages[i] + "\"");
			formItem.focus();
			return false;
		}
	}
	return true;
}

function checkIsNumber(form, items, messages) {
	for (var i=0; i<items.length; i++) {				
		formItem = eval(form + "." + items[i]);
		formItemValue = eval(form + "." + items[i] + ".value");
		if (formItemValue != "") {			
			if (isNaN(formItemValue)) {
				alert("The field: " + "\"" + messages[i] + "\"" + "is not a valid number.");
				formItem.focus();
				return false;
			}
		}
	}
	return true;
}

// Check the quicksearch form.
function checkQuickSearchForm() {
	var pid = frmQuickSearch.txtPid.value;
	if ( !pid || isNaN(pid)) {
		alert("Property IDs must be a valid number. Please try again.");
		frmQuickSearch.txtPid.focus();
	} else {
		frmQuickSearch.submit();
	}
	
	return false;
}