$(document).ready(function()
{
	$(".menuItem:not(.selected)").mouseover(function()
	{
		$(this).toggleClass('active');
	});
	
	$(".menuItem:not(.selected)").mouseout(function()
	{
		$(this).toggleClass('active');
	});
	
	$(".houseTypeTabs > li").click(function()
	{
		if (this.id == 'kaart')
        {
            window.location = '/23/Kaart.html';
            return false;
        }
		if ($("#homeSearchForm"))
		{
			$("#searchType").attr('value', this.id);
			$("#homeSearchForm").attr('action', '10/Home.html');
			$("#homeSearchForm").submit();
		}
		
		$(this).siblings().removeClass('tabOrange');
		$(this).siblings().addClass('tabBlue');
		$(this).removeClass('tabBlue');
		$(this).addClass('tabOrange');
		
		$(this).siblings().children(".floatLeft").attr('src', 'images/tabBlueLeft.jpg');
		$(this).siblings().children(".floatLeft").attr('height', '35');
		$(this).siblings().children(".floatRight").attr('src', 'images/tabBlueRight.jpg');
		$(this).siblings().children(".floatRight").attr('height', '35');
		
		$(this).children(".floatLeft").attr('src', 'images/tabOrangeLeft.jpg');
		$(this).children(".floatLeft").attr('height', '36');
		$(this).children(".floatRight").attr('src', 'images/tabOrangeRight.jpg');
		$(this).children(".floatRight").attr('height', '36');
		$("#searchType").attr('value', this.id);
		
		$("#searchForm").submit();
	});
	
	$('#topPhotos ul').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '135px'
	});
	
	setAutoComplete("street", "results", "streets.php?part=");
	
	
	$('#pageTabs > ul > li').click(function()
	{
		$id = this.id;
		$(this).siblings().removeClass('active');
		$(this).addClass('active');
		$('#pageContent').css("visibility", "visible");
		$('#pageContent').show();
		$('#pageContent').html('<img src="images/loading.gif" width="25" height="25" alt="Loading..." style="vertical-align:middle"/>').load('getContent.php?id=' + $id);
	});
	
	$id = $("#idPage").attr("value");
	$('#pageContent').load('getContent.php?id=' + $id);
	
	$('#houseTabs > ul > li').click(function()
	{
		$(this).siblings().removeClass('active');
		$(this).addClass('active');
		if (this.id == 'route')
		{
			$('#houseContentStreetviewSmall').css("top", "-2000px");
			$('#houseContentRouteSmall').css("top", "-2000px");
			if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '7')
			{
				$('#houseContentStreetview').css("top", "669px");
				$('#houseContentRoute').css("top", "369px");
			}
			else
			{
				$('#houseContentStreetview').css("top", "651px");
				$('#houseContentRoute').css("top", "351px");
			}
			
			$('#houseContent').css("visibility", "hidden");
			if (!window.XMLHttpRequest) 
			{	
				$('#houseContent').html('Google Maps is not available in Internet Explorer 6');
			}
		}
		else
		{
			$('#houseContent').css("visibility", "visible");
			$('#houseContentRoute').css("top", "-2000px");
			$('#houseContentStreetview').css("top", "-2000px");
			$('#houseContentRouteSmall').css("top", "-2000px");
			$('#houseContentStreetviewSmall').css("top", "-2000px");
			if (this.id == 'overview')
			{
				if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '7')
				{
					$('#houseContentStreetviewSmall').css("top", "816px");
					$('#houseContentRouteSmall').css("top", "632px");
				}
				else
				{
					$('#houseContentStreetviewSmall').css("top", "798px");
					$('#houseContentRouteSmall').css("top", "614px");
				}
				
				$('#houseContent').html('Google Maps is not available in Internet Explorer 6');
				
			}
			
			
			$('#houseContent').show();
			$('#houseContent').html('<img src="images/loading.gif" width="25" height="25" alt="Loading..." style="vertical-align:middle"/>').load('getTab.php?function=' + this.id + '&id=' + $id, function()
			{
				$('a[rel=lightbox]').colorbox();
                $(".youtubeBox").colorbox({iframe:true, innerWidth:425, innerHeight:344});

                $('#detailFotos li img').click(function()
                {
                    $('#bigPicture').attr('src', $(this).attr('id'));
                });
			});
		}
	});
	$id = $("#idHouse").attr("value");
	$('#houseContent').load('getTab.php?function=overview&id=' + $id);
	
 });
 
 
function addOption(value, text, id)
{
	var thisValue = value;
	var thisText  = text;
	var thisOpt   = document.createElement('option');
	thisOpt.value = thisValue;
	thisOpt.appendChild(document.createTextNode(thisText));
	$("#" + id).append(thisOpt);
}

function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }
    }  

function showAddress(map,geocoder,address,html, postalcode, i) {
	geocoder.getLatLng(
	address,
	function(point) {
		if (!point && i < 1) {
			showAddress(map, geocoder, postalcode, html, postalcode, 1);
		} else {
		    var icon = [];
            icon[0] = new GIcon();
            icon[0].image = "http://www.goethvastgoed.nl/images/markerGoeth.png";
            icon[0].shadow = "http://www.goethvastgoed.nl/images/shadowGoeth.png";
            icon[0].shadowSize = new GSize(37,34);
            icon[0].iconSize = new GSize(20,34);
            icon[0].iconAnchor = new GPoint(10,17);
            icon[0].infoWindowAnchor = new GPoint(10,17);
			map.setCenter(point, 15);
			var marker = new GMarker(point,{'icon': icon[0]});		
			map.addOverlay(marker);
			map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
		}
	});
}

function openTab(tab)
{
	$this = tab;
	$('#' + $this).siblings().removeClass('active');
	$('#' + $this).addClass('active');
	
	
	if ($this == 'route')
	{
		$('#houseContentRouteSmall').css("top", "-2000px");
		$('#houseContentStreetviewSmall').css("top", "-2000px");
		if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '7')
		{
			$('#houseContentStreetview').css("top", "669px");
			$('#houseContentRoute').css("top", "369px");
		}
		else
		{
			$('#houseContentStreetview').css("top", "651px");
			$('#houseContentRoute').css("top", "351px");
		}
		$('#houseContent').css("visibility", "hidden");
		if (!window.XMLHttpRequest) 
		{	
			$('#houseContent').html('Google Maps is not available in Internet Explorer 6');
		}
	}
	else
	{
		$('#houseContent').css("visibility", "visible");
		$('#houseContentRoute').css("top", "-2000px");
		$('#houseContentRouteSmall').css("top", "-2000px");
		$('#houseContentStreetviewSmall').css("top", "-2000px");
		if ($this == 'overview')
		{
			if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '7')
			{
				$('#houseContentStreetviewSmall').css("top", "816px");
				$('#houseContentRouteSmall').css("top", "632px");
			}
			else
			{
				$('#houseContentStreetviewSmall').css("top", "798px");
				$('#houseContentRouteSmall').css("top", "614px");
			}
			$('#houseContent').html('Google Maps is not available in Internet Explorer 6');
			$('#houseContent').css("height", "615px");
		}
		
		
		$('#houseContent').show();
		$('#houseContent').html('<img src="images/loading.gif" width="25" height="25" alt="Loading..." style="vertical-align:middle"/>').load('getTab.php?function=' + $this + '&id=' + $id, function()
		{
			$('a[rel=lightbox]').colorbox();
            $(".youtubeBox").colorbox({iframe:true, width:'700', height:'700'});
            $('#detailFotos li img').click(function()
            {
                $('#bigPicture').attr('src', $(this).attr('id'));
            });
		});
	}
}

function react()
{
	window.open('/reageer.php?id=' + $id,'React','width=450,height=500,scrollbars=no,toolbar=no');
}