var MouseOverMap = false
var tHandle;
function initialize(Lat, Long) {
	if (GBrowserIsCompatible()) {
		var marker;
		var map = new GMap2(document.getElementById("map_canvas"));
		marker = new GMarker(new GLatLng(Lat, Long));
		map.setCenter(new GLatLng(Lat, Long), 4);
		map.setMapType(G_HYBRID_MAP);	
		map.addOverlay(marker);
	}
}
function MouseOn(){
	MouseOverMap = true
}
function setTimeNow(){

	if (tHandle != 0)
		clearTimeout(tHandle);
	tHandle = setTimeout("setMapNotVisible()",1000);
}
function MouseOff(){
	MouseOverMap = false
	if (document.getElementById("test32").style.visibility == 'visible')
		setTimeNow()

}
function End(){
	HideMap();
	GUnload();
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = opacity / 100;
}

function ShowMap(Element, Lat, Long){
	initialize(Lat, Long);
	var Map = document.getElementById("test32");
	Map.style.top = (getY(Element)+ 30) + "px";
	Map.style.left = (getX(Element)+ 30) + "px";

	Map.style.opacity = 0
	Map.style.visibility = 'visible';

	opacity("test32", 0, 100, 500)
}
function HideMap(){
	var Map = document.getElementById("test32");	
	setTimeNow()
	
}

function setMapNotVisible(){
	tHandle = 0;
	if (MouseOverMap)
		return ;
	
	var Map = document.getElementById("test32");
	//alert("hey");
	Map.style.visibility = 'hidden';
	Map.style.top = "0px";
	Map.style.left = "0px";
	
}

function getY( oElement ){
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function getX( oElement ){
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
google.load("maps", "2"); 
