// JavaScript Document

function loadSocial() {
    //I will assume that if we have one type of button we have them all
    //If not we'll just exit
    if ($(".twitter-share-button").length == 0) return;

    //Twitter
    if (typeof (twttr) != 'undefined') {
        twttr.widgets.load();
    } else {
        $.getScript('http://platform.twitter.com/widgets.js');
    }

    //Facebook
    if (typeof (FB) != 'undefined') {
        FB.init({ status: true, cookie: true, xfbml: true });
    } else {
        $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
            FB.init({ status: true, cookie: true, xfbml: true });
        });
    }
  
    //Linked-in
		
    if (typeof (IN) != 'undefined') {
        IN.parse();
    } else {
        $.getScript("http://platform.linkedin.com/in.js");
    }

    //Google - Note that the google button will not show if you are opening the page from disk - it needs to be http(s)
		
		
    if (typeof (gapi) != 'undefined') {
        $(".g-plusone").each(function () {
            gapi.plusone.render($(this).get(0) , {"mode":"insert", "size": "small"} );
        });
    } else {
        $.getScript('https://apis.google.com/js/plusone.js');
    }


		/*
		
    if (typeof (gapi) != 'undefined') {
        $(".g-plusone").each(function () {
					gapi.plusone.render("g-plusone", {"count": "true", "annotation":"inline" , "size": "standard" , "width":"200px" }); 
					
//        $("#g-plusone").each(function () {
//            gapi.plusone.render($(this).get(0), {"count": "true", "annotation":"inline" ,"size": "standard" , "width":"200px" });

        });
    } else {
        $.getScript('https://apis.google.com/js/plusone.js');
    }
		
		
		
		
//			gapi.plusone.render("g-plusone", {"googleanalytics":"true" , "googleanalytics_obj":"_gaq" , "mode":"insert" , "hideafterlike":"true" , "count": "true", "annotation" : "inline" , "size": "small" , "width" : "200" , "lang":"en-GB" });
		
		
		var gbuttons = $(".g-plusone");
		if (gbuttons.length > 0) {
				if (typeof (gapi) != 'undefined') {
						gbuttons.each(function () {
								gapi.plusone.render($(this).get(0));
						});
				} else {
						$.getScript('https://apis.google.com/js/plusone.js');
				}
		}
		*/
		
}

$(function () {
/* when the page has loaded, load the social links */
		loadSocial();
		
/* Now load the twitter feed  */
/* 
<!-- asynchronous loading of Twitter feed - does no depend on speed of Twitter --> 
<!--                
  type: 'search',
  search: 'coolest guy',
  interval: 6000,
  title: 'Matt Walker-Wilson',
-->
*/

		
		$.getScript('http://widgets.twimg.com/j/2/widget.js', function () {
				var twitter = new TWTR.Widget({
						version: 2,
						type: 'profile',
						id: "my_twitter_div",
						interval: 6000,
						title: 'Matt Walker-Wilson',
						subject: '',
						width: 210,
						height: 300,
						theme: {
								shell: {
										background: '#9AE4E8',
										color: '#000000'
								},
								tweets: {
										background: '#80CBE2',
										color: '#000000',
										links: '#0000cc'
								}
						},
						features: {
								scrollbar: false,
								loop: true,
								live: true,
								hashtags: true,
								timestamp: true,
								avatars: false,
								toptweets: true,
								behavior: 'default'
						}
				}).render().setUser('whoiscoolestguy').start();
		})

})


window.___gcfg = {lang: 'en-GB'};

(function() {
	var po = document.createElement('script'); 
	po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; 
	s.parentNode.insertBefore(po, s);
})();


