// Get today's date
today = new Date();
var intDate;
var strDay;
var strMonth;
var intYear;
var finalDate;

var monthNames = new Array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

intDate = today.getDate();
strMonth = monthNames[today.getMonth()];
intYear = today.getYear();

intLastDigit = intDate % 10;
strSuffix = "th";
if ( intLastDigit == 1 ) {
	strSuffix = "st";
} else if ( intLastDigit == 2 ) {
	strSuffix = "nd";
}
if ( intDate > 10 && intDate < 20 ) {
	strSuffix = "th";
}

function openPopUp(theURL,winName,features) { //v2.0
  mapWin = window.open(theURL,winName,features);
  mapWin.focus();
}


finalDate =  intDate + strSuffix + " " + strMonth + " " + intYear;

// open VT Window
function openVT(sUrl) {
	var url = sUrl;
	vtWin = window.open(url, "vt","scrollbars=no, status=yes, menubar=no, width=720, height=520, resizable=yes");
	vtWin.focus();
}
// open more photos
function openMorePhotos(url) {
		var surl = url;
		mpWin = window.open(surl, "mp","scrollbars=yes, menubar=no, width=350, height=310, resizable=yes");
		mpWin.focus();
}
// open visualInfo (property.asp)
function openVisualInfo(url) {
		var surl = url;
		viWin = window.open(surl, "vi","scrollbars=yes, menubar=no, width=350, height=350, resizable=yes");
		viWin.focus();
}

// open  plans (property.asp - large, fp, lp)
function openPlans(url) {
		var surl = url;
		plWin = window.open(surl, "pl","scrollbars=yes, menubar=no, toolbar=yes, width=600, height=500, resizable=yes");
		plWin.focus();
}

// open Brochure
function openBrochure(sUrl) {
	var url = sUrl;
	brWin = window.open(url, "br","scrollbars=yes, menubar=no, toolbar=yes, width=700, height=500, resizable=yes");
	brWin.focus();
}

// open print rentals lists
function openRentals(sUrl) {
	var url = sUrl;
	rlWin = window.open(url, "rl","scrollbars=yes, menubar=no, toolbar=yes, width=650, height=500, resizable=yes");
	rlWin.focus();
}

// open suburb info (property.asp, building.asp)
function openSuburb(url) {
		var surl = url;
		suWin = window.open(surl, "su","scrollbars=yes, menubar=no, width=450, height=350, resizable=yes");
		suWin.focus();
}

// open Call Me
function openCallMe(sUrl) {
	var url = sUrl;
	cmWin = window.open(url, "cm","scrollbars=no, menubar=no, width=280, height=400, resizable=yes");
	cmWin.focus();
}

function openCalc(sUrl) {
	var url = sUrl;
	caWin = window.open(url, "ca", "scrollbars=yes, menubar=no, width=450, height=500, resizable=yes");
	caWin.focus();
}

// open agent window
function openAgent(sUrl) {
	var url = sUrl;
	agWin = window.open(url, "ag","scrollbars=no, menubar=no, width=320, height=360, resizable=yes");
	agWin.focus();
}

// open chart
function openChart(sUrl) {
	var url = sUrl;
	chWin = window.open(url, "ch","scrollbars=no, menubar=no, width=800, height=670, resizable=yes");
	chWin.focus();
}

//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;
}

function openTerms(sUrl) {
	var url = sUrl;
	caWin = window.open(url, "ca", "scrollbars=yes, menubar=no, width=525, height=500, resizable=yes");
	caWin.focus();
}