
var arrTabName = new Array("Details","Contact","Open House");

function mapProperty(tab1html, tab2html, tab3html, lat, lng, title, icon) {	
	var arrTabContent = new Array(tab1html, tab2html, tab3html);
	var point = new GLatLng(lat, lng);
	bounds.extend(point);
	markerbatch.push(createMarker(icon, point, arrTabContent, title));
}

function createMarker(myicon, point, arrTabContent, mytitle) {
	var options = { title: mytitle, icon: myicon };
	var marker = new GMarker(point, options);
	GEvent.addListener(marker, "click", function() {
		if(arrTabContent[1] == '' && arrTabContent[2] == '')
			marker.openInfoWindowHtml(arrTabContent[0]);
		else {
			var infoTabs = new Array();
			if(arrTabContent[1] != '' && arrTabContent[2] == '') {
				for(i = 0; i < 2; i++)
					infoTabs[i] = new GInfoWindowTab(arrTabName[i], arrTabContent[i]);
			}
			else if(arrTabContent[1] == '' && arrTabContent[2] != '') {
				infoTabs[0] = new GInfoWindowTab(arrTabName[0], arrTabContent[0]);
				infoTabs[1] = new GInfoWindowTab(arrTabName[2], arrTabContent[2]);
			}
			else {
				for(i = 0; i < 3; i++)
					infoTabs[i] = new GInfoWindowTab(arrTabName[i], arrTabContent[i]);
			}
			marker.openInfoWindowTabsHtml(infoTabs);
		}
	});
	return marker;
}

function AddProperty(MLNUM, MLSID, MN, idx, Lat, Lng, Address, City, Zip, PhotoPath, Price, Beds, Baths, PropType, Acres, PID, Agent, Phone, AgentPhoto, OH) {
	// Tab 1 - PROP DETAILS
	var tab1html = '';
	if(idx != "True") {
		tab1html += (OH != '') ? '<table style="width: 275px;">' : '<table>';
		tab1html += '<tr><td style="width:60px;"><img src="/images/logos/NR_110x75.jpg" height="34" width="50" border="0" /></td>' +
			'<td style="font-weight: bold; font-size: 14px;"><a href="/properties/details.asp?&MLSID=' + MLSID + '&MLNUM=' + MLNUM + '" target="_top" title="View Details">' + Address + '<br />' + City + ', NY ' + Zip + '</a></td></tr>' +
			'</table><table><tr><td><a href="/properties/details.asp?MLSID=' + MLSID + '&MLNUM=' + MLNUM + '" target="_top" title="View Details"><img src="' + PhotoPath + '" style="border:1px solid #000000; height: 75px;" /></a></td>' +
			'<td style="font-size:13px;vertical-align:top;"><div style="font-weight: bold;margin-bottom:3px;">Price: ' + Price + '</div>';
	}
	else {
		tab1html += '<table><tr><td style="font-weight: bold; font-size: 14px;" colspan="2"><a href="/properties/details.asp?MLSID=' + MLSID + '&MLNUM=' + MLNUM + '" target="_top" title="View Details">' + Address + '<br />' + City + ', NY ' + Zip + '</a></td></tr>' +
			'<tr><td><a href="/properties/details.asp?MLSID=' + MLSID + '&MLNUM=' + MLNUM + '" target="_top" title="View Details"><img src="' + PhotoPath + '" style="border:1px solid #000000; height: 75px;" /></a></td>' +
			'<td style="font-size:13px;vertical-align:top;"><div style="font-weight: bold;margin-bottom:8px;">Price: ' + Price + '</div>';	
	}

	if(PropType == "Land")
		tab1html += 'Acres: ' + Acres + '<br /></td></tr>';
	else
		tab1html += 'Beds: ' + Beds + '<br />Baths: ' + Baths + '<br /></td></tr>';
	//if(MN == "True")
	//	tab1html += '<tr><td colspan="2" style="font-size: 13px;"><a href="#">save property to MyNothnagle</a></td></tr>';
	tab1html += '</table>';
	
	// Tab 2 - AGENT INFO
	if(PID == '0')
		var tab2html = '';
	else if(PID != '') {
		var tab2html = '<table><tr><td><img src="' + AgentPhoto + '" " style="border:1px solid #000000; height: 92px;" /></td><td>';
		tab2html += '<a href="/agents/profile.asp?pid=' + PID + '" title="View Agent Profile" target="_top">' + Agent + '</a><br>';
		tab2html += Phone.replace("**","<br>") + "<br />";
		tab2html += '<a href="javascript:ContactAgent(\'' + PID + '\',\'' + MLSID + '\',\'' + MLNUM + '\')" title="Contact Agent">Email Agent</a><br>';
		tab2html += '<a href="javascript:SendTextMessage(\'' + PID + '\',\'' + MLSID + '\',\'' + MLNUM + '\')" title="Send a text message to my cell phone">Text Message Agent</a><br></td></tr></table>';
	}
	else {
		var tab2html = '<table><tr><td style="vertical-align:top;"><img src="/images/graphics/agentphoto.jpg" style="border:1px solid #333333;"></td>';
		tab2html += '<td style="vertical-align:top;" nowrap><a href="javascript:GetPropInfo(\'' + MLSID + '\',\'' + MLNUM + '\')">Get More Information</a><br />';
		tab2html += '1-866-295-MOVE<br /></td></tr></table>';
	}	
		
	// Tab 3 - OPEN HOUSE
	if(OH != '')
		tab3html = OH + '<br />';
	else
		tab3html = '';
	if(OH != '')
		PropIcon = icon_OH;
	else
		PropIcon = (idx != "True") ? icon_Noth : icon_IDX;
	mapProperty(tab1html, tab2html, tab3html, Lat, Lng, Address + ' ' + Price, PropIcon) 		
}
