var mapParams;

function getIECanvas()
{
  var canv = null;
  if (!window.opera && document.all && typeof document.body.clientWidth != "undefined")
  {
	 var cm = document.compatMode && document.compatMode == "CSS1Compat";
	 canv = cm ? document.documentElement : document.body;
  }
  return canv;
}

function getWinWidth()
{
  var canv;
  if ( canv = getIECanvas() )
	 return canv.clientWidth - 5 ;
  else
	 return window.innerWidth - 18 - 5 ;
}

function getWinHeight()
{
  var canv;
  if (canv = getIECanvas())
	 return canv.clientHeight - 18 ; 
  else
	 return window.innerHeight - 18 ;
}

function getScrollX()
{
  var canv;
  if (canv = this.getIECanvas())
	 return canv.scrollLeft;
  else if (window.pageXOffset)
	 return window.pageXOffset;
  else if (window.scrollX)
	 return window.scrollX;
  else
	 return 0;
}

function getScrollY()
{
  var canv;
  if (canv = this.getIECanvas())
	 return canv.scrollTop;
  else if (window.pageYOffset)
	 return window.pageYOffset;
  else if (window.scrollY)
	 return window.scrollY;
  else
	 return 0;
}

function getAll()
{
  this.getWinWidth();
  this.getWinHeight();
  this.getScrollX();
  this.getScrollY();
}

function Mapinitialize(params, canvas_id) 
{   
	mapParams = params;
	var str = getURL();
	if(str.indexOf("map") > -1)
	{
		document.getElementById("lnkMapClose").focus();
		var url = window.location.href ;
		obj = mapParams ;
		var GLat = obj.split("&")[0];
		var GLng = obj.split("&")[1];
		var Title = obj.split("&")[2];
		while(Title.indexOf("%20") > 0 )
		{
			Title = Title.replace("%20"," ");
		}
		
		if(getWinWidth() > 0 )
		{	
			var divMapTitle = document.getElementById("divMapTitle"); 
			divMapTitle.innerHTML = "Google Map - " + getTitle();
			document.getElementById(canvas_id).style.height = parseInt(getWinHeight() - 122 - 40) + "px";
			if (GBrowserIsCompatible()) 
			{      
				var map = new GMap2(document.getElementById(canvas_id));   
				map.setCenter(new GLatLng(GLat, GLng), 13);    
				var latlng = new GLatLng(GLat, GLng);
				
				var point = new GLatLng(GLat,GLng);
				
				var marker = new GMarker(point);
				GEvent.addListener(marker, "click", function () {
				  marker.openInfoWindowHtml(Title);
				});
				map.addOverlay(marker);
				
				map.addControl(new GLargeMapControl());
				
				var mapControl = new GMapTypeControl();
				map.addControl(mapControl);	
				
				map.enableScrollWheelZoom();
			}
		}
	}
	else
	{
		window.history.go(-2);
	}
}

function getTitle(param)
{
   	obj = mapParams;
	var map ;
	var GLat = obj.split("&")[0];
    var GLng = obj.split("&")[1];
	Title = obj.split("&")[2];
	while(Title.indexOf("%20") > 0 )
	{
		Title = Title.replace("%20"," ");
	}
	return Title ;
}
