/* ---------------------------------
  @ Google Map Controller
----------------------------------- */
function googleMapViewer() { this.init() }

googleMapViewer.prototype = {

	init : function()
	{
		// main elem
		this.map = $("#map");
		
		// set defaults
		this.interval = 100;
		this.minHeight = this.map.height() - (this.interval * 2);
		this.maxHeight = this.map.height() + (this.interval * 2);
		
		// set root element
		var self = this;
		$('div.mapcontrols')
			.find('div.expand a')
				.click( function() {
					self.expand();
				})
			.end()
			.find('div.contract a')
				.click( function() {
					self.contract();
				})
	},
	
	expand : function()
	{
		// always enable the contract button
		this.enableContract();
		
		var h = this.map.height();
		if (h <= (this.maxHeight-this.interval)) {
			
			// animate it
			var newH = h + this.interval;
			this.map.animate({ height: newH }, "normal");
			
			// if the newH is equal to the maxHeight, fade out the expand button, else fade it in
			if (newH == this.maxHeight) {
				this.disableExpand();
			};
			
		};
	},
	disableExpand : function() { $('div.mapcontrols div.expand').addClass('disabled').fadeTo("normal", 0.3) },
	enableExpand : function() { $('div.mapcontrols div.expand').removeClass('disabled').fadeTo("normal", 1) },
	
	
	contract : function()
	{
		// always enable the expand button
		this.enableExpand();
		
		var h = this.map.height();
		if (h >= (this.minHeight+this.interval)) {
			
			// animate it
			var newH = h - this.interval;
			this.map.animate({ height: newH }, "normal");
			
			// if the newH is equal to the maxHeight, fade out the expand button, else fade it in
			if (newH == this.minHeight) {
				this.disableContract();
			};
			
		};
	},
	disableContract : function() { $('div.mapcontrols div.contract').addClass('disabled').fadeTo("normal", 0.3) },
	enableContract : function() { $('div.mapcontrols div.contract').removeClass('disabled').fadeTo("normal", 1) }
	
};