<!--

var lats = new Array();
var longs = new Array();
var addr_txts = new Array();
var baseIcon ;
var index =0;
var map;

/*
Function echeck is used to verify if the given value is a possible valid email address.
This function thus simply makes sure the email address has one (@), atleast one (.).
It also makes sure that there are no spaces, extra '@'s or a (.) just before or after the @.
It also makes sure that there is atleast one (.) after the @.
*/

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(" ")!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

 	return true
}


function validate()
{
	//alert("here!");

	var validationsOK = false;

	if (frm_email.value == "" ){
				alert("Please specify email.");
				frm_email.focus();
				return false;
		}

		if (!echeck(frm_email.value)) {
				alert("You specified an invalid email address");
				frm_email.focus();
				return false;
	}

	if (frm_addr.value == "" ){
		alert("Please specify address.");
		frm_addr.focus();
		return false;
	}
	else if(
		(frm_city.value == "") &&
		(frm_state.value == "") &&
		(frm_zip.value == "")
		)
	{
		alert("Please specify city/state/zip.");
		frm_city.focus();
	}
	else
		validationsOK = true;

	//alert(validationsOK);
	//return false;

	return validationsOK;
}

function show_view(lat,long){

	var my_url = "st_view.php?l="+lat+"&g="+long;

	var myWindow = window.open(my_url,"MLS","status,menubar,resizable,scrollbars,copyhistory,left=100,height=320,width=520");
	myWindow.focus();
}

function show_sales(){
	//var myWindow = window.open("sales.php","MLS","status,menubar,resizable,scrollbars,copyhistory,left=100,height=600,width=750");
	
	var myWindow = window.open(google_url,"MLS","status,menubar,resizable,scrollbars,copyhistory,left=100,height=600,width=750");

	myWindow.focus();
}

function show_charts(){
	var myWindow = window.open(charts_url,"MLS","status,menubar,resizable,scrollbars,copyhistory,left=80,height=650,width=600");
	myWindow.focus();
}

function show_print(){
	var myWindow = window.open(print_url,"MLS","status,menubar,resizable,scrollbars,copyhistory,left=50,height=650,width=700");
	myWindow.focus();
}

function initialize()
{

	var elixir_office = new GStreetviewPanorama(document.getElementById("elixir_office"));
	  elixirPlace = new GLatLng(lats[0],longs[0]);
	  myPOV = {yaw:370.64659986187695,pitch:-20};
	  elixir_office.setLocationAndPOV(elixirPlace, myPOV);
  	GEvent.addListener(elixir_office, "error", handleNoFlash);

}


function handleNoFlash(errorCode) {
  if (errorCode == 603) {
	alert("Error: Flash doesn't appear to be supported by your browser");
	return;
  }
}

function createMarker(point, addr_text,tndx,mcolor) {

	//var marker = new GMarker(point);

	//tndx = tndx+1;

	baseIcon.image = "images/icons/" + mcolor + "/marker" + tndx + ".png";

//alert(baseIcon.image);

	// Set up our GMarkerOptions object
	var markerOptions = { icon:baseIcon };
  	var marker = new GMarker(point, markerOptions);

	GEvent.addListener(marker, "click",
		function() {
		marker.openInfoWindowHtml(addr_text);
		});
	return marker;
}

function draw_map(my_color) {

  if (GBrowserIsCompatible()) {

	map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());

	// Create a base icon for all of our markers that specifies the shadow, icon dimensions, etc.
	baseIcon = new GIcon(G_DEFAULT_ICON);

	baseIcon.image = "images/icons/house.png";

	var center = new GLatLng(lats[0],longs[0]);
	//Zoom levels between 0 (the lowest zoom level, in which the entire world can be seen on one map) to 19 (the highest zoom level, down to individual buildings) are possible within the normal maps view.
	map.setCenter(center, 14);
	//var pmarker = new GMarker(center);
	var markerOptions = { icon:baseIcon };
  	var pmarker = new GMarker(center, markerOptions);

	map.addOverlay(pmarker);
	GEvent.addListener(pmarker, "click",
			function() {
			pmarker.openInfoWindowHtml(addr_txts[0]);
	});

	//0->principal, 1-last ->comparables.
	for (i=1;i<lats.length;i++)
	{
			//alert(i + lats[i] + " " + longs[i]);
			var point = new GLatLng(lats[i], longs[i]);
			//map.addOverlay(new GMarker(point));
			map.addOverlay(createMarker(point, addr_txts[i],i,my_color));
	}
  }
  else
	alert('Not compatible browser');

}//draw_map

function set_color(color){
	map.clearOverlays();
	draw_map(color);
}

-->
