window.$FFC = function() {

	var $this = this;

	jQuery(document).ready(function() {

		jQuery(".masnoryGrid").css("clear", "both");
		$this.masonry(".masnoryGrid", ".grid_4");

		if($("#contactMapContainer").length)
		{
			$this.loadMapJS();
		}

	});

	$this.masonry = function(parent, box) {

		jQuery(parent).masonry({
			itemSelector : box
		});

	};

	$this.loadMapJS = function() {
		
		var googleMapsScript = document.createElement('script');
		googleMapsScript.type = 'text/javascript';
		googleMapsScript.src = 'http://maps.googleapis.com/maps/api/js?sensor=false&callback=initializeMap';
		document.body.appendChild(googleMapsScript);		
	
	}
	
	$this.initializeMap = function() {

		var latlng = new google.maps.LatLng(55.6008143283576, 13.000881671905518);
	
		var contactMapOptions = {
			zoom : 16,
			center : latlng,
			disableDefaultUI : true,
			panControl : false,
			zoomControl : true,
			mapTypeControl : false,
			scaleControl : false,
			streetViewControl : true,
			overviewMapControl : false,
			scrollwheel:false,
			mapTypeId : google.maps.MapTypeId.ROADMAP,
			styles : [{
				stylers : [{
					saturation : -100
				}]
			}]
		};
	
		var contactMap = new google.maps.Map(document.getElementById('contactMapContainer'), contactMapOptions);
		
		var parserOptions = {
			map:contactMap,
			zoom:false,
			markerOptions: {flat:true,optimized:true,clickable:true,title:'Lorem ipsum'},
			processStyles:true
		};
		
		var myParser = new geoXML3.parser(parserOptions);
		myParser.parse('http://www.firstflight.se/googlemaps/contactmap.xml');		
				
	}	
	
	
}();

