// Default scripts - to be displayed on every page

// get the max number from any number of arguments
function getMax() {

	var args = getMax.arguments;
	var maxNumber = 0;

	for (i=0; i<args.length; i++) {
		if (args[i] > maxNumber) {
			maxNumber = args[i];
		}
	}

	return maxNumber;

}

function newSizedNamedWindow(url, windowName, width, height) {

		newWindow = window.open(url, windowName, 'menubar=no,status=no,scrollbars=auto,resizeable=no,width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,top=0,left=0,screenX=0,screenY=0');
	    newWindow.focus();

}

function newSizedScrollingWindow(url, windowName, width, height) {

		newWindow = window.open(url, windowName, 'menubar=no,status=no,scrollbars=yes,resizeable=no,width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,top=0,left=0,screenX=0,screenY=0');
			newWindow.focus();

}

function launchLotMap(startCommunity) {

	newSizedScrollingWindow('index.cfm?act=main.viewLotMap&communityID=' + startCommunity, 'lotMapWindow', 775, 614);

}

function imageSwap(theImage, newSRC) {
	theImage.src = newSRC;
}


function simplePreload() {

  var args = simplePreload.arguments;

  document.imageArray = new Array(args.length);

  for(var i=0; i<args.length; i++) {

    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];

  }

}

function preloadTopMenuImages() {
	simplePreload('images/topMenu/home_Over.png','images/topMenu/ourNeighbourhoods_Over.png','images/topMenu/homeBuilders_Over.png','images/topMenu/mapsAndLocations_Over.png','images/topMenu/siftonQuality_Over.png','images/topMenu/contactUs_Over.png');
}

function preloadLeftNavImages() {

	if( null != document.getElementById('leftNavMouseoverImageList') ) {

		simplePreload(document.getElementById('leftNavMouseoverImageList').value);

	}

	/* if( typeof( document.getElementById('leftNavMouseoverImageList') ) != 'undefined' ) {

		simplePreload(document.getElementById('leftNavMouseoverImageList').value);

	} */

}

function deleteMediaFile(mediaFileID, returnPage)
{

	if (confirm('Are you sure you want to delete this file? Once it has been deleted it cannot be retrieved.'))
	{
		window.location.href = 'DeleteMediaFile.aspx?mediaFileID=' + mediaFileID + '&returnPage=' + returnPage;
	}

}

function deleteLecture(lectureID, returnPage)
{

	if (confirm('Are you sure you want to delete this lecture? Once it has been deleted it cannot be retrieved.'))
	{
		window.location.href = 'DeleteLecture.aspx?lectureID=' + lectureID + '&returnPage=' + returnPage;
	}

}

/**
* Function creates a popup for links on the right sidebar..
* Added February 06, 2009
* @access public
* @param string locationURL URL to load in the popup window
*/
if ((window.navigator.userAgent.indexOf("Firefox") != -1) || (window.navigator.userAgent.indexOf("MSIE") != -1) || (window.navigator.userAgent.indexOf("SV1") != -1)) {
	var w_screen = screen.availWidth;
	var h_screen = screen.availHeight;
}

var win= null;
function popit(mypage,myname,w,h){
	var winl = (w_screen-w)/2;
	var wint = (h_screen-h)/2;
	settings='height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=no,toolbar=no';
	win=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

