//Show Details in Light Box
var DIV_EDIT_AREA;
function closex(){
	document.getElementById("EditArea").removeChild(DIV_EDIT_AREA);
	document.getElementById("EditArea").style.display='none';
	document.getElementById("hoverbox").style.display='none';
	//document.body.className="enable-scroll-bars";
}
function getTop(){
	if(window.innerHeight)
	return window.pageYOffset;
	
	if(document.documentElement && document.documentElement.scrollTop)
	return document.documentElement.scrollTop;
	
	if(document.body)
	return document.body.scrollTop;
}	
function ShowEditArea(html,left,top){
	
	DIV_EDIT_AREA=document.createElement('DIV');
	DIV_EDIT_AREA.innerHTML=html;
	document.getElementById("EditArea").innerHTML="<div align='right'><strong onclick='closex()' style='cursor:pointer' title='Close'>X</strong>&nbsp;</div>";
	document.getElementById("EditArea").appendChild(DIV_EDIT_AREA);
	document.getElementById("EditArea").style.left = (window.screen.width/2 - left)+"px";
	document.getElementById("EditArea").style.top = (getTop()+top)+"px";
	$("#EditArea:hidden:first").fadeIn("slow");

	//document.getElementById("EditArea").style.display='block';
	//document.body.className="disable-scroll-bars";
	//document.getElementById("hoverbox").style.display="block";
	$("#hoverbox:hidden:first").fadeIn("slow");
	heightwidth=getPageSizeWithScroll();
	
	document.getElementById("hoverbox").style.width=heightwidth[0]+20;
	document.getElementById("hoverbox").style.height=heightwidth[1]+40;
}
function getPageSizeWithScroll(){
	 if (window.innerHeight && window.scrollMaxY) {// Firefox
		 yWithScroll = window.innerHeight + window.scrollMaxY;
		 xWithScroll = window.innerWidth + window.scrollMaxX;
	 }
	 else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		 yWithScroll = document.body.scrollHeight;
		 xWithScroll = document.body.scrollWidth;
	 } 
	 else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		 yWithScroll = document.body.offsetHeight;
		 xWithScroll = document.body.offsetWidth;
	 }
	 arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	 //alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	 return arrayPageSizeWithScroll; 
}
//End

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

var map;
var myPano;   
var panoClient;
var nextPanoId;

function initialize(late,long) {
  var fenwayPark = new GLatLng(late,long);
  var fenwayPOV = {yaw:370.64659986187695,pitch:-20};
  
  panoClient = new GStreetviewClient();      
  
  map = new GMap2(document.getElementById("map_canvas"));
  map.setCenter(fenwayPark, 15);
  map.setUIToDefault();
  //map.addControl(new GLargeMapControl());

  GEvent.addListener(map, "click", function(overlay,latlng) {
	panoClient.getNearestPanorama(latlng, showPanoData);
  });
  
  myPano = new GStreetviewPanorama(document.getElementById("pano"));
  myPano.setLocationAndPOV(fenwayPark, fenwayPOV);
  GEvent.addListener(myPano, "error", handleNoFlash);  
  panoClient.getNearestPanorama(fenwayPark, showPanoData);
}


function handleNoFlash(errorCode) {
  if (errorCode == 603) {
	alert("Error: Flash doesn't appear to be supported by your browser");
	return;
  }
}  
