// /js/isol/isol.gmap.8.js// global functions

function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1) return element;
    elements.push(element);
  }
  return elements;
}

// ISOL Javascript Loader

var isol = {

	site: {

		root: '/',

		admin_root: function() {
			return this.root+'zAz/'
		},

		editkey: 'dskgjw43tjsejLv43dsmv4mf0wmw346346'
	},	

	// append script to html head, now or onload
	loadScript: function(url,delayed) {

		var delayed = delayed || false;

		if (delayed) {
			this.addEvent('load',
				function () {
					isol.loadScript(url);
				}
			);
		} else {
			var script = document.createElement("script");  
			script.src = url;
			script.type = "text/javascript";
			document.getElementsByTagName('head')[0].appendChild(script);
		}		
	},

	// load known isol module, now or onload
	loadModule: function(module,delayed) {

		var delayed = delayed || false;

		if (typeof this[module] == 'undefined')	{
			this[module] = {};
		}
		if (typeof this[module].loaded == 'undefined') {
			this[module].loaded = true;
			this.loadScript(this.site.root+'js/isol/isol.'+module+'.js',delayed);
		}			
	},

	// add event function to element
	addEvent: function(evt,fn,elm) {

		elm = $(elm) || window;

        if (elm.addEventListener) {
                elm.addEventListener(evt, fn, false);
		} else if (elm.attachEvent) {
		    elm.attachEvent('on' + evt,
				function() {
					return fn.call(elm,window.event);
				}
			);
		}
	},

	windows: {}
};

// windows object

// open windows with opener and focus
isol.windows.open = function(url,windowname,settings) {

	popupWin = window.open(url,windowname,settings);
	if (!popupWin.opener) {
		popupWin.opener=self;
		popupWin.focus();
	}
}

if (typeof isol['gmap'] == 'undefined')	{
	isol['gmap'] = {};
}
isol['gmap'].loaded = true;

isol.gmap = {

	gkey: 'ABQIAAAAWwV82y6hqF_hWvs7RSovghT3-9iPpUQ4dLgAjDUuwg3CCSkjUxS6qALtWV4Kc6FovlekBZT48oNW2w',

	maps: [],

	load: function() {
		isol.loadScript('http://www.google.com/jsapi?key='+isol.gmap.gkey+'&callback=isol.gmap.loadGmaps');
	},

	loadGmaps: function() {
		google.load("maps", "2", {"callback" : isol.gmap.isLoaded});
	},

	isLoaded: function() {
		isol.addEvent('unload',google.maps.Unload);
		isol.gmap.init();
	},

	add: function(gmap,callback) {
		gmap.callback = callback;
		isol.gmap.maps.push(gmap);
	},

	init: function() {
		if (typeof isol.gmap.maps != 'undefined') {
			for (var i = 0; i < isol.gmap.maps.length; i++) {
				isol.gmap.draw(isol.gmap.maps[i]);
			}
		}		
	},

	draw: function(gmap) {

		if (GBrowserIsCompatible()) {

			var map = new google.maps.Map2($(gmap.el));
			map.setCenter(new google.maps.LatLng(gmap.clt,gmap.clg),gmap.z);
			map.setMapType(G_NORMAL_MAP);
			map.setUIToDefault();
			
			// create icons
			if (typeof gmap.icons != undefined) {			
				var icons = {};
				var baseIcon = new google.maps.Icon(G_DEFAULT_ICON);
				baseIcon.iconSize = new google.maps.Size(gmap.icons.w,gmap.icons.h);
				baseIcon.shadowSize = new google.maps.Size(gmap.icons.sw,gmap.icons.sh);
				baseIcon.iconAnchor = new google.maps.Point(gmap.icons.px,gmap.icons.py);

				if ((typeof gmap.icons.ids != undefined) && gmap.icons.ids.length) {
					var ilist = gmap.icons.ids;
					var icount = gmap.icons.ids.length;
					for (i=0; i<icount; i++) {
						icons[ilist[i]] = new google.maps.Icon(baseIcon);
						icons[ilist[i]].image = gmap.icons.base+ilist[i]+'.png';
						icons[ilist[i]].mozPrintImage = gmap.icons.base+ilist[i]+'.gif';
					}
				}
			}		
		
			// add items
			if (typeof gmap.items != 'undefined') {

				var item_count = gmap.items.length;

				if (item_count > 1)	{
					var bounds = new google.maps.LatLngBounds();
				}

				var item_count = gmap.items.length;
				if (item_count) {
					for (var i = 0; i < item_count; i++) {

						// get icon
						if (typeof gmap.items[i].icon != undefined) {
							var map_icon = icons[gmap.items[i].icon];
						} else {
							var map_icon = null;
						}

						// define marker
						var latlng = new google.maps.LatLng(gmap.items[i].clt,gmap.items[i].clg);
						var marker = new google.maps.Marker(latlng,{icon:map_icon,title:gmap.items[i].title});

						// add to bounds if set
						if (bounds && gmap.items[i].ob!=1) {
							bounds.extend(latlng);
						}

						// add link
						marker.clink = gmap.items[i].url;
						
						// add marker
						map.addOverlay(marker);

						// info window HTML
						var HTML = gmap.items[i].HTML;
						if (HTML) {
							marker.openInfoWindowHtml(HTML);
						}					
					}

					// center single item
					if (item_count == 1) {
						map.setCenter(latlng,11);
						
					// or zoom to bounds
					} else if (bounds) {
						map.setCenter(bounds.getCenter());
						map.setZoom(map.getBoundsZoomLevel(bounds));
					}
				}			
			}

			// add click link
			map.clink = gmap.url;
			
			// click events
			google.maps.Event.addListener(map,'click',function(overlay)	{
				// marker link
				if (overlay != undefined) {
					if (overlay.hasOwnProperty('clink')) {
						window.location.href = overlay.clink;
					}				
				// map link
				} else if (this.clink) {
					window.location.href = this.clink;
				}
			});

			// callback function
			if (typeof gmap.callback == 'function') {
				gmap.callback(map,icons);
			}
		}
	} 
}

isol.gmap.load();
// WLTN property search

// apartments is checked
function checkApts() {
	if (document.psearch.elements['s_category[5]'].checked) {
		document.psearch.elements['s_category[15]'].checked = false;
		document.psearch.elements['s_category[8]'].checked = false;
		document.psearch.elements['s_category[6]'].checked = false;
		document.psearch.elements['s_category[16]'].checked = false;
		document.psearch.elements['s_category[9]'].checked = false;
		document.psearch.s_avail[0].checked = true;
		document.all('slabel').innerText='Bedrms';
	} else {
		document.all('slabel').innerText='Sq.Ft.';
	}			
}
// land is checked
function checkLand() {
	if (document.psearch.elements['s_category[9]'].checked) {
		document.psearch.elements['s_category[15]'].checked = false;
		document.psearch.elements['s_category[8]'].checked = false;
		document.psearch.elements['s_category[6]'].checked = false;
		document.psearch.elements['s_category[16]'].checked = false;
		document.psearch.elements['s_category[5]'].checked = false;
		document.all('slabel').innerText='Acres';
	}	else {
		document.all('slabel').innerText='Sq.Ft.';
	}		
}
// other is checked
function checkOther(thisCheckbox) {
	if (thisCheckbox.checked) {
		document.psearch.elements['s_category[5]'].checked = false;
		document.psearch.elements['s_category[9]'].checked = false;
		document.all('slabel').innerText='Sq.Ft.';
	}			
}

// WLTN custom flash code

// sned mouseover action to flash site plan
function space_hover(spaceid,tr) {
	window.document.ISOL_Flash.SetVariable('/ext_hover.hover_id', spaceid); 
	window.document.ISOL_Flash.TCallFrame( '/ext_hover', 1);
	prev_color=tr.bgColor;
	tr.bgColor='#aaddaa';
}
// sned mouseout action to flash site plan
function space_dehover(spaceid,tr) {
	window.document.ISOL_Flash.SetVariable('/ext_dehover.hover_id', spaceid); 
	window.document.ISOL_Flash.TCallFrame( '/ext_dehover', 1);
	tr.bgColor=prev_color;
}