// T324 Scripts (version 1.01)
// 07.15.2005

// Copyright Date Script
function copyrightdate(start_year)
/* comment within a script */
{
var d=new Date();
yr=d.getFullYear();
if (yr!=start_year) {
return(start_year+"-"+yr);  }
if (yr==start_year) {
return(start_year);  }
}
			  
// NoSpamEmail Script
function nospam(domain,name,visible){
/* comment within a script */
document.write('<a href=\"mail'+'to:' + name + '@' + domain + '\">');
document.write(visible+ '</a>');
}
//Example: nospam("casamina-santabarbara.com","info","Click here to get more information") 

// NoSpamEmail Script 2
function nospam2(domain,name,tld){
document.write('<a href=\"mail'+'to:' + name + '@' + domain + '.' + tld + '\">');
document.write(name + '@' + domain + '.' + tld + '</a>');
}
//Example: nospam2("casamina-santabarbara,"info","com") 

// Requires MacroMedia Flash Script
function getflash(message){
document.write('<p align="left"><a href="http://www.macromedia.com/go/getflashplayer/" target="_blank"><img src="/resources/Master_Images/get_flash_player.gif" alt="Get Macromedia Flash Player" hspace="5" border="0" align="right" /></a>' + message + '</p>');
}
//Example: getflash("Get Flash player for FREE!")

// PDF
function pdfer(name,title,size){
document.write('<table width="500" border="0" cellspacing="0" cellpadding="0" align="left"><tr align="left" valign="top"><td width="13" valign="middle"><img src="/resources/Master_Images/icon_pdf.gif" alt="PDF" width="36" height="36" border="0"></a></td><td width="10">&nbsp;</td><td width="439" valign="middle"><p><a href="' + name + '">' + title + '</a>(' + size + 'K)</p></td></tr></table>');
}

//Example: 
//pdf("/main/documents/aerialmap.pdf")

/**
* googleMap uses the Google Maps API to draw a map centered on a given point with an
* optional location marker.  The marker can have an optional popup message balloon when
* clicked on that can contain the location's address and/or a special messge.
*
* Version  : 1.0
* Created  : 07.14.2005
* Modified : 07.15.2005
*
* @param mapElement		the value of the id attribute of the target DIV element
* @param width        	the width of the map including units (ex. '12em')
* @param height       	the height of the map including units (ex. '400px')
* @param latitude     	latitude of the center point of the map
* @param longitude    	longitude of the center point of the map
* @param street       	the street portion of the address
* @param city         	the city portion of the address
* @param state        	the state portion of the address
* @param zip          	the zipcode portion of the address
* @param showControls 	show Google Map controls [true|false]
* @param showMarker     show marker at center point of map [true|false]
* @param smallMarker    use small marker [true|false]
* @param markerColor    color of the marker; Color choices include "red," "orange," 
* 						"yellow," "green," "blue," "purple," "black," & "white"
* @param showBalloon    show a popup message balloon when the marker is clicked [true|false]
* @param balloonMsg     optional messge for the popup balloon
* @param balloonStyle   optional CSS font style for the popup balloon
* 						defaults to 'font: 13px Tahoma, Arial, sans-serif'
* 						Note: do NOT include a trailing semi-colon (;)!
*
* @return true on success, false on failure
*
* Example:
* 
* googleMap(
*	'map',
*	'400px',
*	'400px',
*	37.789128,
*	-122.401982,
*	'1 Post',
*	'San Francisco',
*	'CA',
*	'94104',
*	true,
*	true,
*	false,
*	'red',
*	true,
*	'McKesson Corp.',
*	''
* );
*/

function googleMap(mapElement, width, height, latitude, longitude, street, city, state, zip, showControls, showMarker, smallMarker, markerColor, showBalloon, balloonMsg, balloonStyle) {
	var _googleMap = {

		createIcon: function () {
			// Create a small marker icon
			var icon = new GIcon();
			// Color choices include "red," "orange," "yellow," "green," "blue," "purple," "black," & "white"
			icon.image = "http://labs.google.com/ridefinder/images/mm_20_"+ this.markerColor+".png";
			icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			icon.iconSize = new GSize(12, 20);
			icon.shadowSize = new GSize(22, 20);
			icon.iconAnchor = new GPoint(6, 20);
			icon.infoWindowAnchor = new GPoint(5, 1);
			return icon;
		},
	
		createBalloonText: function () {
			// Display the address if given, and/or an additional message if given
			var address = '<p style="' + this.balloonStyle + '">' + this.street + '<br/>' + this.city + ', ' + this.state + ' ' + this.zip + '</p>';
			address = (this.city) ? '<h3 style="margin-top: 0; ' + this.balloonStyle + '; font-size: 16px; font-weight: bold;">Address:</h3>' + address : '';
			address = (this.balloonMsg) ? address + '<p style="' + this.balloonStyle + '">' + this.balloonMsg + '</p>' : address;
			return  address;
		},
		
		createMarker: function () {
			// Create a marker and its optional message balloon
			var _marker = (this.smallMarker) ? new GMarker(this.centerPoint, this.createIcon()) : new GMarker(this.centerPoint);
			if (this.showBalloon) {
				var self = this;
				GEvent.addListener(_marker, "click", function() { _marker.openInfoWindowHtml(self.createBalloonText()); });
			}
			return _marker;
		},
		
		drawMap: function (mapElement, width, height, latitude, longitude, street, city, state, zip, showControls, showMarker, smallMarker, markerColor, showBalloon, balloonMsg, balloonStyle) {
			this.street = street;
			this.city   = city;
			this.state  = state;
			this.zip    = zip;
			this.smallMarker  = smallMarker;
			this.markerColor  = markerColor;
			this.showBalloon  = showBalloon;
			this.balloonMsg   = balloonMsg;
			this.balloonStyle = balloonStyle || 'font: 13px Tahoma, Arial, sans-serif';
			
			var el = document.getElementById(mapElement);
			
			el.style.width  = width;
			el.style.height = height;			
			el.style.border = '1px solid #666';
			
			var map = new GMap(el);
			
			if (showControls) {
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
			}
			this.centerPoint = new GPoint(longitude, latitude);
			map.centerAndZoom(this.centerPoint, 4);
			if (showMarker) {
				map.addOverlay(this.createMarker());
			}
		}
	};
	
	if (GBrowserIsCompatible()) {
		_googleMap.drawMap(mapElement, width, height, latitude, longitude, street, city, state, zip, showControls, showMarker, smallMarker, markerColor, showBalloon, balloonMsg, balloonStyle);
		return true;
	}
	return false;
}