function CreateMarker( Lat, Lng, Type ) {
	var MarkerIcon;
	var Marker;
	var LatLng = new google.maps.LatLng(Lat, Lng);
	
	if( Type == 'CircleCenter' ) {
		MarkerIcon = CreateMarkerIcon( Type );
		Marker = new google.maps.Marker({
			icon: MarkerIcon,
	        position: LatLng, 
	        map: Map,
	        draggable: true,
	        raiseOnDrag: false
	    });
	} else {
		// default
		MarkerIcon = CreateMarkerIcon( Type );	
		Marker = new google.maps.Marker({
			icon: MarkerIcon,
	        position: LatLng, 
	        map: Map,
	        draggable: false
	    });
	}	
	
	return Marker;
}

function CreateMarkerFromPoint( LatLng, Type ) {
	var MarkerIcon;
	var Marker;
	
	if( Type == 'CircleCenter' ) {
		MarkerIcon = CreateMarkerIcon( Type );
		Marker = new google.maps.Marker({
			icon: MarkerIcon,
	        position: LatLng, 
	        map: Map,
	        draggable: true,
	        raiseOnDrag: false
	    });
	} else {
		// default
		MarkerIcon = CreateMarkerIcon( Type );	
		Marker = new google.maps.Marker({
			icon: MarkerIcon,
	        position: LatLng, 
	        map: Map,
	        draggable: false
	    });
	}	
	
	return Marker;
}

function CreateMarkerIcon( Type ) {
	var MarkerIcon;
	if( Type == 'CircleCenter' ) {
		MarkerIcon = new google.maps.MarkerImage(
				AbsPath + 'images/Map/CircleIcon.png', // url
				new google.maps.Size(20,20), // size
				new google.maps.Point(0,0), // origin
				new google.maps.Point(10,10) // anchor
		    );
	} else {
		// default
		MarkerIcon = new google.maps.MarkerImage(
				AbsPath + 'images/Map/Icon.png', // url
				new google.maps.Size(20,25), // size
				new google.maps.Point(0,0), // origin
				new google.maps.Point(10,25) // anchor 10,25
		    );
	}
	return MarkerIcon;
}

function DisplayProduct( ProductID ) {
	var Url = AbsPath + 'includes/Components/Map/Ajax.php';
	$.ajax({
		type: "POST",
		url: Url,
		data: {ID: ProductID, Action: 'ProductView'},
		dataType: "json",
		contentType: "application/x-www-form-urlencoded; charset=UTF-8;",
		timeout: 5000,
		error: function(){
			// nothing
		},
		success: function( Result ) {
			$( '#SearchCountry' ).hide();
			$( '#MapMessage' ).hide();
			$( '#MapProduct' ).show(); //alert(Result["Location"]);
			$( '#MapProduct' ).html(Result["Location"]);
			
			InitProductFunctions();
			//window.location = Result["Location"];
		}
	});	
}

function LocationProduct( ProductID ) {
	var Url = AbsPath + 'includes/Components/Map/Ajax.php';
	$.ajax({
		type: "POST",
		url: Url,
		data: {ID: ProductID, Action: 'Product'},
		dataType: "json",
		contentType: "application/x-www-form-urlencoded; charset=UTF-8;",
		timeout: 5000,
		error: function(){
			// nothing
		},
		success: function( Result ) {
			//window.open( Result["Location"], 'Accommodatie' );
			window.location = Result["Location"];
		}
	});	
}

function InitProductFunctions() {
	$('div.DisplayCountries').bind('click', function() {		
		HideProduct();
	});
}

function HideProduct() {
	$( '#MapProduct' ).hide();
	$( '#SearchCountry' ).show();
}
