/* Property Data global javascript */

function submitPropertyDataSearch() {

	/* 	# %PUBLIC%
		# NAME:*		submitPropertyDataSearch
		# DESCR:*		Grabs the property data suburb value from the "propertydatasub" text input field
		# :*			and property data state value from the "propertydatastate" select control, checks
		# :*			the suburb name is not null or blank and redirects browser to the propertydata
		# :*			CGI:Application module run mode "propertydata" to search for property data
		# :*			with the given criteria.		
		# USAGE:*		submitPropertyDataSearch();
		# RETURNS:*		false always.
		# %ENDPUBLIC% */

	var suburbname = $F('propertydatasub');
	var state = $F('propertydatastate');

	// Check that our propertydatasub field is not blank
	if (suburbname == '' || suburbname == null) {
		alertBox('Property Data Search Error:', 'You must enter a suburb name to search for.');
		return false;
	}

	window.location = '/portal/propertydata?rm=propertydata&search=1' + '&suburbname=' + suburbname + "&state=" + state;

	return false;
}

var openAlphabetSuburbDiv = '';

function displayAlphabetDiv(DivIDToDisplay) {

	/* 	# %PUBLIC%
		# NAME:*		displayAlphabetDiv
		# DESCR:*		Given an ID of a div, Fade(hide) any div that is currently displaying
		# :*			and Appear(show) the div whose ID is passed. Uses Scriptaculous effects
		# :*			for Fade and Appear.	
		# USAGE:*		displayAlphabetDiv('suburbalphabetA');
		# RETURNS:*		Nothing. The currently open div will close and the div whose ID is passed will open.
		# %ENDPUBLIC% */

	if (DivIDToDisplay != '' || DivIDToDisplay != null) {

		if (openAlphabetSuburbDiv != '') {
			Effect.Fade(openAlphabetSuburbDiv, {
												afterFinish: function() {
													resizePage();
												},

												duration: 0.5, queue: 'end'});
		}

		Effect.Appear(DivIDToDisplay, {
										afterFinish: function() {
											resizePage();
										},
										duration:0.5, queue: 'end'});

		openAlphabetSuburbDiv = DivIDToDisplay;

	}

}

function resizePage() {

	/* 	# %PUBLIC%
		# NAME:*		resizePage()
		# DESCR:*		Due to the fact the portal design is such that right / left columns,
		# :*			header div are not flowing through out the page design but are x, y
		# :*			co-ordinate located, the content div area does not grow /shrink with page
		# :*			content that is hidden / shown. This is a rough hack to make sure that any
		# :*			page text that over hangs the page size when shown, resizes the page.
		# :*			Just another reason why the current portal design is a croc.....
		# USAGE:*		INTERNAL CALL. DO NOT USE.
		# RETURNS:*		Nothing.
		# %ENDPUBLIC% */

	// Make sure we resize the backgorund when a larger div opens.

	var contentContainer = $("contentContainer");  
	var scrollHeight = document.body.parentNode.scrollHeight;  
	var windowHeight = window.innerHeight;  

	if (scrollHeight < windowHeight ) {
		document.body.style.height = windowHeight + "px";
		contentContainer.style.height = windowHeight + 'px';

	} else {
		document.body.style.height = scrollHeight + 'px';
		contentContainer.style.height = scrollHeight + "px";

	} 
} 

