// JavaScript Document
function sspToggleDisplayMode() {
	thisMovie("ssp").sspToggleDisplayMode();
}
function sspLoadAlbum() {
	thisMovie("ssp").sspLoadAlbum();
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	} else {
		return document[movieName]
	}
}
function fcheck(el) {
	var emailID=el.email;	
	if(el.name.value == "") { alert("Please enter your name."); el.name.focus(); return false; }
	else if((emailID.value==null)||(emailID.value=="")){ if(!emailID.disabled) { alert("Please Enter your Email Address"); emailID.focus(); return false; }}
	else if(echeck(emailID.value)==false){ emailID.value=""; emailID.focus(); return false; }
	//else if(el.feedback_type.value=="0"){ alert("Please Select a Feedback Type."); el.feedback_type.focus(); return false; }
	else if(el.comments.value=="") { alert("Please enter your comments."); el.comments.focus(); return false; }
}
function echeck(el) {
	var at="@";
	var dot=".";
	var lat=el.indexOf(at);
	var lel=el.length;
	var ldot=el.indexOf(dot);
	if (el.indexOf(at)==-1){ alert("Invalid E-mail Address"); return false; }
	if (el.indexOf(at)==-1 || el.indexOf(at)==0 || el.indexOf(at)==lel){ alert("Invalid E-mail Address"); return false; }
	if (el.indexOf(dot)==-1 || el.indexOf(dot)==0 || el.indexOf(dot)==lel){ alert("Invalid E-mail Address"); return false; }
	if (el.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail Address"); return false; }
	if (el.substring(lat-1,lat)==dot || el.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail Address"); return false; }
	if (el.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail Address"); return false; }
	if (el.indexOf(" ")!=-1){ alert("Invalid E-mail Address"); return false; }
}
var map = null;
var geocoder = null;
var baseIcon = null; 
var counter = 0; 
function init() {
	if (enableGmap && GBrowserIsCompatible()) {
		document.getElementById("map").className="map"
		map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(0,0), 11);
		map.addControl(new GSmallMapControl());
		geocoder = new GClientGeocoder();			
		baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		showAddress(address); 
	}
}
function showAddress(address) {
	if (geocoder) {
		map_zoom = 14; 
		for(i=0;i<address.length; i++) {
			geocoder.getLatLng(
			 address[i],
				function(point) {
					if (!point) {
					//alert(address[i] + " not found");
					} else {
					map.setCenter(point, map_zoom);
						/*var marker = new GMarker(point); map.addOverlay(marker);*/
						map.addOverlay(createMarker(point, i));
					}
				}
			);
		}
	}
}
function createMarker(point, index) {
  var letter = String.fromCharCode("A".charCodeAt(0)+counter);
  counter++; 
  var icon = new GIcon(baseIcon);
  icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
  var marker = new GMarker(point, icon);
  /*
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("Marker <b>" + letter + "</b>");
  });*/
  return marker;
}
window.addEvent('domready',function(){
	init(); 
}); 