function CMapPoint(category, xmlNode)
{
	//private member variables
	var m_category = category;
	var m_id = null;
	var m_name = null;
	var m_alt_name = null;
	var m_abbv = null;
	var m_number = -1;
	var m_latitude = -1;
	var m_longitude = -1;
	var m_type1 = null;
	var m_type2 = null;
	var m_type3 = null;
	var m_title_link = null;
	var m_image_name = null;
	var m_keywords = null;
	var m_description = null;
	var m_address = null;
	var m_general_info = null;	//html for m_general_info (which is  just the general tab
	var m_photo_info = null;	//html for the photo tab
	var m_maxWindowWidth = 200;
	
	//public member variables
	this.is_visible = false;
	
	//public member functions
	this.getMarker = getMarker;
	this.compareTo = compareTo;
	this.matchOn = matchOn;
	this.getLatLng = getLatLng;
	this.getInfoTabs = getInfoTabs;
	this.getGeneralInfo = getGeneralInfo;
	this.compareToID = compareToID;
	this.compareToTypes = compareToTypes;
	this.compareToIdOrAbbv = compareToIdOrAbbv;
	this.getCategory = getCategory;
	
	//GMap stuff
	var m_infoTabs = null;	//info tab information for the html
	var m_icon = null;
	var m_marker = null;
	
	//initialize the information
	initNode(xmlNode);
	
	/*
	Function: initNode
	Purpose: construct the a mappoint based off an ItemList xml node
	*/
	function initNode(){
		try{
			if (xmlNode.getElementsByTagName("ID")[0].hasChildNodes()){
				m_id = 
					xmlNode.getElementsByTagName("ID")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("Name")[0].hasChildNodes()){
				m_name = 
					xmlNode.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("Alt_Name")[0].hasChildNodes()){
				m_alt_name = 
					xmlNode.getElementsByTagName("Alt_Name")[0].childNodes[0].nodeValue;
			}
		}catch(err){}	
		try{	//not all the xml files have abbreviations
			if (xmlNode.getElementsByTagName("Abbv")[0].hasChildNodes()){
				m_abbv =
					xmlNode.getElementsByTagName("Abbv")[0].childNodes[0].nodeValue;
			}
		}catch(error){}
		try{
			if (xmlNode.getElementsByTagName("Number")[0].hasChildNodes()){
				m_number =
					xmlNode.getElementsByTagName("Number")[0].childNodes[0].nodeValue;
			}
		}catch(error){}
		try{
			if (xmlNode.getElementsByTagName("Address")[0].hasChildNodes()){
				m_address = 
					xmlNode.getElementsByTagName("Address")[0].childNodes[0].nodeValue;
			}
		}catch(error){}
		
		try{
			if (xmlNode.getElementsByTagName("GeoLat")[0].hasChildNodes()){
				m_latitude = 
					xmlNode.getElementsByTagName("GeoLat")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("GeoLong")[0].hasChildNodes()){
				m_longitude = 
					xmlNode.getElementsByTagName("GeoLong")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		/*
		try{
			if (xmlNode.getElementsByTagName("Type_1")[0].hasChildNodes()){
				m_type1 = 
					xmlNode.getElementsByTagName("Type_1")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		*/
		try{
			if (xmlNode.getElementsByTagName("Type_1")[0].hasChildNodes()){
				m_type1 = 
					xmlNode.getElementsByTagName("Type_1")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
		if (xmlNode.getElementsByTagName("Type_2")[0].hasChildNodes()){
				m_type2 = 
					xmlNode.getElementsByTagName("Type_2")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("Type_3")[0].hasChildNodes()){
				m_type3 = 
					xmlNode.getElementsByTagName("Type_3")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
		if (xmlNode.getElementsByTagName("Title_Link")[0].hasChildNodes()){
				m_title_link = 
					xmlNode.getElementsByTagName("Title_Link")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		
		try{
			if (xmlNode.getElementsByTagName("Image")[0].hasChildNodes()){
				m_image_name = 
					xmlNode.getElementsByTagName("Image")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("Keywords")[0].hasChildNodes()){
				m_keywords = 
					xmlNode.getElementsByTagName("Keywords")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		try{
			if (xmlNode.getElementsByTagName("Description")[0].hasChildNodes()){
				m_description = 
					xmlNode.getElementsByTagName("Description")[0].childNodes[0].nodeValue;
			}
		}catch(err){}
		
		//create the marker
		createGeneralInfo();
		createPhotoInfo();
		createIcon();
		createInfoTabs();
		createMarker();
	}; //end init
	
	function getMarker()
	{
		return m_marker;
	}
	
	function getLatLng()
	{
		return new GLatLng(parseFloat(m_latitude), parseFloat(m_longitude));	
	}
	
	function getInfoTabs()
	{
		return m_infoTabs;
	}
	
	function getGeneralInfo()
	{
		return m_general_info;
	}
	
	function getCategory()
	{
		return m_category;
	}
	
	/*
	Function: createMarker
	Purpose: create a marker based on the latitude, longitude, icon; then add a click listener
	*/
	function createMarker()
	{
		var point = new GLatLng(parseFloat(m_latitude), 
			parseFloat(m_longitude));		
		m_marker = new GMarker(point, m_icon);
		
		/*
		//add an event listener that opens up the infowindow
		GEvent.addListener(m_marker, "click", function() {
			//determine if infoTabs are needed
			if (m_infoTabs != null){
				m_marker.openInfoWindowTabsHtml(m_infoTabs, 
					{maxWidth:m_maxWindowWidth});
			}
			else{
				m_marker.openInfoWindowHtml(m_general_info,
					{maxWidth:m_maxWindowWidth});
			}
		});
		*/

		GEvent.addListener(m_marker, "click", function() {
			//determine if infoTabs are needed
			if (m_infoTabs != null){
				m_marker.openInfoWindowTabsHtml(m_infoTabs, {maxWidth:m_maxWindowWidth});
			}
			else{
				m_marker.openInfoWindowHtml(m_general_info, {maxWidth:m_maxWindowWidth});
			}
		});
		
		//changes the page title when clicked
		GEvent.addListener(m_marker, "infowindowopen", function() {
			var title = "";
			if (m_name != null)
				title = m_name;
			else if (m_alt_name != null)
				title = m_alt_name;
			else if (m_number != -1)
				title = m_number;
			title += " on the MSU Interactive Campus Map";
			document.title = title;
		});
		GEvent.addListener(m_marker, "infowindowclose", function() { 
			document.title= "Interactive Campus Map - Michigan State University"; 
		});
	};	//end createMarker
	
	/*
	Function: createIcon
	Purpose: create an icon based off the type
	*/
	function createIcon()
	{
		m_icon = new GIcon();
		if (m_category == "buildings")
		{
			 //added by wso 2-13-09
			if (m_type2 == "Residence Hall"){
				m_icon.image = "_images/markers/rh_yellow_na.png";
			}
			//added by wso 2-13-09
			else if (m_type2 == "Apartment"){
				m_icon.image = "_images/markers/ua_yellow_na.png";
			}
			else{ 
				m_icon.image = "_images/markers/red.png";
			}
		}
		else if (m_category == "destinations"){ 
			m_icon.image = "_images/markers/red.png";
		}
		
		else if (m_category == "construction"){ 
			m_icon.image = "_images/markers/construction_icon.png";
		}
	
		else if (m_category == "nature"){ 
			m_icon.image = "_images/markers/nature.png"; 
		}
		
		else if (m_category == "parking"){
			// added by mdm
			if (m_type1 == "Residential"){ 
				m_icon.image = "_images/markers/residential_parking.gif"
			} 
			else if (m_type1 == "Employee"){
				m_icon.image = "_images/markers/employee_parking.gif";
			}
			else{
				m_icon.image = "_images/markers/visitor_parking.png";
			}
		}
		else{
			m_icon.image = "_images/markers/yellow.png"; 
		}
	
		m_icon.iconSize = new GSize(32, 32);
		m_icon.iconAnchor = new GPoint(16, 32);
		m_icon.infoWindowAnchor = new GPoint(5, 1);
	}
	
	/*
	Function: createInfoTabs
	Purpose: creates the General and Photo info tabs
	*/
	function createInfoTabs()
	{
		if (m_image_name != null)
		{
			m_infoTabs = [
				new GInfoWindowTab("General", m_general_info),
				new GInfoWindowTab("Photo", m_photo_info)
			];	
		}
	}
	
	/*
	Function: createGeneralInfo
	Purpose: creates the General information
	*/
	function createGeneralInfo()
	{
		m_general_info = 
			'<div class=\"infoWindow\" style=\"width:220px\">';
			if (m_title_link != null){
				m_general_info += '<h1><a href="http://' + m_title_link + 
					'" target="_blank">' + 
					m_name + '<img src="_images/popup.gif" ' + 
					'alt="Open link in new window" />'
					+'</a></h1>';
			}
			else if (m_name != null)
			{
				m_general_info += "<h1>" + m_name + "</h1>";
			}
			else 
			{
				m_general_info +=  "<h1>" + m_number + "</h1>";
			}
			
			if (m_alt_name != null)
			{
				m_general_info += "<p><em>" + m_alt_name + "</em></p>";	
			}
			
			//check that it has a type, thus a bullet to put in the info window
			if ((m_type1 != null) || (m_type1 != null) || (m_type3 != null))
			{
				m_general_info += '<ul>'; 
				if (m_type1 != null){
					m_general_info += '<li>' + m_type1 + '</li>';
				}
				if (m_type2 != null){
					m_general_info += '<li>' + m_type2 + '</li>';
				}
				if (m_type3 != null){
					m_general_info += '<li>' + m_type3 + '</li>';
				}
				m_general_info += '</ul>';
			}
			
			if (m_number != -1){
				m_general_info += '<p id="buildingNumber">Building Number: ' + 
					m_number + '</p>';
			}
			if (m_abbv != null){
				m_general_info += '<p id="Abbreviation">Abbreviation: ' + m_abbv + '</p>';
			}
			if (m_description != null){
				m_general_info += '<p id="description">' + m_description + '</p>';
			}
			
			if (m_abbv != null)
			{
				m_general_info += '<p><a href=\"index.php?location=' + 
					m_abbv.toLowerCase() 
					+ '\">' +
					'Create link to this location</a></p>';	
			}
			else
			{
				m_general_info += '<p><a href=\"index.php?location=' + 
					m_id + '\">' +
					'Create link to this location</a></p>';
			}
			m_general_info += '</div>';
	}
	
	/*
	Function: createPhotoInfo
	Purpose: creates the photo information that is displayed in the tabs
	*/
	function createPhotoInfo()
	{
		m_photo_info = '<div class="infoWindow2">';
			if (m_image_name != null)
			{
				m_photo_info +=
				'<p><a href="' + building_path + m_image_name + '.jpg" target="_blank">' +
				'<img src="' + building_path  + m_image_name + '_thumb.jpg"' +
					'wm_idth="180" height="120"/>' +
				'</a>' + 
				'</p>' +
				'<p class="viewLink">' + 
				'<a href="' + building_path + m_image_name + '.jpg" target="_blank">' +
				'View larger</a>' + 
				'</p>';
			}
			else
			{
				m_photo_info +=
					"<p class='noPicture'>No photo is<br />currently available</p>";
			}
			m_photo_info += '</div>';	
	}
	
	/*
	Function: compareToID
	Purpose: compare to see if the IDs match
	*/
	function compareToID(searchTerm)
	{
		if (m_id != null){
			if (m_id == searchTerm)
				return true;
		}
		return false;
	}
	
	/*
	Function: compareTo
	Purpose: compare to see if the name, alternate name, or abbreviation match
	*/
	function compareTo(searchTerm)
	{
		if (m_name != null){
			if (m_name == searchTerm)
				return true;
		}
		if (m_alt_name != null){
			if (m_alt_name == searchTerm)
				return true;
		}
		if (m_abbv != null){
			if (m_abbv == searchTerm)
				return true;
		}
		return false;
	}
	
	/*
	Function: compareToIdOrAbbv
	Purpose: comapre to see if the id or abbreviation match
	*/
	function compareToIdOrAbbv(searchTerm)
	{
		if ((m_abbv == searchTerm) || (m_id == searchTerm))
			return true;
		else
			return false;
	}
	
	/*
	Function: compareToTypes
	Purpose: compare to see if the types match
	*/
	function compareToTypes(searchTerm)
	{
		if (( m_type1 == searchTerm) ||( m_type2 == searchTerm) ||( m_type3 == searchTerm))
			return true;
		else
			return false;
	}
	
	/*
	Function: matchOn
	Purpose: do a regexpr match on the search pattern
	*/
	function matchOn(searchPattern)
	{
		if (m_name != null){
			if (m_name.match(searchPattern) != null)
				return true;
		}
		if (m_alt_name != null){
			if ( m_alt_name.match(searchPattern) != null)
				return true;
		}
		if (m_abbv != null){
			if ( m_abbv.match(searchPattern) != null)
				return true;
		}
		return false;
	}
}

