﻿

/* map */
var Map = new function() {

	this.Toggle = function(iVacancyID, sPostcode) {
		var oCell = f.GetObject('divMap_' + iVacancyID);

		if (!f.GetObject('imgMap_' + iVacancyID)) {

			//work out url
			var sURL = 'http://maps.google.com/maps/api/staticmap?center=[postcode],uk&zoom=12&size=530x250&maptype=roadmap&sensor=false&key=[mapskey]';
			sURL = s.Replace(sURL, '[postcode]', s.Replace(sPostcode, ' ', '+'));
			sURL = s.Replace(sURL, '[mapskey]', f.GetValue('hidGoogleAPIKey'));

			//create map image
			var oImage = document.createElement('img');
			oImage.setAttribute('src', sURL);
			oImage.setAttribute('id', 'imgMap_' + iVacancyID);
			oImage.setAttribute('class', 'map');
			oCell.appendChild(oImage);


			//create pointer
			oImage = document.createElement('img');
			oImage.setAttribute('src', '/images/point.png');
			oImage.setAttribute('id', 'imgPoint_' + iVacancyID);
			oImage.setAttribute('class', 'point');
			oCell.appendChild(oImage);


			f.AddClass('aM_' + iVacancyID, 'show');
		} else {
			oCell.removeChild(f.GetObject('imgMap_' + iVacancyID));
			oCell.removeChild(f.GetObject('imgPoint_' + iVacancyID));
			f.RemoveClass('aM_' + iVacancyID, 'show');
		}
	}

}


