/**********************************************************************
 * HH400 Google Maps API Project
 * @File: hh400.map.fullscreen.js
 * Includes functions that control how the map is displayed;
 * Utilizes prototype.js element methods to insert elements back and
 * forth between fixed width and dynamic width elements on the map
 * Version 1.0 | 05-04-2009
 * Developed by Cartosoft, LLC
 * http://www.cartosoft.com | info@cartosoft.com
 * Copyright 2009 Google, Inc. | http://www.google.com
**********************************************************************/

/***
Show map in full screen
***/

function showFullScreen() {
	
	//$('fullscreen-tip-fullscreen').setStyle({display:'none'});

	var fs_wrapper = $('full-screen-wrapper');
	var fs_title = $('full-screen-title');
	var fs_content = $('full-screen-content');

	fs_wrapper.toggle();
	
	fs_title.insert($('pageTitle'));
	fs_content.insert($('sidebar'));
	fs_content.insert($('mapwrapper'));
	fs_content.insert($('max-button'));
	fs_content.insert($('max-smallscreen-button'));
	
	//Get the viewport height:
	var view_height = document.viewport.getHeight() - 100;
	var view_width = document.viewport.getWidth();
	
	//Restyle the contents
	$('sidebar').setStyle({
	  height: view_height+'px'
	});
	
	$('mapwrapper').setStyle({
	  width: (view_width - 249) +'px',
	  height: view_height+'px'
	});


	$('smallscreen-button').setStyle({display:'inline'});
	$('fullscreen-button').setStyle({display:'none'});
	if (!$('sidebar').visible()) {
		$('max-smallscreen-button').setStyle({display:'block'});
	}
	else {
		$('max-fullscreen-button').setStyle({display:'none'});
	}
	
	map.checkResize();
	
	var iw = map.getInfoWindow();
	
	if (iw) {
		$$('.infowindow').each(function(s){ var width = (s.ancestors()[0].getWidth()-20); s.setStyle({width: width+'px', marginLeft: '0px'}); })
		$$('.infowindow-content').each(function(s){ var width = (s.ancestors()[0].getWidth()-20); s.setStyle({width: (width-10)+'px'}); })
	}
	
	fullscreen = 1;
}

/***
Show map in small screen
***/

function showSmallScreen() {
	var fs_wrapper = $('full-screen-wrapper');
	var sm_site = $('page-title-wrapper');
	var sm_column = $('GoogleMapsHolder');

	fs_wrapper.toggle();
	sm_site.insert($('pageTitle'), {position:top});
	sm_column.insert($('sidebar'));
	sm_column.insert($('mapwrapper'));
	sm_column.insert($('max-button'));
	sm_column.insert($('max-smallscreen-button'));
	
	//Restyle the contents
	$('sidebar').setStyle({
	  width: '232px',
	  height: '425px'
	});
	
	$('mapwrapper').setStyle({
	  width: '447px',
	  height: '425px'
	});

	$('smallscreen-button').setStyle({display:'none'});
	$('fullscreen-button').setStyle({display:'inline'});
	$('max-smallscreen-button').setStyle({display:'none'});
	if (!$('sidebar').visible()) {
	$('max-fullscreen-button').setStyle({display:'block'});
	}
	else {
	$('max-fullscreen-button').setStyle({display:'none'});
	}
	
	map.checkResize();
	
	var iw = map.getInfoWindow();
	
	if (iw) {
		$$('.infowindow').each(function(s){ var width = (s.ancestors()[0].getWidth()-20); s.setStyle({width: width+'px', marginLeft: '20px'}); })
		$$('.infowindow-content').each(function(s){ var width = (s.ancestors()[0].getWidth()-20); s.setStyle({width: (width-10)+'px'}); })
	}
	
	fullscreen = 0;

}