//<![CDATA[
   	if (GBrowserIsCompatible()) {

		var sidebar_html	= "";
		var gmarkers		= [];
		var htmls			= [];
		var Buyer_Form		= [];
		var Phone_No		= [];
		var CMA_Form		= [];
		var IMVOIP			= [];
		var i				= 0;
		var AgentDisplayName= "";
		
		var clicktypecityballoon3	= 9;
		var clicktypemapballoon3	= 10;
		var clicktypemapballoon1	= 11;
		var clicktypecityballoon1	= 12;				
		var clicktypeaboutme		= 14;
		var clicktypeofferview		= 15;
		var clicktypeneighbourhood	= 16;
		var clicktypecontactme		= 17;
		var clicktypeemailafriend	= 18;
		var increment				= 1;
		
		// create the map
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());

		map.setCenter(new GLatLng(42.4419, -96.1419), 4); //SHOWS US and canada 
		
		//added on 9/29/2006 - zooming based on dbl click on the map
		map.enableDoubleClickZoom();
		map.getPane(G_MAP_FLOAT_SHADOW_PANE).style.visibility="hidden";
		
		if (document.ddform.hiddummy.value != "1"){
			GEvent.addDomListener(map, "click",
				function(overlay, point) {
					if (point) {
						var latLngStr6 = point.y.toFixed(6) + ', ' + point.x.toFixed(6);
						document.getElementById("ddform").hiddummy.value = 1 ;
						document.getElementById("ddform").varLat.value = point.y.toFixed(0); 
						document.getElementById("ddform").varLong.value = point.x.toFixed(0);
						document.getElementById("ddform").submit(); 
					}
			});
		}
		
	//	window.setTimeout(function() {
    //    map.panTo(new GLatLng(37.4569, -122.1569));
    //    }, 4000);
    

        
		// ====== 01/17/2007 set up marker mouseover tooltip div ======
		var tooltip = document.createElement("div");
		document.getElementById("map").appendChild(tooltip);
		tooltip.style.visibility="hidden";

		//added on 10/3/2006 - show the initial default text on right hand side bar
		var defaultText = "<span class=sContent><B>Benefits of using e-Agent:</B><BR><BR>";
		defaultText = defaultText + "1. All Real Estate e-Agents will give you free access to school and neighborhood information.<BR><BR>";
		defaultText = defaultText + "2. Contact any of the e-Agents in whatever way they allow you to contact them (Call them Direct, Email, or even IM them).<BR><BR>";
		defaultText = defaultText + "3. Feel Safe - Your information is only given to the e-Agent(s) you choose and there is never a commitment.</span><BR><BR>";
		
		document.getElementById("sidebar").innerHTML = defaultText;
		
		// Create our "tiny" marker blue color icon
		var icon = new GIcon();
		icon.iconAnchor = new GPoint(10, 20);
		icon.infoWindowAnchor = new GPoint(5, 2);
		
		// A function to create the marker and set up the event window
		function createMarker(point,name,html,userName,AgentPhoto,AgentCompanyPhoto,VSPhoneNo,TerritoryID,AgentID,MarketType,systemversion,agentDisplayName,MLSLink,CompanyWebsite,EmailAddress,FaxNumber,PhoneNumber,IMID,IMType,AddressLine1,AddressLine2,OfferStatement,AboutMe,Town,StateAbbr,StateID) {
		
		
			//fixing image problem of Armando Macias Jr. and Deborah Vanden Heuvel - 02/22/2007
			//fixing image problem of Al Mac Donald - 05/02/2007
			if ((AgentID == 14707) || (AgentID == 20508) || (AgentID == 22329)){
				userName = checkdot(userName);
				userName = repNUll(userName);
			}	
				
			//10-20-2006 showing bigger balloon for territory Boynton Beach, FL as per Lowell's request.
			//01-25-2007 showing bigger ballon for territory Birmingham, AL as per Lowell's request.(Issue#410)
			if ((MarketType == "7") || (MarketType == "2") || (TerritoryID == "20699") || (TerritoryID == "21043")){
				icon.image = "http://www.google.com/mapfiles/marker.png";
				icon.iconSize = new GSize(20, 30);
				var marker = new GMarker(point,icon);
			}	
			else{
				icon.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
				icon.iconSize = new GSize(15, 20);
				var marker = new GMarker(point,icon);
			}	
			
			if (AgentID == "16085"){
				//alert(EmailAddress);
			}
			
			AgentPhoto		= ReplaceCarat(repNUll(leftTrim(AgentPhoto)));
			AboutMe			= ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(AboutMe));
			agentDisplayName= ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(leftTrim(agentDisplayName))); //02/05/2008
			EmailAddress	= Replacespace(ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(EmailAddress))); //02/05/2008
			AddressLine1	= ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(AddressLine1)); //02/05/2008
			AddressLine2	= ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(AddressLine2)); //02/05/2008
			name			= ReplaceCarat(name); //02/06/2008
			Town			= ReplaceCarat(Town); //02/06/2008
			
			// === 01/17/2007 store the name so that the tooltip function can use it ===
			marker.tooltip =  '<div class="tooltip1">'+name+'</div>';			
			
			if (AgentID == "16085"){
				//alert(EmailAddress);
			}
			
			if (OfferStatement != "")
				OfferStatement = (ReplaceCarat(ReplaceGlobalSingleCaretToSingleQuote(OfferStatement)));

	        if (AgentPhoto != "NoPhoto.gif")
				userimgsrc = "<img src=http://www.e-agent.biz/agentsites/" + userName + "/" + AgentPhoto + ">";
			else
				userimgsrc = "<img src=http://www.e-agent.biz/agentsites/" + AgentPhoto + ">";
			
			if (AgentCompanyPhoto != ""){
				//AgentCompanyPhoto = splitstr(AgentCompanyPhoto);
				AgentCompanyPhoto = repNUll(AgentCompanyPhoto);
				Agentcompanysrc = "<img src=http://www.e-agent.biz/agentsites/" + userName + "/" + AgentCompanyPhoto + ">";
			}	
			else
				Agentcompanysrc = "";
				
			//agent photo, name, occupiedterritory and his company photo	
			newhtml = "<table border='0' cellpadding='1' cellspacing='1' ID=Table1 width=430px>"
			newhtml = newhtml + "<tr><td valign=top width=75px>" + userimgsrc + "</td>"
			newhtml = newhtml + "<td valign=top width=255px><table border=0 ID=Table2 cellspacing=1 cellpadding=1>"
			newhtml = newhtml + "<tr><td valign=top class=fonttext><b><img src='images/e.jpg'>&nbsp;"+ ReplaceCarat(html) + "</b></td></tr>"
			newhtml = newhtml +	"<tr><td valign=top class=fonttext><b>" + name + "</b></td></tr>"
			newhtml = newhtml +	"<tr><td valign=top></td></tr></table></td>"
			newhtml = newhtml +	"<td valign=top align=right width=100px>"+ Agentcompanysrc + "</td></tr></table>"
			
			//different links like buyerform/phone/cma/imvoip
			link = "<table border=1 cellpadding=0 cellspacing=0 valign=top width=430px bordercolor=#cc3300><tr>";
			link = link + '<td><img src=images/ballAvailable1.jpg border=0 alt="Click here to view available homes in your area" title="Click here to view available homes in your area"></td>';
			link = link + '<td valign=top><a href="javascript:PhoneNo('+i+')"><img src=images/ballCall.jpg border=0 alt="Click here to call this e-Agent" Title="Click here to call this e-Agent"></a></td>';
			link = link + '<td><a href="javascript:CMAForm('+i+')"><img src=images/ballHome.jpg border=0 alt="Click here to find your homes value" Title="Click here to find your homes value"></a></td>';
			link = link + '<td><a href="javascript:IMVoip('+i+')"><img src=images/ballIM.jpg border=0 alt="Click here to Instant Message this e-Agent" title="Click here to Instant message this e-Agent"></a></td>';
			link = link + '</tr></table>';
			
			//buyer form
			buyerform = '' + 
					'<form id=Form1 name=form1 method=post>' +
					"<table border=0 cellpadding=1 cellspacing=1  ID=Table4 width=430px>" + 
					"<tr><td colspan=4><b class=headerStyle align=left>View current homes for sale</b> </td></tr>" +
					"<tr valign=top><td class=BalloonFormElements valign=middle>First Name:</td><td><input type=text name=firstname ID=Text7 maxlength=20 size=15></td>" +
					"<td class=BalloonFormElements valign=middle>Last Name:</td><td><input type=text name=lastname ID=Text8 maxlength=20 size=15></td></tr>" +
					"<tr valign=top><td class=BalloonFormElements valign=middle>Address:</td><td><input type=text name=address ID=Text9 maxlength=50 size=15></td>" + 
					"<td class=BalloonFormElements valign=middle>Zip:</td><td><input type=text name=zipcode ID=Text10 maxlength=7 size=15></td></tr>" +
					"<tr valign=top><td class=BalloonFormElements valign=middle>Email:</td><td><input type=text name=email ID=Text11 maxlength=50 size=15></td>" +
					"<td class=BalloonFormElements valign=middle>Phone:<BR>(xxx-xxx-xxxx)</td><td><input type=text name=Phone ID=Text12 maxlength=12 size=15></td></tr>" +
					
					"<tr><td class=BalloonFormElements>Price Range:</td>" + 
					
					"<td colspan=2><select name=pricerange STYLE='font-family: Arial, Helvetica, sans-serif;font-size:x-small;color: #333333;text-align:left;'><option value=1>$80,000 - $100,000</option>" +
					"<option value=2>$100,000 -  $125,000</option><option value=3>$125,000 - $150,000</option>"+
					"<option value=4>$150,000 - $200,000</option><option value=5>$200,000 - $250,000</option>"+
					"<option value=6>$250,000 - $300,000</option><option value=7>$300,000 - $350,000</option>"+
					"<option value=8>$350,000 - $400,000</option><option value=9>$400,000 - $500,000</option>"+
					"<option value=10 selected>$500,000 - $650,000</option><option value=11>$650,000 - $800,000</option>"+
					"<option value=12>$800,000 - $1,000,000</option><option value=13>$1,000,000 - $1,500,000</option>"+
					"<option value=14>$1,500,000 - $2,000,000</option><option value=18>$2,000,000 - $4,000,000</option>"+
					"<option value=19>$4,000,000+</option></select></td></tr>" +
					
					"<tr><td class=BalloonFormElements colspan=4>Are you also looking to sell your home:" +
					"<input type=Radio name=currhomesale value=yes checked ID=Radio1 checked>Yes&nbsp;&nbsp;<input type=Radio name=currhomesale value=no ID=Radio4>No</td></tr>" +
					
					"<tr valign=top><td align=center colspan=4><input type=button value='Email me available homes now' onclick=javascript:submitform(document.form1); ID=Button2 NAME=Button1></td>" +
					"</tr></table>" + 
					"<input type=hidden name=hidtype value=buyer ID=Hidden4><input type=hidden name=hidTerritoryID value=" + TerritoryID + " ID=Hidden5><input type=hidden name=hidAgentID value=" + AgentID + " ID=Hidden6>" +
					"</form>"  +
					'</td></tr></table>' ;
			
			BuyerFormHeader = '<tr bgcolor="#E3EDF5"><td colspan=2> ' +
							'<img border=0 name=iwimage1 src=http://www.eagent.com/images/iw-availablehomes_over.jpg>&nbsp;'+
							'<a href="javascript:PhoneNo('+ i +')" >' +
							'<img name=iwimage2 border=0 src=http://www.eagent.com/images/iw-callthiseagent.jpg></a> '+
							'<a href="javascript:CMAForm('+i+')" > ' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw_myhomevalue.jpg></a> ' +
							'<a href="javascript:IMVoip('+i+')" >' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw-imthiseagent.jpg></a>' +
							'</td></tr>';
			
			newHeading = '<div size=500px><table border=0 cellpadding=0 cellspacing=0 ID=HeaderTable width=400px>' +
							'<tr><td width=10><img src=http://www.eagent.com/images/iw-e.jpg></td>' +
							'	<td class=agent background=http://www.eagent.com/images/iw-locationbg.jpg align=right>' + ReplaceCarat(html) + ' for ' + name + '</td> '+
							'</tr>';
								
			newLeftImage = '<tr><td colspan=2 bgcolor=#E3EDF5  valign=top align=left> '+
							'	<table border=0 cellpadding=0 cellspacing=0 width=320px ID="Table2"> '+
							'	<tr><td valign=top height=22 width=81 align=left> ' + userimgsrc +
							'	<br><img height=1 src="images/pixel.gif">' + Agentcompanysrc + 
							'	</td><td bgcolor=#DFDFDF><img height=1 src="images/pixel.gif"></td><td width=200 valign=top align=left>' ;
			
			newbuyerform = '<form id=Form1 name=form1 method=post>' +
						'<input type=hidden name=test value="">' +
						'<table border=0 cellpadding=0 cellspacing=0> ' +
						"		<tr><td colspan=4><b class=headerStyle align=left>View current homes for sale</b> </td></tr>" +
						'		<tr valign=top><td class=links>&nbsp;First:</td><td><input type=text name=firstname ID=Text7 maxlength=20 size=15></td>'+
						'		<td class=links>&nbsp;Last:</td><td><input type=text name=lastname ID="Text8" maxlength=20 size=15></td></tr>'+
						'		<tr valign=top><td class=links>Address:</td><td><input type=text name=address ID="Text9" maxlength=50 size=15></td>'+
						'		<td class=links>&nbsp;Zip:</td><td><input type=text name=zipcode ID="Text10" maxlength=7 size=15></td></tr>'+
						'		<tr valign=top><td class=links>&nbsp;Email:</td><td><input type=text name=email ID="Text11" maxlength=50 size=15></td>'+
						'		<td class=links>&nbsp;Phone:</td><td><input type=text name=Phone ID="Text12" maxlength=12 size=15></td></tr>'+
						'		<tr><td class=links colspan=2>&nbsp;Price Range:</td><td colspan=2 align=left><select name=pricerange STYLE="font-family: Arial, Helvetica, sans-serif;font-size:x-small;color: #333333;text-align:left;" ID="Select1"> ' +
						'			<option value=1>$80,000 - $100,000</option><option value=2>$100,000 -  $125,000</option> ' +
						'			<option value=3>$125,000 - $150,000</option><option value=4>$150,000 - $200,000</option> ' +
						'			<option value=5>$200,000 - $250,000</option><option value=6>$250,000 - $300,000</option> ' +
						'			<option value=7>$300,000 - $350,000</option><option value=8>$350,000 - $400,000</option> ' +
						'			<option value=9>$400,000 - $500,000</option><option value=10 selected>$500,000 - $650,000</option> ' +
						'			<option value=11>$650,000 - $800,000</option><option value=12>$800,000 - $1,000,000</option> ' +
						'			<option value=13>$1,000,000 - $1,500,000</option><option value=14>$1,500,000 - $2,000,000</option> ' +
						'			<option value=18>$2,000,000 - $4,000,000</option><option value=19>$4,000,000+</option></select> '+
						'		</td></tr>' +

						'		<tr><td class=links colspan=3>Are you also looking to sell your home?</td> '+
						'		<td class=links align=left><input type=Radio name=currhomesale value=yes ID=Radio1 checked>Yes&nbsp;&nbsp;<input type=Radio name=currhomesale value=no ID=Radio4>No</td></tr>'+
						
//						'		<tr><td class=links colspan=4><hr></td></tr>'+
						//Added on 08/20/2007 -Josh request, forcing user to select either one of the raido button
						//Removed on 08/27/2007 -Lowell request, to remove the 2nd question.
//						'		<tr><td class=links colspan=3>2. Would you have preferred to see the homes first and then filled out this contact form at a later date?</td> '+
//						'		<td class=links align=left><input type=Radio name=movetoeAgent2 value=yes ID=movetoeAgent2>Yes&nbsp;&nbsp;<input type=Radio name=movetoeAgent2 value=no ID=movetoeAgent2>No</td></tr>'+						
						
						'		<tr valign=top><td class=links align=center colspan=4><input type=button value="Show me available homes now" onclick=javascript:submitform(document.form1); ID=Button2 NAME=Button1></td></tr> '+
						"		<input type=hidden name=hidtype value=buyer ID=Hidden4><input type=hidden name=hidTerritoryID value=" + TerritoryID + " ID=Hidden5><input type=hidden name=hidAgentID value=" + AgentID + " ID=Hidden6>" +
						'</table> ' +
						'</form>' ;
			
			newendhtml = '	</td></tr></table></td></tr></table> </div>';
			
			imageparameters = "AgentID=" + leftTrim(AgentID) + "&ProductID=1&Type=Photo"
			userimgsrc = imageparameters;
			
			imageparameters = "AgentID=" + leftTrim(AgentID) + "&ProductID=1&Type=Logo"
			Agentcompanysrc = imageparameters;
			
			BuyerHtml = newHeading + BuyerFormHeader + newLeftImage + newbuyerform + newendhtml;
			
			if (systemversion == "3"){
				newHead = Heading2("1",i,AgentID,TerritoryID,agentDisplayName,name,EmailAddress,PhoneNumber);
				newBody = MyOffer2(AgentID,TerritoryID,EmailAddress,OfferStatement,userName,userimgsrc,Agentcompanysrc,MLSLink,Town,StateAbbr);
				newFoot = FooterLinks(AgentID,TerritoryID);
				
				BuyerHtml =  newHead + newBody + newFoot;
			
				//BuyerHtml = Neighbourhood(i,userName,agentDisplayName,name,userimgsrc,Agentcompanysrc,AgentID,TerritoryID,MLSLink,Town,StateAbbr,StateID,PhoneNumber,EmailAddress);
				
			}

	        html		= BuyerHtml;
			gmarkers[i] = marker;
			htmls[i]	= html;
	        
			GEvent.addListener(marker, "click", function() {
				//Map Balloon Click for Territory Viewed category
				if (systemversion == "1") {
					ajaxFunction(AgentID,TerritoryID,1,clicktypemapballoon1,increment);//06/22/2007
				}else if (systemversion == "3") {
					ajaxFunction(AgentID,TerritoryID,1,clicktypemapballoon3,increment);//07/02/2007
				}
				
				RealEstateBalloonClicked(name,1); //04/17/2007
				map.savePosition(); //01/18/2007
				marker.openInfoWindowHtml(html,900);
				
			});
			
			//  ======01/17/2007  The new marker "mouseover" and "mouseout" listeners  ======
			GEvent.addListener(marker,"mouseover", function() {
				showTooltip(marker);
			});        
			GEvent.addListener(marker,"mouseout", function() {
				tooltip.style.visibility="hidden"
			});

			//recenters map view after closing infowindow 01/18/2007
			GEvent.addListener(map, "infowindowclose",function(){
				map.returnToSavedPosition();
			}); 

	       
	       //buyer form
	        Buyer_Form[i] = html;
	
			//Phone form header
			PhoneFormHeader = '<tr bgcolor="#E3EDF5"><td colspan=2> ' +
							'<a href="javascript:BuyerForm('+i+')"><img border=0 name=iwimage1 src=http://www.eagent.com/images/iw-availablehomes.jpg></a>&nbsp;'+
							'<img name=iwimage2 border=0 src=http://www.eagent.com/images/iw-callthiseagent_over.jpg>'+
							'<a href="javascript:CMAForm('+i+')"> ' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw_myhomevalue.jpg></a> ' +
							'<a href="javascript:IMVoip('+i+')">' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw-imthiseagent.jpg></a>' +
							'</td> </tr>';
							
			//Phone Form body			
			newPhoneForm = '<form id=form2 name=form2 method=post>' +
						'<table border=0 cellpadding=1 cellspacing=0 width=320px>' +
						'		<tr valign=top ><td class=links colspan=4 align=left>&nbsp;Would you have liked to call me toll-free? &nbsp;'+
						'		<tr><td class=links colspan=4 align=left><input type="radio" name="yesno" value="yes" checked="checked">Yes &nbsp;<input type="radio" name="yesno" value="no">No</span></td><td><input type=hidden name=hidtype value=phone ID=Hidden4></td></tr>'+
						'		<tr><td class=links colspan=4 align=left>Please leave your name and phone number below and I\'d be happy to contact you.</td></tr> ' +
						'		<tr valign=top><td class=links colspan=2 align=left>&nbsp;Name:</td><td colspan=2 align=left><input type=text name=firstname ID=Text7 maxlength=20 size=15></td><td>&nbsp;</td></tr>'+
						'		<tr valign=top><td class=links colspan=2 align=left>&nbsp;Phone:&nbsp;(xxx-xxx-xxxx)</td><td colspan=2 align=left><input type=text name=Phone ID="Text12" maxlength=12 size=15></td><td>&nbsp;<br><br></td></tr>'+
						
						'		<tr valign=top><td class=links align=center colspan=4><input type=button value="Submit" onclick=javascript:submitPhoneform(document.form2); ID=Button2 NAME=Button2></td></tr> '+
						"		<input type=hidden name=hidTerritoryID value=" + TerritoryID + " ID=Hidden5><input type=hidden name=hidAgentID value=" + AgentID + " ID=Hidden6>" +
						'</table> ' +
						'</form>' ;
			
			//Phone form direct number if the user has been subscribed for phone leads
			newPhoneNumber = 
						'<table border=1 cellpadding=0 cellspacing=0 width=320px> ' +
						'		<tr><td class=links colspan=4 align=center><br><b>Direct Number:</b>&nbsp;'+
						'		<tr><td class=links colspan=4 align=center>' + VSPhoneNo + '</td></tr>'+
						'</table> ';

			if ((VSPhoneNo) != "0") 
				// The info window version with the "Phone No." open
				Phone_No[i] = newHeading + PhoneFormHeader + newLeftImage + newPhoneNumber + newendhtml;
			else
				Phone_No[i] = newHeading + PhoneFormHeader + newLeftImage + newPhoneForm + newendhtml;
				
			if (systemversion == "3") {
				//Phone_No[i] = MyOffer(i,userName,agentDisplayName,name,userimgsrc,Agentcompanysrc,AgentID,TerritoryID,OfferStatement,PhoneNumber,EmailAddress);

				PhonenewHead = Heading2("2",i,AgentID,TerritoryID,agentDisplayName,name,EmailAddress,PhoneNumber);
				
				PhonenewBody = MyNeighborhood2(MLSLink,userName,userimgsrc,Agentcompanysrc,Town,StateAbbr,StateID);
				
				PhonenewFoot = FooterLinks(AgentID,TerritoryID);
				
				Phone_No[i] = PhonenewHead + PhonenewBody + PhonenewFoot;
								
			}	 

			//CMA Form header
			CMAFormHeader = '<tr bgcolor="#E3EDF5"><td colspan=2> ' +
							'<a href="javascript:BuyerForm('+i+')"><img border=0 name=iwimage1 src=http://www.eagent.com/images/iw-availablehomes.jpg></a>&nbsp;'+
							'<a href="javascript:PhoneNo('+ i +')" >' +
							'<img name=iwimage2 border=0 src=http://www.eagent.com/images/iw-callthiseagent.jpg></a> '+
							'<a href="javascript:CMAForm('+i+')"> ' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw_myhomevalue_over.jpg></a> ' +
							'<a href="javascript:IMVoip('+i+')">' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw-imthiseagent.jpg></a>' +
							'</td> </tr>';
			
			//CMA Form body			
			newCMAForm = '<form id=Form3 name=form3 method=post>' +
						'<table border=0 cellpadding=0 cellspacing=0> ' +
						'	<tr><td class=links colspan=4 align=left>What\'s my home worth?&nbsp; </td></tr>'+
						'		<tr valign=top><td class=links>First:</td><td><input type=text name=firstname ID=Text7 maxlength=20 size=15></td>'+
						'		<td class=links>Last:</td><td><input type=text name=lastname ID="Text8" maxlength=20 size=15></td></tr>'+
						'		<tr valign=top><td class=links>Address:</td><td><input type=text name=address ID="Text9" maxlength=50 size=15></td>'+
						'		<td class=links>Zip:</td><td><input type=text name=zipcode ID="Text10" maxlength=7 size=15></td></tr>'+
						'		<tr valign=top><td class=links>Email:</td><td><input type=text name=email ID="Text11" maxlength=50 size=15></td>'+
						'		<td class=links>Phone:</td><td><input type=text name=Phone ID="Text12" maxlength=12 size=15></td></tr>'+
						'		<tr><td class=links colspan=3 align=left>Is this property currently listed?</td><td align=left class=links> ' +
						'		<input type="radio" name="yesno" value="yes">Yes &nbsp;<input type="radio" name="yesno" value="no" checked="checked">No &nbsp;</td></tr>' +
						'		<tr><td class=links>Est.Value:</td> <td class=links align=left><input type=text name=estimatevalue maxlength=10 size=15></td>'+
						'		<td class=links>Sq.Footage:</td><td ><input type=text name=squareFootage maxlength=10 size=15></td></tr>'+
						'		<tr valign=top><td class=links align=center colspan=4><input type=button value="Email me my home value" onclick=javascript:submitform(document.form3); ID=Button3 NAME=Button3></td></tr> '+
						"		<input type=hidden name=hidtype value=cma ID=Hidden4><input type=hidden name=hidTerritoryID value=" + TerritoryID + " ID=Hidden5><input type=hidden name=hidAgentID value=" + AgentID + " ID=Hidden6>" +
						'</table> ' +
						'</form>' ;
			
			CMA_Form[i] = newHeading + CMAFormHeader + newLeftImage + newCMAForm + newendhtml;
				
			if (systemversion == "3") {

				//CMA_Form[i] = ContactMe(i,userName,agentDisplayName,name,userimgsrc,Agentcompanysrc,AgentID,TerritoryID,EmailAddress,CompanyWebsite,PhoneNumber,FaxNumber,AddressLine1,AddressLine2, IMID,IMType);
				AddressLine1 = AddressLine1 + " " + AddressLine2;
				CMAnewHead = Heading2("3",i,AgentID,TerritoryID,agentDisplayName,name,EmailAddress,PhoneNumber);
				CMAnewBody = MyContact2(agentDisplayName,PhoneNumber,EmailAddress,CompanyWebsite,AddressLine1,userName,userimgsrc,Agentcompanysrc);
				CMAnewFoot = FooterLinks(AgentID,TerritoryID);
				
				CMA_Form[i] = CMAnewHead + CMAnewBody + CMAnewFoot;

			}	
			
			//IMVOIP Form header
			IMVOIPFormHeader = '<tr bgcolor="#E3EDF5"><td colspan=2> ' +
							'<a href="javascript:BuyerForm('+i+')"><img border=0 name=iwimage1 src=http://www.eagent.com/images/iw-availablehomes.jpg></a>&nbsp;'+
							'<a href="javascript:PhoneNo('+ i +')" >' +
							'<img name=iwimage2 border=0 src=http://www.eagent.com/images/iw-callthiseagent.jpg></a> '+
							'<a href="javascript:CMAForm('+i+')"> ' +
							'<img border=0  name=iwimage3  src=http://www.eagent.com/images/iw_myhomevalue.jpg></a> ' +
							'<img border=0  name=iwimage4  src=http://www.eagent.com/images/iw-imthiseagent_over.jpg>' +
							'</td> </tr>';
			
			//IMVOIP Form body			
			newIMVOIPForm = '<form id=form4 name=form4 method=post>' +
						'<table border=0 cellpadding=1 cellspacing=0 width=320px>' +
						'		<tr><td class=links colspan=4 align=left>What is your IM or VOIP ID?&nbsp;'+
						'		<tr><td class=links colspan=4><input type="radio" name="im" value="yahoo" checked="checked">Yahoo&nbsp;<input type="radio" name="im" value="msn">MSN&nbsp;<input type="radio" name="im" value="aol">AOL&nbsp;<input type="radio" name="im" value="skype">Skype</span>&nbsp;<input type="radio" id="im" name="im" value="other">Other </span>&nbsp;</td><td><input type=hidden name=hidtype value=imvoip ID=Hidden4></td></tr>'+
						'		<tr valign=top><td class=links colspan=2 align=left>Name:</td><td colspan=2 align=left><input type=text name=firstname ID=Text7 maxlength=20 size=15></td><td>&nbsp;</td></tr>'+
						'		<tr valign=top><td class=links colspan=2 align=left>IM/VOIP ID:</td><td colspan=2 align=left><input type=text name=imvoip maxlength=20 size=15></td><td>&nbsp;<BR><BR></td></tr>'+
						'		<tr valign=top><td class=links align=center colspan=4><input type=button value="Submit" onclick=javascript:submit_IMVOIP(document.form4); ID=Button4 NAME=Button4></td></tr> '+
						"		<input type=hidden name=hidTerritoryID value=" + TerritoryID + " ID=Hidden5><input type=hidden name=hidAgentID value=" + AgentID + " ID=Hidden6>" +
						'</table> ' +
						'</form>' ;
			
			IMVOIP[i] = newHeading + IMVOIPFormHeader + newLeftImage + newIMVOIPForm + newendhtml;
			
			if (systemversion == "3") {	
				//IMVOIP[i] = AboutMeInfowindow(i,userName,agentDisplayName,name,userimgsrc,Agentcompanysrc,AgentID,TerritoryID,AboutMe,PhoneNumber,EmailAddress);
				IMVOIPnewHead = Heading2("4",i,AgentID,TerritoryID,agentDisplayName,name,EmailAddress,PhoneNumber);
				IMVOIPnewBody = AboutMe2(AboutMe,userName,userimgsrc,Agentcompanysrc);
				IMVOIPnewFoot = FooterLinks(AgentID,TerritoryID);
								
				IMVOIP[i] = IMVOIPnewHead + IMVOIPnewBody + IMVOIPnewFoot;
			}
				
			sidebar_html += '<a href="javascript:myclick(' + i + ');cityclick('+systemversion+','+AgentID+','+TerritoryID+');">' + name + '</a><br>';
			i++;
			return marker;
		}
		
		// ====== 01/17/2007 This function displays the tooltip ======
		// it can be called from an icon mousover
		function showTooltip(marker) {
      			tooltip.innerHTML = marker.tooltip;
			var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
			var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
			var anchor=marker.getIcon().iconAnchor;
			var width=marker.getIcon().iconSize.width;
			var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
			pos.apply(tooltip);
			tooltip.style.visibility="visible";
		}

		// This function picks up the click and opens the corresponding info window
		function myclick(i) {
			map.savePosition(); //02/22/2007
			gmarkers[i].openInfoWindowHtml(htmls[i],10);
		}

		//07/02/2007 function to count clicktype for right hand side city list.		
		function cityclick(systemversion,agentid,territoryid){
			//Territory Viewed (click city) Click count
			if (systemversion == "1"){
				ajaxFunction(agentid,territoryid,1,clicktypecityballoon1,increment);
			}else if (systemversion == "3"){
				ajaxFunction(agentid,territoryid,1,clicktypecityballoon3,increment);
			}
		}
		
		function Messsage(){
			alert("MLS not uploaded, please check surrounding territories.");
		}

		// functions that open the Buyer form
		function BuyerForm(i) {
			gmarkers[i].openInfoWindowHtml(Buyer_Form[i]);
		}
	      
		// functions that open the Phone no. text
		function PhoneNo(i) {
			gmarkers[i].openInfoWindowHtml(Phone_No[i]);
		}
	      
		// functions that open the CMA Form.
		function CMAForm(i) {
			gmarkers[i].openInfoWindowHtml(CMA_Form[i]);
		}

		// functions that open the IMVoip
		function IMVoip(i) {
			gmarkers[i].openInfoWindowHtml(IMVOIP[i]);
		}
				
		//07/02/2007
		//function to open the different tab based on parameters and click gets counted
		function OpenTabs(tab,i,agentid,territoryid,clickcountcategory){
			//alert(tab + ' ' + i + ' ' + agentid + ' ' + territoryid + ' ' + clickcountcategory);
			if (tab == "contactme"){
				gmarkers[i].openInfoWindowHtml(CMA_Form[i]);
			}
			else if (tab == "myoffer"){
				gmarkers[i].openInfoWindowHtml(Buyer_Form[i]);			
			}
			else if (tab == "aboutme"){
				gmarkers[i].openInfoWindowHtml(IMVOIP[i]);						
			}
			else if (tab == "neighbourhood"){
				gmarkers[i].openInfoWindowHtml(Phone_No[i]);						
			}
			//Territory Viewed Click count
			ajaxFunction(agentid,territoryid,1,clickcountcategory,increment);
		}

		// A function to read the data----------------------------
		function readMap(url) {
		
			// Start with an empty GLatLngBounds object =====     
			var bounds = new GLatLngBounds();
			
			try{
				var request = GXmlHttp.create();
			} catch (e) {
				alert("GXmlHttp caught...");
			}
			request.open("GET", url, true);
			request.onreadystatechange = function() {
			showLoad(); //show loading message

			if (request.readyState == 4) {
				
				var xmlDoc = request.responseXML;
				// obtain the array of markers and loop through it

				if ((request.status==200) || (request.status==0)) {
				
					if ((xmlDoc.documentElement != null)){
						
						var markers = xmlDoc.documentElement.getElementsByTagName("marker");
			            
						// hide the info window, otherwise it still stays open where the removed marker used to be
						map.getInfoWindow().hide();
			            
						// clear all existing markers
						for (i=0; i<gmarkers.length; i++) {
							map.clearOverlays();
						}
						
						for (i=0; i<Buyer_Form.length; i++) {
							map.clearOverlays();
						}

						// empty the array
						gmarkers = [];
						Buyer_Form = [];
						Phone_No = [];
						CMA_Form = [];
						IMVOIP = [];

						// reset the sidebar
						sidebar_html="";
						currentmarkerID = 0; //needs to be removed..
						if (markers.length != 0){
							for (var j = 0; j < markers.length; j++) {
								// obtain the attribues of each marker
								var lat				= parseFloat(markers[j].getAttribute("lat"));
								var lng				= parseFloat(markers[j].getAttribute("lng"));
								var point			= new GLatLng(lat,lng);
								var html			= markers[j].getAttribute("Name");
								var label			= markers[j].getAttribute("City");
								var userName		= markers[j].getAttribute("UserName");
								var AgentPhoto		= markers[j].getAttribute("AgentPhoto");
								var AgentCompanyPhoto = markers[j].getAttribute("AgentCompanyPhoto");
								var VSPhoneNo		= markers[j].getAttribute("VSPhoneNo");
								var TerritoryID		= markers[j].getAttribute("TerritoryID");
								var AgentID			= markers[j].getAttribute("AgentID");
								var MarketType		= markers[j].getAttribute("largeMarket");
								var SystemVersion	= markers[j].getAttribute("SystemVersion");
								var agentDisplayName= markers[j].getAttribute("AgentDisplayName");
								var MLSLink			= markers[j].getAttribute("MLSLink");
								var CompanyWebsite	= markers[j].getAttribute("CompanyWebsite");
								var EmailAddress	= markers[j].getAttribute("EmailAddress");
								var FaxNumber		= markers[j].getAttribute("FaxNumber");
								var PhoneNumber		= markers[j].getAttribute("PhoneNumber");
								var IMID			= markers[j].getAttribute("IMID");
								var IMType			= markers[j].getAttribute("IMType");
								var AddressLine1	= markers[j].getAttribute("AddressLine1");
								var AddressLine2	= markers[j].getAttribute("AddressLine2");
								var OfferStatement	= markers[j].getAttribute("OfferingStatement");
								var AboutMe			= markers[j].getAttribute("AboutMe");
								var Town			= markers[j].getAttribute("Town");
								var StateAbbr		= markers[j].getAttribute("StateAbbr");
								var StateID			= markers[j].getAttribute("StateID");
					              
								// create the marker
								var marker = createMarker(point,label,html,userName,AgentPhoto,AgentCompanyPhoto, VSPhoneNo,TerritoryID,AgentID,MarketType,SystemVersion,agentDisplayName,MLSLink,CompanyWebsite,EmailAddress,FaxNumber,PhoneNumber,IMID,IMType,AddressLine1,AddressLine2,OfferStatement,AboutMe,Town,StateAbbr,StateID);
								
								map.addOverlay(marker);
								
								bounds.extend(point);
							}
							// put the assembled sidebar_html contents into the sidebar div	
							document.getElementById("sidebar").innerHTML = sidebar_html;
							
							// determine the centre from the bounds ======
							var clat1 = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
							var clng1 = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
							//map.setCenter(new GLatLng(clat1,clng1));
							var zoomVal = getZoomValue(url)
							map.setCenter(new GLatLng(clat1,clng1),zoomVal);
							
							//movefirst();
							
							function balloonTimer(){
								window.setTimeout(function() {
									marker.openInfoWindowHtml(CMA_Form[currentmarkerID]);
								}, 5000);
								
								window.setTimeout(function() {
									marker.openInfoWindowHtml(Phone_No[currentmarkerID]);
								}, 10000);
								window.setTimeout(function() {
									marker.openInfoWindowHtml(IMVOIP[currentmarkerID]);
								}, 15000);
								window.setTimeout(function() {
									marker.openInfoWindowHtml(Buyer_Form[currentmarkerID]);
								}, 20000);
							}	
							
							function movefirst(){		
								balloonTimer();
								//window.setTimeout(function(){movenext();}, 22000);	
								
							}	
								            
	            			function movenext(){							
								balloonTimer();
								window.setTimeout(function(){movefirst();}, 22000);
							}

							
						}
						else{
							var nomaps = "<span class=note>Sorry, we do not have an e-Agent in the State/Province you have chosen, please choose another State/Province.</span> ";
							document.getElementById("sidebar").innerHTML = nomaps;
						}
						hideLoad(); //hide the loading message
						
					} 	
					else{ // check if object is null/not
						ajaxErrorNotification(url);
						alert("There is problem with data. \nPlease contact e-Agent customer service team regarding this issue 866-324-3687. Thank you.");
						document.location = document.location.href;
					}
				
				}else{ //checking request.status not equal 200
					alert("Your internet connection is a bit sporadic right now, we are going to bring you back to our homepage.");
					document.location = document.location.href;
				}
				
			} //request.readyState = 4
			
		} //onreadystatechange
				
		request.send(null);
	}
      // When initially loaded, use the data from "map11a.xml"
      //readMap("xmlData_VA.xml");
     
}else {
    alert("Sorry, the Google Maps API is not compatible with this browser");
}

function RealEstateBalloonClicked(cityState,mode)
{
	//05/17/2007
	var GoogleAnalyticsBalloonTracker;
	if (mode == "1") //google map balloon click
		GoogleAnalyticsBalloonTracker = "/RealEstateBalloonClicked?Map=" + cityState;
	else if (mode == "2") //Randomizer link clicked (which balloon opensup)
		GoogleAnalyticsBalloonTracker = "/RealEstateBalloonClicked?Randomizer=" + cityState;
		
	urchinTracker(GoogleAnalyticsBalloonTracker);
}


function infowindow(username,CityState,userimgsrc,Agentcompanysrc,agentid,territoryid,OfferingStatement){

		infowindow2 = "";
		
		userimgsrc = "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
		Agentcompanysrc = "<img src=./showimage.asp?" + Agentcompanysrc + ">"; 	
		imagePixel = "<img src='./images/pixel.gif'>"
		
		infowindow2 = infowindow2 + "<div id='infowindow1'>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 ID=Table1 bgcolor=white>"
		infowindow2 = infowindow2 + "<tr><td width=180px><img src='./images/iw-e.jpg'></td>"
		infowindow2 = infowindow2 + "<td width=300px class='agent'>" +username + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=2>" +imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2>"
		infowindow2 = infowindow2 + "<a href='' onMouseOver=changeImages('iwimage1','iwimage1on'); onMouseOut=changeImages('iwimage1','iwimage1off');><img border=0 name=iwimage1 src='./images/iw-aboutme.jpg'></a>"
		infowindow2 = infowindow2 + "<a href='' onMouseOver=changeImages('iwimage2','iwimage2on'); onMouseOut=changeImages('iwimage2','iwimage2off');><img border=0 name=iwimage2 src='./images/iw-callthiseagent.jpg'></a>"
		infowindow2 = infowindow2 + "<a href='' onMouseOver=changeImages('iwimage3','iwimage3on'); onMouseOut=changeImages('iwimage3','iwimage3off');><img border=0 name=iwimage3 src='./images/iw-imthiseagent.jpg'></a>"
		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 bgcolor=#E3EDF5 height=155 valign=top align=right>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=252>"
		infowindow2 = infowindow2 + "<tr><td valign=top height=135 width=81><img height=5 width=1 src='./images/pixel.gif'>"
		infowindow2 = infowindow2 + userimgsrc + "<br><img height=5 src='./images/pixel.gif'>" + Agentcompanysrc + "</td>"
		infowindow2 = infowindow2 + "<td width=171 valign=top>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 width=171 background='./images/iw-locationbg.jpg'"
		infowindow2 = infowindow2 + "height=25 align=right class='location'>" + CityState + "</td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td width=10 rowspan=4>" +imagePixel + "</td>"
		infowindow2 = infowindow2 + "<td height=22 valign=center><img src='./images/iw-arrow.jpg'>"
		infowindow2 = infowindow2 + "<a href='' class='links'>View Homes</a></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td height=22 valign=center><img src='./images/iw-arrow.jpg'>"
		infowindow2 = infowindow2 + "<a href='' class='links'>School Reports</a></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=22 valign=center><img src='./images/iw-arrow.jpg'>"
		infowindow2 = infowindow2 + "<a href='' class='links'>Neighbourhood testing girish Reports</a></td></tr>"

		infowindow2 = infowindow2 + "</table></td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 valign=top><a class='links' href=javascript:DisplayVideo(1,"+agentid+","+territoryid+",5);>My Video</a></td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2>" + imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "</table></td></tr></table></div>"
		return infowindow2;
		
}
       
      
function Neighbourhood(i,username,AgentDisplayName,CityState,userimgsrc,Agentcompanysrc,agentid,territoryid,MLSLink,Town, StateAbbr,StateID,PhoneNumber,EmailAddress){
		infowindow2		= "";
	
		userimgsrc = "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
		Agentcompanysrc = "<img src=./showimage.asp?" + Agentcompanysrc + ">"; 	
		imagePixel = "<img src='./images/pixel.gif'>"
		
		infowindow2 = infowindow2 + "<div id='infowindow1'>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 ID=Table1 bgcolor=white width=100%>"
		infowindow2 = infowindow2 + "<tr><td width=300px><img src='./images/iw-e.jpg'></td>"
		infowindow2 = infowindow2 + "<td width=350px class='agent' align=right>" +AgentDisplayName + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=2>" +imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 align=right>"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('aboutme',"+ i +","+agentid+","+territoryid+","+clicktypeaboutme+") onMouseOver=changeImages('AboutMeImage','imageeAgentcom1on'); onMouseOut=changeImages('AboutMeImage','imageeAgentcom1off');><img border=0 name=AboutMeImage src='./images/iw-aboutme.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('myoffer',"+ i +","+agentid+","+territoryid+","+clicktypeofferview+") onMouseOver=changeImages('MyOffer','imageeAgentcom2on'); onMouseOut=changeImages('MyOffer','imageeAgentcom2off');><img border=0 name=MyOffer alt='My Offer' src='./images/iw_myoffer.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('contactme',"+ i +","+agentid+","+territoryid+","+clicktypecontactme+") onMouseOver=changeImages('MyContact','imageeAgentcom3on'); onMouseOut=changeImages('MyContact','imageeAgentcom3off');><img border=0 name=MyContact src='./images/iw_ContactMe.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href='#'><img border=0 alt='Neighbourhood details' name=Neighbourhood src='./images/iw_neighbourhood_over.jpg'></a>"
		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 bgcolor=#E3EDF5 height=155 valign=top align=left>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=400>"
		infowindow2 = infowindow2 + "<tr><td valign=top height=125 width=81><img height=5 width=1 src='./images/pixel.gif'>"
		infowindow2 = infowindow2 + userimgsrc + "<br><img height=5 src='./images/pixel.gif'>" + Agentcompanysrc + "<a class='links' href=javascript:DisplayVideo(1,"+agentid+","+territoryid+",13);>My Video</a></td>"
		infowindow2 = infowindow2 + "<td width=320px valign=top>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=90%>"
		infowindow2 = infowindow2 + "<tr><td colspan=3  background='./images/iw-locationbg.jpg'"
		infowindow2 = infowindow2 + "height=25 align=right class='location'>" + CityState + "</td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td width=20 rowspan=5>" +imagePixel + "</td>"
		infowindow2 = infowindow2 + "<td><img src='./images/iw-arrow.jpg'></td><td>"
		
		if (MLSLink != ""){
			infowindow2 = infowindow2 + "<a target='_blank' href='http://" + MLSLink + "' class='neighborhood'>";
		}else{
			infowindow2 = infowindow2 + "<a href=javascript:Messsage() class='neighborhood'>"
		}
		infowindow2 = infowindow2 + "View All Current Homes For Sale</a></td></tr>"

		infowindow2 = infowindow2 + "<tr><td colspan=2 height=10><img src='./images/pixel.gif'></td></tr>"
		
		School = "http://www.greatschools.net/city/" + Town + "/" + StateAbbr;
		infowindow2 = infowindow2 + "<tr><td><img src='./images/iw-arrow.jpg'></td>"
		infowindow2 = infowindow2 + "<td><a target='_blank' href='" + School + "' class='neighborhood'>Research The School District</a></td></tr>"

		infowindow2 = infowindow2 + "<tr><td colspan=2 height=10><img src='./images/pixel.gif'></td></tr>"
				
		infowindow2 = infowindow2 + "<tr><td><img src='./images/iw-arrow.jpg'></td>"
		
		//Town = "http://www.americantowns.com/" + StateAbbr + "/" + Town;
		Town = "Neighboorhood/eAgentAmericanTowns.asp?stateabbr=" + StateAbbr + "&town=" + Town;
		if (StateID > 62){ //Neighbourhood for Canada
			Town = "http://www12.statcan.ca/english/census06/data/profiles/community/Index.cfm?Lang=E";
		}
		
		infowindow2 = infowindow2 + "<td><a target='_blank' href=" +Town+ " class='neighborhood'>Free Neighborhood Information</a></td></tr>"
		infowindow2 = infowindow2 + "<tr><td>&nbsp;<BR></td></tr>" 
		//OpenTabs('emailthispage',"+ i +","+agentid+","+territoryid+","+clicktypeemailafriend+");																																				
		//infowindow2 = infowindow2 + "<tr><td align=center colspan=3><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"
		
		infowindow2 = infowindow2 + "</table></td></tr>"
		//infowindow2 = infowindow2 + "<tr><td colspan=2 valign=top><a class='links' href=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');>Email this territory to friend</a></td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2>" + imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "</table></td></tr>"

		infowindow2 = infowindow2 + "<tr><td align=center colspan=2><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');>"
		infowindow2 = infowindow2 + "<input type='button' name='needhelp' value='Need Help?' onclick=javascript:open_popup('NeedHelp.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"
		infowindow2 = infowindow2 + "<tr><td class=links align=left>Phone: " +PhoneNumber + "</td><td class=links align=right>Email: <a href=mailto:" + EmailAddress + ">" + EmailAddress + "</a></td></tr>"
		
		infowindow2 = infowindow2 + "</table></div>"
		
		return infowindow2;
		
}


function MyOffer(i,username,AgentDisplayName,CityState,userimgsrc,Agentcompanysrc,agentid,territoryid,OfferStatement,PhoneNumber,EmailAddress){

		infowindow2		= "";
		
		userimgsrc = "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
		Agentcompanysrc = "<img src=./showimage.asp?" + Agentcompanysrc + ">"; 	
		imagePixel = "<img src='./images/pixel.gif'>"
		
		infowindow2 = infowindow2 + "<div id='infowindow1'>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 ID=Table1 bgcolor=white>"
		infowindow2 = infowindow2 + "<tr><td width=200px><img src='./images/iw-e.jpg'></td>"
		infowindow2 = infowindow2 + "<td width=250px class='agent' align=right>" +AgentDisplayName + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=2>" +imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 align=right>" 
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('aboutme',"+ i +","+agentid+","+territoryid+","+clicktypeaboutme+") onMouseOver=changeImages('iwimage1','imageeAgentcom1on'); onMouseOut=changeImages('iwimage1','imageeAgentcom1off');><img border=0 name=iwimage1 src='./images/iw-aboutme.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href='#'><img border=0 name=iwimage2 src='./images/iw_myoffer_over.jpg' alt='My Offerring Statement'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('contactme',"+ i +","+agentid+","+territoryid+","+clicktypecontactme+") onMouseOver=changeImages('iwimage3','imageeAgentcom3on'); onMouseOut=changeImages('iwimage3','imageeAgentcom3off');><img border=0 name=iwimage3 alt='Contact Me' src='./images/iw_ContactMe.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('neighbourhood',"+ i +","+agentid+","+territoryid+","+clicktypeneighbourhood+") onMouseOver=changeImages('iwimage4','imageeAgentcom4on'); onMouseOut=changeImages('iwimage4','imageeAgentcom4off');><img border=0 name=iwimage4 alt='Neighbourhood Details'  src='./images/iw_neighbourhood.jpg'></a>"

		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 bgcolor=#E3EDF5 height=155 valign=top align=left>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=400>"
		infowindow2 = infowindow2 + "<tr><td valign=top height=125 width=81><img height=5 width=1 src='./images/pixel.gif'>"
		infowindow2 = infowindow2 + userimgsrc + "<br><img height=5 src='./images/pixel.gif'>" + Agentcompanysrc + "<a class='links' href=javascript:DisplayVideo(1,"+agentid+","+territoryid+",13);>My Video</a></td>"
		infowindow2 = infowindow2 + "<td width=320px valign=top>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=90%>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 background='./images/iw-locationbg.jpg'"
		infowindow2 = infowindow2 + "height=25 align=right class='location'>" + CityState + "</td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td width=5 rowspan=4>" +imagePixel + "</td>"
		infowindow2 = infowindow2 + "<td height=22 valign=center class=links>"
		
		if (OfferStatement == ""){
			OfferStatement = "No Offer Available!"
		}
		infowindow2 = infowindow2 + OfferStatement + "</td></tr>"
		
		infowindow2 = infowindow2 + "</table></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td colspan=2>" + imagePixel + "</td></tr>"
		
		infowindow2 = infowindow2 + "</table></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td align=center colspan=2><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');>"
		infowindow2 = infowindow2 + "<input type='button' name='needhelp' value='Need Help?' onclick=javascript:open_popup('NeedHelp.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"
		infowindow2 = infowindow2 + "<tr><td class=links align=left>Phone: " +PhoneNumber + "</td><td class=links align=right>Email: <a href=mailto:" + EmailAddress + ">" + EmailAddress + "</a></td></tr>"
		
		infowindow2 = infowindow2 + "</table></div>"
		
		return infowindow2;
		
		return infowindow2;
		
}


function ContactMe(i,username,AgentDisplayName,CityState,userimgsrc,Agentcompanysrc,agentid,territoryid,EmailAddress,CompanyWebsite,PhoneNumber,FaxNumber,AddressLine1,AddressLine2, IMID,IMType){
		
		infowindow2 = "";
		
		userimgsrc = "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
		Agentcompanysrc = "<img src=./showimage.asp?" + Agentcompanysrc + ">"; 	
		imagePixel = "<img src='./images/pixel.gif'>"
		
		infowindow2 = infowindow2 + "<div id='infowindow1'>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 ID=Table1 bgcolor=white>"
		infowindow2 = infowindow2 + "<tr><td width=200px><img src='./images/iw-e.jpg'></td>"
		infowindow2 = infowindow2 + "<td width=250px class='agent' align=right align=right>" +AgentDisplayName + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=2>" +imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 align=right>" 
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('aboutme',"+ i +","+agentid+","+territoryid+","+clicktypeaboutme+") onMouseOver=changeImages('iwimage1','imageeAgentcom1on'); onMouseOut=changeImages('iwimage1','imageeAgentcom1off');><img border=0 name=iwimage1 src='./images/iw-aboutme.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('myoffer',"+ i +","+agentid+","+territoryid+","+clicktypeofferview+") onMouseOver=changeImages('iwimage2','imageeAgentcom2on'); onMouseOut=changeImages('iwimage2','imageeAgentcom2off');><img border=0 name=iwimage2 src='./images/iw_myoffer.jpg' alt='My Offerring Statement'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href='#'><img border=0 name=iwimage3 alt='Contact Me' src='./images/iw_ContactMe_over.jpg'></a>&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('neighbourhood',"+ i +","+agentid+","+territoryid+","+clicktypeneighbourhood+") onMouseOver=changeImages('iwimage4','imageeAgentcom4on'); onMouseOut=changeImages('iwimage4','imageeAgentcom4off');><img border=0 name=iwimage4 alt='Neighbourhood Details'  src='./images/iw_neighbourhood.jpg'></a>"

		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 bgcolor=#E3EDF5 height=155 valign=top align=left>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=400>"
		infowindow2 = infowindow2 + "<tr><td align=left valign=top height=125 width=81><img height=5 width=1 src='./images/pixel.gif'>"
		infowindow2 = infowindow2 + userimgsrc + "<br><img height=5 src='./images/pixel.gif'>" + Agentcompanysrc + "<BR><a class='links' href=javascript:DisplayVideo(1,"+agentid+","+territoryid+",13);>My Video</a></td>"
		infowindow2 = infowindow2 + "<td width=340px valign=top>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=100%>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 background='./images/iw-locationbg.jpg'"
		infowindow2 = infowindow2 + "height=25 align=right class='location'>" + CityState + "</td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td width=5 rowspan=10>" +imagePixel + "</td>"
		infowindow2 = infowindow2 + "<td height=22 valign=center class=links>"

		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=100%>"
		infowindow2 = infowindow2 + "<tr><td class=links width=30%>Name:</td><td class=links width=50%>" + AgentDisplayName + "</td></tr>"
		if (PhoneNumber != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>Phone:</td><td class=links width=50%>" + PhoneNumber + "</td></tr>"
		}
		if (FaxNumber != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>Fax:</td><td class=links width=50%>" + FaxNumber + "</td></tr>"
		}
		if (EmailAddress != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>Email:</td><td class=links width=50%><a href=mailto:" + EmailAddress + ">" + EmailAddress + "</a></td></tr>"
		}
		if (CompanyWebsite != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>My Website:</td><td class=links width=50%><a target='_blank' href=http://" + CompanyWebsite + ">" + CompanyWebsite + "</a></td></tr>"
		}

		if (AddressLine1 != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>Address:</td><td class=links width=50%>" + AddressLine1 + "</td></tr>"
		}
		if (AddressLine2 != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%></td><td class=links width=50%>" + AddressLine2 + "</td></tr>"
		}
		
		if (IMID != "") {
			infowindow2 = infowindow2 + "<tr><td class=links width=30%>" + IMType + "&nbsp;ID:</td><td class=links width=50%>" + IMID + "</td></tr>"
		}
		
		infowindow2 = infowindow2 + "</table></td></tr>"
		
		//infowindow2 = infowindow2 + "<tr><td align=center colspan=2><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td colspan=2>" + imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "</table></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td align=center colspan=2><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');>"
		infowindow2 = infowindow2 + "<input type='button' name='needhelp' value='Need Help?' onclick=javascript:open_popup('NeedHelp.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"

		infowindow2 = infowindow2 + "</table></div>"
		
		return infowindow2;
		
}

//about me info 
function AboutMeInfowindow(i,username,AgentDisplayName,CityState,userimgsrc,Agentcompanysrc,agentid,territoryid,AboutMe,PhoneNumber,EmailAddress){
		infowindow2 = "";
		
		userimgsrc = "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
		Agentcompanysrc = "<img src=./showimage.asp?" + Agentcompanysrc + ">"; 	
		imagePixel = "<img src='./images/pixel.gif'>"
		
		infowindow2 = infowindow2 + "<div id='infowindow1'>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 ID=Table1 bgcolor=white>"
		infowindow2 = infowindow2 + "<tr><td width=200px><img src='./images/iw-e.jpg'></td>"
		infowindow2 = infowindow2 + "<td width=250px class='agent' align=right>" + AgentDisplayName + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 height=2>" +imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 align=left>" 
		infowindow2 = infowindow2 + "<a href='#'><img border=0 name=iwimage1 src='./images/iw-aboutme_over.jpg'></a>&nbsp;&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('myoffer',"+ i +","+agentid+","+territoryid+","+clicktypeofferview+") onMouseOver=changeImages('iwimage2','imageeAgentcom2on'); onMouseOut=changeImages('iwimage2','imageeAgentcom2off');><img border=0 name=iwimage2 src='./images/iw_myoffer.jpg' alt='My Offerring Statement'></a>&nbsp;&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('contactme',"+ i +","+agentid+","+territoryid+","+clicktypecontactme+") onMouseOver=changeImages('iwimage3','imageeAgentcom3on'); onMouseOut=changeImages('iwimage3','imageeAgentcom3off');><img border=0 name=iwimage3 alt='Contact Me' src='./images/iw_ContactMe.jpg'></a>&nbsp;&nbsp;"
		infowindow2 = infowindow2 + "<a href=javascript:OpenTabs('neighbourhood',"+ i +","+agentid+","+territoryid+","+clicktypeneighbourhood+") onMouseOver=changeImages('iwimage4','imageeAgentcom4on'); onMouseOut=changeImages('iwimage4','imageeAgentcom4off');><img border=0 name=iwimage4 alt='Neighbourhood Details'  src='./images/iw_neighbourhood.jpg'></a>"

		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 bgcolor=#E3EDF5 height=155 valign=top align=center>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=400>"
		infowindow2 = infowindow2 + "<tr><td valign=top height=125 width=81><img height=5 width=1 src='./images/pixel.gif'>"
		infowindow2 = infowindow2 + userimgsrc + "<br><img height=5 src='./images/pixel.gif'>" + Agentcompanysrc + "<a class='links' href=javascript:DisplayVideo(1,"+agentid+","+territoryid+",13);>My Video</a></td>"
		infowindow2 = infowindow2 + "<td width=320px valign=top>"
		infowindow2 = infowindow2 + "<table border=0 cellpadding=0 cellspacing=0 width=90%>"
		infowindow2 = infowindow2 + "<tr><td colspan=2 background='./images/iw-locationbg.jpg'"
		infowindow2 = infowindow2 + "height=25 align=right class='location'>" + CityState + "</td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td width=5 rowspan=4>" +imagePixel + "</td>"
		infowindow2 = infowindow2 + "<td height=22 class=links valign=left align=left>"
		
		if (AboutMe != ""){
			infowindow2 = infowindow2 + AboutMe;
		}else{
			infowindow2 = infowindow2 + "About me details...<BR>I'm so and so..."
		}

		infowindow2 = infowindow2 + "</td></tr>"
		infowindow2 = infowindow2 + "</table></td></tr>"

		infowindow2 = infowindow2 + "<tr><td colspan=2>" + imagePixel + "</td></tr>"
		infowindow2 = infowindow2 + "</table></td></tr>"
		
		infowindow2 = infowindow2 + "<tr><td align=center colspan=2><input type='button' name='emailthislink' value='Email this link' onclick=javascript:open_popup('Emailthislink.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');>"
		infowindow2 = infowindow2 + "<input type='button' name='needhelp' value='Need Help?' onclick=javascript:open_popup('NeedHelp.asp?productid=0&agentid="+agentid+"&territoryid="+territoryid+"');></td></tr>"
		infowindow2 = infowindow2 + "<tr><td class=links align=left>Phone: " +PhoneNumber + "</td><td class=links align=right>Email: <a href=mailto:" + EmailAddress + ">" + EmailAddress + "</a></td></tr>"

		infowindow2 = infowindow2 + "</table></div>"
		
		return infowindow2;
		
}

function GoogleAds(){

	GoogleAds = GoogleAds + "<tr><td>";
//	GoogleAds = GoogleAds + "<script type=text/javascript>";
	GoogleAds = GoogleAds + "google_ad_client = 'pub-8024740823823488';";
	GoogleAds = GoogleAds + "google_ad_width = 234;";
	GoogleAds = GoogleAds + "google_ad_height = 60;";
	GoogleAds = GoogleAds + "google_ad_format = '234x60_as';";
	GoogleAds = GoogleAds + "google_ad_type = 'text_image';";
	GoogleAds = GoogleAds + "google_ad_channel = '';";
	GoogleAds = GoogleAds + "google_color_border = 'FFFFFF';";
	GoogleAds = GoogleAds + "google_color_bg = 'FFFFFF';";
	GoogleAds = GoogleAds + "google_color_link = '0066CC';";
	GoogleAds = GoogleAds + "google_color_text = '000000';";
	GoogleAds = GoogleAds + "google_color_url = '0066CC';";
//	GoogleAds = GoogleAds + "</script>";
	GoogleAds = GoogleAds + "<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script>";
	GoogleAds = GoogleAds + "</td></tr>"	;
		
	return GoogleAds;

}

function Heading2(mode,i,agentid,territoryid,AgentName,city,emailid,phoneno){

	newheading2 = "";
	emailid1	= "";
	
	topheadClass = "win_phone";
	//35+22=57
	if (AgentName.length + city.length > 57){
		topheadClass = "win_phone1";	
	}
	//win_agentname //win_phone
	AgentName	= '<span class='+topheadClass+'>' + AgentName + '</span>';
	city		= '<span class='+topheadClass+'>' + city + '</span>';
	//emailid1	= '<a href=mailto:'+ emailid + '>'+emailid+'</a>';
	if (emailid != ""){
		emailid1	= '<a href=mailto:'+ emailid + ' title='+emailid+'>Email</a>';
	}
	// 1st row (Agent Name and email link)
	newheading2 = "<table border=0 cellpadding=0 cellspacing=0 id=win_table>";
	newheading2 = newheading2 +	'<tr><td colspan=3>';
	newheading2 = newheading2 +	AgentName + ' | ' + city + ' | ' + emailid1;
	newheading2 = newheading2 +	'</td></tr>';
	
	if (mode == "1"){
		myofferclassID = "win_myofferCurrent";
	}else{
		myofferclassID = "win_myoffer";
	}
	
	if (mode == "2"){
		myNeighborhoodclassID = "win_neighborhoodCurrent";
	}else{
		myNeighborhoodclassID = "win_neighborhood";
	}

	if (mode == "3"){
		myContactclassID = "win_contactCurrent";
	}else{
		myContactclassID = "win_contact";
	}

	if (mode == "4"){
		myAboutclassID = "win_aboutmeCurrent";
	}else{
		myAboutclassID = "win_aboutme";
	}
			
	//2nd row buttons	
	newheading2 = newheading2 + '<tr><td>';
	
	newheading2 = newheading2 + '<a href=javascript:OpenTabs("myoffer",'+ i +','+agentid+','+territoryid+','+clicktypeofferview+'); id='+myofferclassID+'></a>';
	
	newheading2 = newheading2 + '<a href=javascript:OpenTabs("neighbourhood",'+ i +','+agentid+','+territoryid+','+clicktypeneighbourhood+'); id='+myNeighborhoodclassID+'></a>';
	
	newheading2 = newheading2 + '<a href=javascript:OpenTabs("contactme",'+ i +','+agentid+','+territoryid+','+clicktypecontactme+'); id='+myContactclassID+'></a>';
	
	newheading2 = newheading2 + '<a href=javascript:OpenTabs("aboutme",'+ i +','+agentid+','+territoryid+','+clicktypecontactme+'); id='+myAboutclassID+'></a>';
	
	newheading2 = newheading2 + '</td><td rowspan=2 width=3 bgcolor=#ffffff></td>';

	phonestyle = "win_phone";
	if (phoneno.length > 12){
		phonestyle = "win_phonesmallfont";
	}
	newheading2 = newheading2 + '<td align=center><span class='+phonestyle+'>'+phoneno+'</span></td></tr>';
	
	return newheading2;
	
}

function MyOffer2(agentid,territoryid,emailid,OfferStatement,username,userimgsrc,Agentcompanysrc,MLSLink,Town,StateAbbr){

	MLSURL			= ""
	newMyOffer2		= "";
	userimgsrc		= "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
	Agentcompanysrc = "<img border=0 class=win_agentimages src=./showimage.asp?" + Agentcompanysrc + ">"; 
	initialMLSLink	=	MLSLink;
	if (MLSLink != ""){
		if ((MLSLink.indexOf("http")) == -1){
			MLSLink = "http://" + MLSLink ;
		}
		
		if ((initialMLSLink.indexOf("http")) == -1){
			initialMLSLink = "http://" + initialMLSLink ;
		}
		
		MLSURL	= MLSLink;
		//MLSLink	= '<a class=win_nothanks target=_blank href='+ MLSLink + '>';
		MLSLink = "<a href='javascript:SubmitMLSLink(document.newform2);' class='win_nothanks'>"
		
	}else{
		MLSLink = MLSLink + "<a href=javascript:Messsage(); class='win_nothanks'>"
	}
	
	MLSLink = MLSLink + '<u>See The Listings</u></a>';

	
	// 1st row (Offer) and form header
	newMyOffer2 = newMyOffer2 + '<tr><td height=196 valign=top width=354 bgcolor=#E3EDF5>';	
	newMyOffer2 = newMyOffer2 + '<div id=win_myoffer_container>';
	newMyOffer2 = newMyOffer2 + '<form id=newform2 name=newform2 method=post>';		
	newMyOffer2 = newMyOffer2 + '<table border=0 cellpadding=1 cellspacing=0 ><tr><td class=text colspan=3 ><font color=red><b>';
	newMyOffer2 = newMyOffer2 + OfferStatement;
	newMyOffer2 = newMyOffer2 + '</b></font></td></tr><tr><td class=text colspan=3>';
	newMyOffer2 = newMyOffer2 + '<hr><b>To view homes now with no commitment please leave your:</b>';
	newMyOffer2 = newMyOffer2 + '</td></tr>';
	
	//2nd row (offer form)
	newMyOffer2 = newMyOffer2 + '<tr><td>';
	//newMyOffer2 = newMyOffer2 + 'testing from girish';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidtype name=hidtype value=eagent2>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidTerritoryID name=hidTerritoryID value='+territoryid+'>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidAgentID name=hidAgentID value='+agentid+'>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidMLSLink name=hidMLSLink value='+initialMLSLink+'>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidusername name=hidusername value='+username+'>';
	
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidTown name=hidTown value='+Town+'>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidStateAbbr name=hidStateAbbr value='+StateAbbr+'>';
	newMyOffer2 = newMyOffer2 + '<input type=hidden id=hidMLSURL name=hidMLSURL value='+MLSURL+'>';	
	
	newMyOffer2 = newMyOffer2 + '<table width=200 border=0 cellpadding=2 cellspacing=0>';
	newMyOffer2 = newMyOffer2 + '<tr><td class=smalltext><b>Name</b></td><td colspan=2><input type=text class=win_input id=firstname name=firstname maxlength=20></td></tr>';
	newMyOffer2 = newMyOffer2 + '<tr><td class=smalltext><b>Email</b></td><td colspan=2><input type=text class=win_input id=email name=email maxlength=50></td></tr>';
	newMyOffer2 = newMyOffer2 + '<tr><td class=smalltext><b>Phone<BR></b></td><td><input type=text class=win_input id=Phone name=Phone maxlength=12></td>';
	
	//12/04/2007
	newMyOffer2 = newMyOffer2 + '</tr></table>';
	newMyOffer2 = newMyOffer2 + '</td>';
	newMyOffer2 = newMyOffer2 + '<td align=center width=250><span class=win_nothanks></span>';
	newMyOffer2 = newMyOffer2 + '<a href=javascript:submitnewform2(document.newform2);><img border=0 src=/images/button101.JPG></a></td>';	
	

	newMyOffer2 = newMyOffer2 + '</td></tr>';	
	newMyOffer2 = newMyOffer2 + '</table>';
	newMyOffer2 = newMyOffer2 + '</form>';	
	newMyOffer2 = newMyOffer2 + '</div></td>';
	//Right side agent image and company logo.	
	newMyOffer2 = newMyOffer2 + '<td width=97 bgcolor=#EFF2F4 valign=top align=center>';
	newMyOffer2 = newMyOffer2 + userimgsrc + '<p>';
	newMyOffer2 = newMyOffer2 + Agentcompanysrc;
	newMyOffer2 = newMyOffer2 + '</td></tr>';
	
	return newMyOffer2;
	
}

function MyContact2(Name,phoneno,emailid,website,address,username,userimgsrc,Agentcompanysrc){

	newMyContact2	= "";
	userimgsrc		= "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
	Agentcompanysrc = "<img class=win_agentimages src=./showimage.asp?" + Agentcompanysrc + ">"; 

	if ((website.indexOf("http")) == -1){
		website = "http://" + website + "/";
	}
	website	= '<a href='+ website + '>'+website+'</a>';
	
	display_emailid="";
	if (emailid != ""){
		display_emailid = ReplacespaceBack(emailid);
		emailid = Replacespace(emailid);
	}
	
	emailid	= '<a href=mailto:'+emailid+'>' + display_emailid + '</a>';
	
	// 1st row (Offer) and form header
	newMyContact2 = newMyContact2 + '<tr><td height=186 valign=top width=354 bgcolor=#E3EDF5>';	
	newMyContact2 = newMyContact2 + '<div id=win_myoffer_container>';
	newMyContact2 = newMyContact2 + '<table border=0 cellpadding=3 cellspacing=0 width=325>';

	newMyContact2 = newMyContact2 + '<tr><td class=text><b>Name:</b></td><td class=text>'+Name+'</td></tr>';
	newMyContact2 = newMyContact2 + '<tr><td width=75 class=text><b>Phone:</b></td><td class=text>'+phoneno+'</td></tr>';
	newMyContact2 = newMyContact2 + '<tr><td width=75 class=text><b>E-Mail:</b></td><td class=text>'+emailid+'</td></tr>';	
	newMyContact2 = newMyContact2 + '<tr><td width=75 class=text><b>Website:</b></td><td class=text>'+website+'</td></tr>';
	newMyContact2 = newMyContact2 + '<tr><td width=75 class=text><b>Address:</b></td><td class=text>'+address+'</td></tr>';
	
	newMyContact2 = newMyContact2 + '</table></div></td>';
	
	//Right side agent image and company logo.	
	newMyContact2 = newMyContact2 + '<td width=97 bgcolor=#EFF2F4 valign=top align=center>';
	newMyContact2 = newMyContact2 + userimgsrc + '<p>';
	newMyContact2 = newMyContact2 + Agentcompanysrc;
	
	newMyContact2 = newMyContact2 + '</td></tr>';
		
	return newMyContact2;
	
}

function MyNeighborhood2(MLSLink,username,userimgsrc,Agentcompanysrc,Town,StateAbbr,StateID){

	MLSURL				= ""
	MyNewNeighborhood2	= "";
	userimgsrc			= "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
	Agentcompanysrc		= "<img class=win_agentimages src=./showimage.asp?" + Agentcompanysrc + ">"; 
	hidTown				= Town;

	if (MLSLink != ""){
		if ((MLSLink.indexOf("http")) == -1){
			MLSLink = "http://" + MLSLink + "/";
		}
		MLSURL	= MLSLink;
		//MLSLink	= '<a class=win_phone target=_blank href='+ MLSLink + '>';
		MLSLink = "<a href='javascript:SubmitMLSLink(document.frmMLS);' class='win_phone'>"
		
	}else{
		MLSLink = MLSLink + "<a href=javascript:Messsage() class='win_phone'>"
	}

	MLSLink = MLSLink + "View All Current Homes For Sale</a>"
	
	SchoolLink = "http://www.greatschools.net/city/" + Town + "/" + StateAbbr;
	SchoolLink = "<a target='_blank' href='" + SchoolLink + "' class='win_phone'>Research The School District</a>"
	
	//Town = "http://www.americantowns.com/" + StateAbbr + "/" + Town;
	Town = "Neighborhood/eAgentAmericanTowns.asp?stateabbr=" + StateAbbr + "&town=" + RemoveSpace(Town);
	if (StateID > 62){ //Neighbourhood for Canada
		Town = "http://www12.statcan.ca/english/census06/data/profiles/community/Index.cfm?Lang=E";
	}
	NeighborhoodLink = "<a target='_blank' href=" +Town+ " class='win_phone'>Free Neighborhood Information</a>"
	
	// 1st row (Offer) and form header
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<tr><td height=186 valign=top width=390 bgcolor=#E3EDF5>';	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<div id=win_myoffer_container>';
	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<form id=frmMLS name=frmMLS method=post>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<table border=0 cellpadding=3 cellspacing=0  align=center>';
	
	// form body
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<tr><td><br></td></tr>';
	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<input type=hidden id=hidTown name=hidTown value='+hidTown+'>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<input type=hidden id=hidStateAbbr name=hidStateAbbr value='+StateAbbr+'>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<input type=hidden id=hidMLSURL name=hidMLSURL value='+MLSURL+'>';
	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<tr><td class=text><img src=./images/iw-arrow.jpg>'+MLSLink+'<BR><BR></td></tr>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<tr><td class=text><img src=./images/iw-arrow.jpg>'+SchoolLink+'<BR><BR></td></tr>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<tr><td class=text><img src=./images/iw-arrow.jpg>'+NeighborhoodLink+'</td></tr>';
	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '</table>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '</form>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + '</div></td>';
	
	//Right side agent image and company logo.	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '<td width=97 bgcolor=#EFF2F4 valign=top align=center>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + userimgsrc + '<p>';
	MyNewNeighborhood2 = MyNewNeighborhood2 + Agentcompanysrc;
	
	MyNewNeighborhood2 = MyNewNeighborhood2 + '</td></tr>';
		
	return MyNewNeighborhood2;
	
}

function AboutMe2(AboutMe,username,userimgsrc,Agentcompanysrc){

	MyAboutMe2			= "";
	userimgsrc			= "<img alt='e-Agent:" + username + "' src=./showimage.asp?" + userimgsrc + ">";
	Agentcompanysrc		= "<img class=win_agentimages src=./showimage.asp?" + Agentcompanysrc + ">"; 

	forumurl = getDiscussionForumURL();

	if (AboutMe == ""){
		AboutMe = "<span class='win_phone'>Sorry, I have not had a chance to update this area...click here to join the <a target=_blank href="+forumurl+">discussion forum!</a> where you can ask questions regarding anything real estate related. </span>";
	}
	
	// 1st row (Offer) and form header
	MyAboutMe2 = MyAboutMe2 + '<tr><td height=186 valign=top width=390 bgcolor=#E3EDF5>';	
	MyAboutMe2 = MyAboutMe2 + '<div id=win_myoffer_container>';
	MyAboutMe2 = MyAboutMe2 + '<table border=0 cellpadding=3 cellspacing=0  align=center>';
	
	// form body
	MyAboutMe2 = MyAboutMe2 + '<tr><td><br><br></td></tr>';
	MyAboutMe2 = MyAboutMe2 + '<tr><td class=text>' + AboutMe + '</td></tr>';
		
	MyAboutMe2 = MyAboutMe2 + '</table></div></td>';
	
	//Right side agent image and company logo.	
	MyAboutMe2 = MyAboutMe2 + '<td width=97 bgcolor=#EFF2F4 valign=top align=center>';
	MyAboutMe2 = MyAboutMe2 + userimgsrc + '<p>';
	MyAboutMe2 = MyAboutMe2 + Agentcompanysrc;
	
	MyAboutMe2 = MyAboutMe2 + '</td></tr>';
		
	return MyAboutMe2;
	
}

function FooterLinks(agentid,territoryid){

	forumurl = getDiscussionForumURL();
	newFooter2 = "";
	
	//Footer links 
	newFooter2 = newFooter2 + '<tr><td colspan=3 align=center class=win_bottomlinks>';
	newFooter2 = newFooter2 + '<a target=_blank href="'+forumurl+'">discussion forums</a>  |  <a href=javascript:DisplayVideo(1,'+agentid+','+territoryid+',5);>video link</a>  |  <a href=javascript:open_popup("Emailthislink.asp?productid=0&agentid='+agentid+'&territoryid='+territoryid+'");>email this page</a>  |  <a href=javascript:open_popup("NeedHelp.asp?productid=0&agentid='+agentid+'&territoryid='+territoryid+'");>need help?</a>';
	newFooter2 = newFooter2 + '</td></tr>';
	
	newFooter2 = newFooter2 + '</table>';
	return newFooter2;

}



//]]>