﻿/// <reference name="MicrosoftAjax.debug.js" />

Type.registerNamespace("CoasterBuzz");

CoasterBuzz.ParkMap = function() {
	CoasterBuzz.ParkMap.initializeBase(this);
	this._expander = null;
	this._trigger = null;
	this._mapDiv = null;
	this._cssHeightSelector = null;
	this._location = null;
}

CoasterBuzz.ParkMap.prototype = {
	initialize: function() {
		CoasterBuzz.ParkMap.callBaseMethod(this, "initialize");
		this._expander = new PopForums.UI.ExpandContract(this.get_MapDiv().id, this.get_CssHeightSelector());
		this._expander.add_expandComplete(Function.createDelegate(this, this._expandComplete));
		this._expander.add_shrinkComplete(Function.createDelegate(this, this._shrinkComplete));
		$addHandlers(this.get_Trigger(), { "click":this._executeMotion }, this);
	},
	
	_executeMotion : function() {
		this._expander.executeExpandContract();
	},
	
	_expandComplete : function() {
		var map = new VEMap(this.get_MapDiv().id);
		map.LoadMap();
		try {
			map.Find(null, this.get_Location());
		}
		catch (e) {
			alert(e.message);
		}
		map.SetMapStyle(VEMapStyle.Hybrid);
		this.get_Trigger().innerHTML = "Hide map";
	},
	
	_shrinkComplete : function() {
		this.get_Trigger().innerHTML = "Open overhead map of park";
	},
	
	get_Trigger : function() {
		return this._trigger;
	},
	
	set_Trigger : function(value) {
		this._trigger = value;
	},
	
	get_MapDiv : function() {
		return this._mapDiv;
	},
	
	set_MapDiv : function(value) {
		this._mapDiv = value;
	},
	
	get_CssHeightSelector : function() {
		return this._cssHeightSelector;
	},
	
	set_CssHeightSelector : function(value) {
		this._cssHeightSelector = value;
	},
	
	get_Location : function() {
		return this._location;
	},
	
	set_Location : function(value) {
		this._location = value;
	},

	dispose : function() {
		CoasterBuzz.ParkMap.callBaseMethod(this, "dispose");
	}
}

CoasterBuzz.ParkMap.registerClass("CoasterBuzz.ParkMap", Sys.Component);