// Master Javascript file
//
// version:   1.0
// author:   Bryan Lademann
// email:     bryan@bryanlademann.com
// website:   http://www.bryanlademann.com

/*------------------------------------------*/

google.load("jquery", "1");
//google.load("jqueryui", "1");

google.setOnLoadCallback(function(){



// calls twitter feed and creates working links 
(function(jQuery){
jQuery.fn.lastTwitterMessage = function(username){
	
	var $base = this;
	if(!username || username == "") return this; // username required
	var url = "http://twitter.com/statuses/user_timeline.json?callback=?";
	jQuery.getJSON( url, { count: 10, screen_name: username },
	function(data){
	if(data && data.length >= 1){
	try{
	var item = null;
	for(var i = 0; i < data.length; i++){
	if(/^@/i.test(data[i].text)) continue;
	item = data[i]; break;
	}
	if(!item) return;
	var $tweet = $("<p></p> ").text(item.text);
	$tweet.html(
	$tweet.html()
	.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,'<a href="$1">$1</a>')
	.replace(/(^|\s)#(\w+)/g,'$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>')
	.replace(/(^|\s)@(\w+)/g,'$1<a href="http://twitter.com/$2">@$2</a>')
	)
	$tweet.append(" <br /><br /><a href='http://twitter.com/" + username + "'>Follow Deans Dugout on Twitter</a>&nbsp; ").wrapInner("<span>");
	$base.empty().append($tweet).show();
	} catch (e) { };
	};
	});
	return this; // Don't break the chain
	};
})(jQuery);


jQuery(function() {
	jQuery("<div id='tweet'></div>").hide().appendTo("#twitter")
	.lastTwitterMessage('deansdugout');
	jQuery('#twitter').append('<div id="pointer"></div>');
});


// Fancybox control
jQuery(function() {
	
	/* This is basic - uses default settings */

		jQuery("a#single_image").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
		});

		/* Using custom settings */

		jQuery("a#inline").fancybox({
			'hideOnContentClick': true
		});

		/* Apply fancybox to multiple items */

		jQuery("a.group").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
		});
		
		
		jQuery("a#video-link").fancybox({
			
			'speedIn'		:	600, 
			'speedOut'		:	200,
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'overlayShow'	: true,
			'overlayOpacity': 0.4,
			'overlayColor'  :'#000', 
			'title'			: this.title,
			'width'			: 480,
			'height'		: 295,
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
});

/*
// Loads map and adds marker by geocoding

var Map =
	{
		init: function()
		{
			Map.type1();
		},
		
        // Create an array and loop through the items and add them to the map
        type1: function()
        {
            var map = new GMap2(jQuery("#map").get(0));
            map.setCenter(new GLatLng(41.736246, -88.099571), 13);
            
            // Store the locations as a list of objects with a property for the name and
            // a property for the marker
            var locations = 
            [
                { name: "Deans' Dugout", marker: new GMarker(new GLatLng(41.736246, -88.099571)) }
              
            ];
            
            // Loop through the locations and add them to them map
            for(var i = 0; i < locations.length; i++)
            {
                var location = locations[i];			
                Map.addToMap(map, location.marker, location.name);
                
            }
        
        },
        
        
        // Use this function to add a marker to the map
	    addToMap: function(map, marker, name, gdir)
        {
            map.addOverlay(marker);
            GEvent.addListener(marker, "click", function()
            {
                jQuery.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=" + name + "&tagmode=any&format=json&jsoncallback=?",
                  function(data)
                  {
                   
                    var imageHtml = new Image();
                    
                    var imageWindow = jQuery("<div id='markerInfo'>" + name + "</div>").append(imageHtml).html();

                    map.openInfoWindowHtml(marker.getLatLng(),  imageWindow);
                  });
            

            });
        },
    }

jQuery(Map.init)

*/





});
