$(window).ready(function() {
	setIconen();
	$(window).bind('resize', function() { setIconen(); });
	$(window).bind('scroll', function() { setIconen(); });
});

function setIconen() {
	if ($('#divIconen').length > 0) {
		heightMenu = ($('#divMenu').position().top + $('#divMenu').height() + 50);
		iconenTop = (($(window).height() - $('#divIconen').height()) + $(window).scrollTop());

		if (iconenTop < heightMenu) {
			iconenTop = heightMenu;
		}

		$('#divIconen').css('top', iconenTop);
	}
}

function TopObjects(sVisibility)
{
	switch (sVisibility)
	{
		case "visible":
			$('select').show();
			$('object').show();
			break;

		case "hidden":
			$('select').hide();
			$('object').hide();
			break;
	}
}

function showInschrijfUitleg(Stap, Titel)
{
	style = "height=400, width=500, status=yes, toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=no";
	open("/inschrijvingen/Help.aspx?Stap=" + Stap, "HelpPopup", style );
}

function aHover(aTag, style)
{
	aTag.className = style
}

function aNormal(aTag)
{
	aTag.className = ''
}

function getBase() {
    var baseTag = document.getElementsByTagName("base");
    if (baseTag[0] == undefined)
        return "";
    else
        return baseHref = baseTag[0].href;
}

function googleStreetview(adres) {
	width = 900;
	height = 600;
	style = "height=" + height + ",width=" + width + ", status=no, toolbar=no, menubar=no, location=no, scrollbars=no, resizable=no";
	window.open("/Woonbedrijf/Woningaanbod/Streetview.aspx?Adres=" + adres, "_blank", style);
}

function showGoogleStreetview(address) {
	var gGeocoder = new GClientGeocoder();

	gGeocoder.getLatLng(
				address,
				function(position) {
					if (position == null) {

						alert('Adres niet gevonden.');
						window.close();

					} else {

						var gStreetView = new GStreetviewClient();
						gStreetView.getNearestPanoramaLatLng(
							position,
							function(camera) {
								if (camera == null) {
									alert('Er zijn geen Google Streetview beelden beschikbaar voor deze locatie.');
									window.close();
								} else {
									var bearing = LatLon.bearing(camera.lat(), camera.lng(), position.lat(), position.lng());
									var pov = { yaw: bearing };
									var gStreetViewPanorama = new GStreetviewPanorama($('#GoogleStreetView')[0]);
									gStreetViewPanorama.setLocationAndPOV(camera, pov);
								}
							}
						)
					}
				}
			);
}