/**
 *	Resize IFrame to fit contents
 */

$(document).ready(function()
{
	/*
	$('#mapFrame').load(function() {
		var $mapFrame = document.getElementById('mapFrame');
		var frameHeight;
		if ( $mapFrame.contentDocument ) { // DOM
			//frameHeight = $mapFrame.contentDocument.getElementById('map_controls').scrollHeight;
			frameHeight = $mapFrame.contentDocument.getElementById('map_controls').offsetHeight;
		} 
		else if ( $mapFrame.contentWindow ) { // IE win
			frameHeight = $mapFrame.contentWindow.document.body.scrollHeight;
		}
		//alert('height: ' + frameHeight);
		$mapFrame.height = frameHeight; // or style.height..
	});
	*/
	
	/**
	 * Hide the form unless there are errors
	 */
	if ($(".cmtErrors").length == 0) {
		$('#mapCmtForm').hide();
	}
	
	$('#commentToggle').click(function(){
		$('#mapCmtForm').slideToggle();
		return false;
	});
	
	/** Handle comment box **/
	$('#cmtSubmit').click(function() {
		$('#mapCmtForm').submit();
		return false;
	});
	
});

function calculateHeight()
{
  var $nh = document.getElementById('mapFrame').contentWindow.document.body.scrollHeight;
  //document.getElementById('mapFrame').height = $newHeight;
  alert($nh);
}

