function loadRoute(company_id, lat, lng, address, titel) 
{
	if (GBrowserIsCompatible()) 
	{
		var dirMarker;
		var routepoints 	= [];
		
		var geocoder = new GClientGeocoder();	
		
		var map = new GMap2(document.getElementById("map_"+company_id));
		map.addControl(new GLargeMapControl3D());
		map.enableScrollWheelZoom();
		
		map.setCenter(new GLatLng(lat, lng), 16);
 
		var latlng = new GLatLng(lat,lng);
		var pointer = new GMarker(latlng,{title:titel});

		GEvent.addListener(pointer, "click", function() {
			var HTMLContent = jQuery.get("/includes/get_company_info.php", { company_id: company_id },
				function(data){
				    pointer.openInfoWindowHtml(data);
			});
		});
		
		map.addOverlay(pointer);

		gdir = new GDirections(map , document.getElementById("route")); 
		
		if(!address || address == "  ")
		{
			alert("Geen adres opgegeven");
			return false;
		}

		geocoder.getLatLng
		(
			address,
			function(point) 
			{
				if (!point) 
				{
					alert(address + " niet gevonden");
					return false;
				} 
				else 
				{
					if(dirMarker) { map.removeOverlay(pointer) };
					
					var dirIcon = new GIcon();
					dirIcon.image = "http://maps.google.com/intl/nl_ALL/mapfiles/icon_greenA.png";
					dirIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
					dirIcon.iconSize = new GSize(15, 23);
					dirIcon.shadowSize = new GSize(22, 23);
					dirIcon.iconAnchor = new GPoint(6, 23);
					dirIcon.infoWindowAnchor = new GPoint(5, 1);      					
					
					dirMarker = new GMarker(point, {title: 'Vertrekpunt', icon:dirIcon});
					map.addOverlay(dirMarker);
	
					homeLatLng 		= dirMarker.getPoint();
					destLatLng		= pointer.getPoint();
	
					routepoints[0] = address+"@"+homeLatLng.lat()+", "+homeLatLng.lng();
					routepoints[1] = pointer.getTitle()+" @"+destLatLng.lat()+", "+destLatLng.lng();
	
					gdir.load("from: "+routepoints[0]+" to:"+routepoints[1], { "locale": "nl","getPolyline": true, "getSteps": true });
				}
			}
		);
	}
}
function load_map(divId, lat, lng, adjustCSS) 
{
	if(divId == undefined || lat == undefined || lng == undefined) 
	{
		alert("Er is een fout opgetreden");
		return false;
	}
	

	if (GBrowserIsCompatible()) 
	{
		if(adjustCSS == undefined) {
			jQuery("#map_"+divId).css("height","250px");
		}
		
		var map = new GMap2(document.getElementById("map_"+divId));
		map.addControl(new GLargeMapControl3D());
		map.enableScrollWheelZoom();
		
		map.setCenter(new GLatLng(lat, lng), 16);
 
		var latlng = new GLatLng(lat,lng);
		var pointer = new GMarker(latlng);

		GEvent.addListener(pointer, "click", function() {
			var HTMLContent = jQuery.get("/includes/get_company_info.php", { company_id: divId },
				function(data){
				    pointer.openInfoWindowHtml(data);
			});
		});
		
		map.addOverlay(pointer);
	}
}

jQuery(document).ready(function($)
{
	Cufon.replace('.dealertitle, .action_star_cat, .category, .productinfo, h1, .blok_title h2, .subcategory, .adrestitle, .extranet_title, #action_star_popup', {fontFamily: 'din_bold'});

	Shadowbox.init({
		handleOversize:     'drag',
		resizeDuration:		0.35,
		fadeDuration:		0.10,
		overlayOpacity:		0.6,
		language:  	 		"nl",
		players:			["img"]
	});
	
	/* Documentatie */
	jQuery("#doc_category").change(function(){
		jQuery.getJSON("/cmsfiles/components/documentatie/get_products.php", {id:jQuery(this).val()}, function(products){
			var content = '<option>Maak een keuze...</option>';
		
			for(var i=0; i<products.length; i++){
				content += "<option value='"+products[i].id+"'>"+products[i].title+"</option>";
			}
			
			jQuery("#doc_product").html(content);
			jQuery("#doc_docs").html('');
		});
	});
	
	jQuery("#doc_product").change(function(){
		jQuery.ajax({
			url 	: "/cmsfiles/components/documentatie/get_docs.php", 
			data	: {id:jQuery(this).val()}, 
			success	: function(html){
				jQuery("#doc_docs").html(html);
			}
		});
	});
	
	meerkat({
		close: '.close',
		//dontShow: '.close',
		animation: 'slide',
		animationSpeed: 500,
		dontShowExpire: 0,
		meerkatPosition: 'bottom',
		background: 'url("/images/meerkat/bg.png") repeat 0 0',
		//background: '#f68f1e repeat 0 0',
		//background: '#626262 repeat 0 0',
		removeCookie: '#showAd',
		height: '280px'
	});
	
	jQuery('.assort_img').hover(					 
		function(){
			$(this).next().find("a").addClass('linkhover');
		}, function(){
			$(this).next().find("a").removeClass('linkhover');
		}
	);
	
	jQuery('.subcat_img').hover(					 
		function(){
			$(this).next().find("a").addClass('linkhover');
		}, function(){
			$(this).next().find("a").removeClass('linkhover');
		}
	);
	
	jQuery('.product_img').hover(					 
		function(){
			$(this).next().find("a").addClass('linkhover');
		}, function(){
			$(this).next().find("a").removeClass('linkhover');
		}
	);
	
});