function setMapZoom(map, markers)
{
    var bounds = new GLatLngBounds;
    for (var i=0; i<markers.length; i++) 
    {        
        bounds.extend(markers[i]);
    }
    map.setZoom(map.getBoundsZoomLevel(bounds) - 1);    
    map.setCenter(bounds.getCenter());
}

function createPoint(markerArray, map, lat, lng, woningtype, bestandsnaam, gemeente, straatnaam, huisnummer, rekenhuur, woningid)
{                    		        	  
    if(lat && lng)
    {
        point = new GLatLng(lat,lng);
        markerArray.push(point);                    		                                 		                         
        map.addOverlay(createMarker(point, woningtype, bestandsnaam, gemeente, straatnaam, huisnummer, rekenhuur, woningid)); 		                
        
    }          		      
}

function createMarker(point, woningtype, bestandsnaam, gemeente, straatnaam, huisnummer, rekenhuur, woningid)
{
    
    if(bestandsnaam.length > 0)
    {  
    }
    else
    {
        bestandsnaam = '/uploads/imageNotFound.png.90x90.png';        
    }
 
    var marker = new GMarker(point, createIcon());
    GEvent.addListener(marker,
                       "mouseover",
                       function()
                       {
                            marker.openInfoWindowHtml("<div class='total_container'><div class='popupWoningWindow'><a href='/woningaanbod/woningaanbod/details/"+woningid+"'><img src='"+bestandsnaam+"'/></a></div><div class='woning_details'><a href='/woningaanbod/woningaanbod/details/"+woningid+"'><div class='plaats'>"+gemeente+"</div><div class='locatiecontainer'><div class='straat'>"+straatnaam+"&nbsp;</div><div class='huisnummer'>"+huisnummer+"</div></div></a><div class='rekenhuur'>&euro;"+rekenhuur+"&nbsp;</div><div class='woningtype'>"+woningtype+"</div></div></div>");
                       });
    return marker;                      
}

function createIcon()
{
    var myIcon        = new GIcon(G_DEFAULT_ICON);
    myIcon.image      = "/images/huisje_oranje.png";
    myIcon.iconSize   = new GSize(34, 28)
    myIcon.shadow     = "";
    myIcon.iconAnchor = new GPoint(0,0);
    
    var markerOptions = {icon:myIcon};
    
    return markerOptions;
}

function hidePan()
{
	document.getElementById('streetView').style.display = 'none';
	document.getElementById('sluitenknop').style.display = 'none';

}

function showPan()
{
	document.getElementById('streetView').style.display = 'block';
	document.getElementById('sluitenknop').style.display = 'block';
}

function imStreetViewControl() {}
 
	//subclass the GControl Object
imStreetViewControl.prototype = new GControl();
	 
	//create and style my button
imStreetViewControl.prototype.initialize = function(imGMapObj) 
{
	var streetViewBtn = document.createElement("div");
	streetViewBtn.style.textDecoration = "none";
	streetViewBtn.style.color = "#000000";
	streetViewBtn.style.backgroundColor = "white";
	streetViewBtn.style.font = "small Arial";
	streetViewBtn.style.fontSize = "11px";
	streetViewBtn.style.border = "1px solid black";
	streetViewBtn.style.padding = "1px";
	streetViewBtn.style.paddingBottom = "2px";
	streetViewBtn.style.marginBottom = "0px";
	streetViewBtn.style.textAlign = "center";
	streetViewBtn.style.width = "6em";
	streetViewBtn.style.cursor = "pointer";
		  
	streetViewBtn.appendChild(document.createTextNode("Street view"));
	GEvent.addDomListener(streetViewBtn, "click", function() 
		{  	 	
			showPan();
	 	}
	);
 
	imGMapObj.getContainer().appendChild(streetViewBtn);
	return streetViewBtn;
}

imStreetViewControl.prototype.getDefaultPosition = function() 
{
	if(navigator.appVersion.indexOf("MSIE 7.")!=-1 || navigator.appVersion.indexOf("MSIE 8.")!=-1)
		return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(252, 7));
	else
		return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(210, 7));
}
		

