/* Author: 
	Chris Barrow / archivestudio.co.uk
*/

$(function()
{
	$('#container').fadeIn(1000);
	// Load twitter feed	
	$("#feed").getTwitter({
		userName: "represent_uk",
		numTweets: 9,
		loaderText: "",
		slideIn: true,
		slideDuration: 250,
		showHeading: false,
		showProfileLink: false,
		showTimestamp: true
	});
	
	setTimeout(function()
	{
		$('#splash').fadeOut(1000);
	},3000);
	
	if( navigator.userAgent.match(/Android/i) ||
 		navigator.userAgent.match(/webOS/i) ||
 		navigator.userAgent.match(/iPhone/i) ||
 		navigator.userAgent.match(/iPod/i)){
 		// some code
	
	} else {
		$('#location').click(function(e)
	{
		e.preventDefault();
		$('#container').fadeOut(1000,function()
		{
			$('#map-wrapper').fadeIn(1000);
			loadMap();
		});
	});
	}
	
	$('#close').click(function()
	{
		$('#map-wrapper').fadeOut(1000,function()
		{
			$('#container').fadeIn(1000);
		});
	});
	
	$(window).resize(function()
	{
		var h = $(this).height();
		var ch = 700;
		var mt = (h / 2 - (ch / 2));
		if(mt < 0) mt = 0;
		$('#container').css('margin-top',mt+'px');
	});
	
	$(window).trigger('resize');
});

var loadMap = function()
{
	geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 14,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    
    map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
        
	var address = '5 Back Hill London EC1R 5EN';
	geocoder.geocode( { 'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			map.setCenter(results[0].geometry.location);
			
			// icon
			var image = 'images/marker.png';
			//var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
			var beachMarker = new google.maps.Marker({
				position: results[0].geometry.location,
				map: map,
				icon: image
			});
			/*
			var marker = new google.maps.Marker({
				map: map, 
				position: results[0].geometry.location
			});*/
		} else {
			alert("Geocode was not successful for the following reason: " + status);
		}
    });
}





















