// --------------------------------- vars ---------------------------------

photo_border_width=1;
photo_border_color='#606060';

photo_padding_width=5;
photo_padding_color='white';

photo_speed=0.2;
photo_nifty_controls=1;

unloading = false;

var map;
var geo_lat = 0;
var geo_lon = 0;
var info = "";

// --------------------------------------------------------------------------

ie = /MSIE ((5\.5)|[678])/.test(navigator.userAgent);
win = navigator.platform == "Win32";

ie7 = navigator.appVersion.indexOf("MSIE 7.0") != -1;

function $(o) { return document.getElementById(o); }

function loadmap(city) {
	if (city == 'Brugge') {
		geo_lat = 51.218375;
		geo_lon = 3.213560;
		info = "Leopold II laan 24, Brugge";
	} else if (city == 'Gent') {
		geo_lat = 51.04148;
		geo_lon = 3.734181;
		info = "Gustaaf Callierlaan 74/001, Gent";
	} else if (city == 'Roeselare') {
		geo_lat = 50.93582;
		geo_lon = 3.120825;
		info = "Meensesteenweg 203, Roeselare";
	} else {
		geo_lat = 51.026038;
		geo_lon = 3.040091;
		info = "Wilgenlaan 39, Kortemark";
	}

	initiatemap();

	centermap();
	wait();
}

function initiatemap() {
	if (GBrowserIsCompatible()) {

		_mTerms = "Voorwaarden"; 
		_mMapError = "Er is een fout opgetreden. Zover kan Google Maps niet zoomen."; 
		_mSatelliteError = "Er is een fout opgetreden. Er zijn geen beelden beschikbaar."; 
		_mZoomIn = "Inzoomen"; 
		_mZoomOut = "Uitzoomen"; 
		_mZoomSet = "Klik om te zoomen"; 
		_mZoomDrag = "Sleep om te zoomen"; 
		_mPanWest = "Naar links"; 
		_mPanEast = "Naar rechts"; 
		_mPanNorth = "Naar boven"; 
		_mPanSouth = "Naar onder"; 
		_mTeleAtlas = "Tele Atlas"; 
		_mDataCopy = "Kaartgeg. &#169;2006 "; 
		_mMapCopy = "Kaartgeg. &#169;2006 "; 
		_mSatelliteCopy = "Beelden &#169;2006 "; 
		_mGoogleCopy = "&#169;2006 Google"; 
		_mKilometers = "kilometer"; 
		_mMiles = "miles"; 
		_mMeters = "meter"; 
		_mFeet = "feet"; 
		_mPreferMetric = true; 
		_mAutocompleteFrom = "van"; 
		_mAutocompleteTo = "naar"; 
		_mDecimalPoint = ","; 
		_mThousandsSeparator = "."; 

	      var contactmap = new GMap2(document.getElementById("map"));
		contactmap.addControl(new GSmallMapControl());
		contactmap.setCenter(new GLatLng(geo_lat,geo_lon), 14);

  		var point = new GLatLng(geo_lat,geo_lon);

		var icon = new GIcon();
		icon.iconSize = new GSize(50, 45);
		icon.iconAnchor = new GPoint(19, 45);
		icon.image = "/images/marker.png";

	  	var marker = new GMarker(point, icon);
		contactmap.addOverlay(marker);
	}
}

function centermap() {
	dv=document.getElementById("bigphotodiv");
	dv.style.width=400+(photo_padding_width*2+photo_border_width*2);
	dv.style.height=300+(photo_padding_width*2+photo_border_width*2);

	dv=document.getElementById("mapdiv");
	dv.style.width=document.getElementById("bigphotodiv").style.width;
	dv.style.height=document.getElementById("bigphotodiv").style.height;
	dv.style.backgroundColor=photo_padding_color;
	dv.style.borderColor=photo_border_color;
	dv.style.borderWidth=photo_border_width;
	dv.style.borderStyle="solid";

	dv=document.getElementById("map");
	dv.style.top=photo_padding_width+photo_border_width;
	dv.style.left=photo_padding_width+photo_border_width;

	dv=document.getElementById("infodivbg");
	dv.style.left=(photo_padding_width+photo_border_width);
	dv.style.width=400;
	dv.style.top=(photo_padding_width+photo_border_width)+277;

	dv=document.getElementById("infodiv");
	dv.style.left=(photo_padding_width+photo_border_width);
	dv.style.width=400;
	dv.style.top=(photo_padding_width+photo_border_width)+277;
	dv.innerHTML = info;

	dv=document.getElementById("closediv");
	dv.style.left=(photo_padding_width+1)+(400-(20-photo_border_width));
	dv.style.top=(photo_padding_width+1)+photo_border_width+3;

	dv=document.getElementById("bigphotodiv");
	h=document.body.clientHeight;
	t=document.body.scrollTop;
	w=document.body.clientWidth;
	l=document.body.scrollLeft;
	y=Math.floor(h/2-dv.offsetHeight/2+t);
	x=Math.floor(w/2-dv.offsetWidth/2+l);
	dv.style.top=y;
	dv.style.left=x;
	dv.style.zIndex = 10;
}

function fixcenter() {
	centermap();
}

function wait() {
	if (!unloading) {
		unloading = true;
		if (ie || 1==1) {
			pw = document.body.scrollWidth;
			ph = document.body.scrollHeight;
			cw = document.body.clientWidth;
			ch = document.body.clientHeight;
			sl = document.body.scrollLeft;
			st = document.body.scrollTop;
		}
		$('wait').style.width = pw;
		$('wait').style.height = ph;
		$('wait').style.zIndex = 8;
		$('wait').style.visibility = "visible";

		dv=document.getElementById("bigphotodiv");
		fadeIn("bigphotodiv",photo_speed);
	}
}

function unwait() {
	unloading = false;
	$('wait').style.visibility = "hidden";
}

function hidemap() {
	dv = document.getElementById("bigphotodiv");
	dv.style.visibility="hidden";
	unwait();
}

function fadeIn(whatdiv, speed) {
	if (document.all) {
		$(whatdiv).style.filter = "blendTrans(duration=" + speed + ")";
//		if ($(whatdiv).filters.blendTrans.status != 2) {
			$(whatdiv).filters.blendTrans.apply();
			$(whatdiv).style.visibility = "visible";
			$(whatdiv).filters.blendTrans.play();
//		}
	} else {
		$(whatdiv).style.opacity = 0;
		$(whatdiv).style.mozOpacity = 0;
		$(whatdiv).style.visibility = "visible";
		for (i = 0.1; i <= 1; i += 0.025) {
			window.setTimeout("$('" + whatdiv + "').style.opacity=" + i, i * 1000 * speed);
			window.setTimeout("$('" + whatdiv + "').style.mozOpacity=" + i, i * 1000 * speed);
		}
	}
}

function fadeOut(whatdiv,speed) {
	if (document.all) {
		$(whatdiv).style.filter = "blendTrans(duration=" + speed + ")";
//		if ($(whatdiv).filters.blendTrans.status != 2) {
			$(whatdiv).filters.blendTrans.apply();
			$(whatdiv).style.visibility = "hidden";
			$(whatdiv).filters.blendTrans.play();
//		}
	} else {
		$(whatdiv).style.opacity = 0;
		$(whatdiv).style.mozOpacity = 0;
		$(whatdiv).style.visibility = "visible";
		for (i = 0.1; i <= 1; i += 0.025) {
			window.setTimeout("$('" + whatdiv + "').style.opacity=" + (0.9 - i), i * 1000 * speed);
			window.setTimeout("$('" + whatdiv + "').style.mozOpacity=" + (0.9 - i), i * 1000 * speed);
		}
	}
}

document.write('<DIV ID="bigphotodiv" STYLE="position:absolute;left:-999;top:-999;visibility:hidden;z-index: 11;">');
document.write('<DIV ID="mapdiv" STYLE="position:absolute;left:0;top:0;"></DIV>');
document.write('<DIV ID="map" STYLE="position:absolute;width:400px;height:300px;left:0;top:0;">');
document.write('</DIV>');
document.write('<DIV ID="closediv" STYLE="position:absolute;width:15px;height:15px;left:0;top:0;">');
	document.write('<A HREF="javascript:hidemap()"><IMG SRC="/aanbod/icon_close.gif" WIDTH=15 HEIGHT=15 BORDER=0></A>');
document.write('</DIV>');
document.write('<DIV ID="infodivbg" STYLE="position:absolute;left:0;top:0;background:black;width:60px;height:23;padding-top:4;filter:alpha(opacity=90);-moz-opacity:90;opacity:90;"></DIV>');
document.write('<DIV ID="infodiv" STYLE="position:absolute;left:0;top:0;width:60px;color:white;text-align:center;height:23;padding-top:4;font-family:tahoma,arial;font-size:11px"></DIV>');
document.write('</DIV>');

window.onresize=fixcenter;