/**
* Author 	- Tom Caflisch
* Site	 	- http://allthingswebdesign.com
* Title	 	- social
* Description 	- A jquery plugin that adds a sidebar on the left with a 6 social icons and a content area for each one
*/
(function($) {
	$.fn.social = function(callback) {
	
		var defaults = {
			
		};
		var options = null;
		var settings = $.extend({}, defaults, options);	
		
		
		
		var imgs = (
			'<li class="first"><a class="pic" href="#fb"><img src="http://10foldsolutions.com/do_not_remove/social-plugin-images/fb.png" alt="Facebook" /><img class="triangle" src="http://10foldsolutions.com/do_not_remove/social-plugin-images/triangle.png" /></a></li>'+
			'<li><a class="pic" href="#twit"><img src="http://10foldsolutions.com/do_not_remove/social-plugin-images/twit.png" alt="Twitter" /></a></li>'+
			'<li><a class="pic" href="#youtube"><img src="http://10foldsolutions.com/do_not_remove/social-plugin-images/youtube.png" alt="Youtube" /></a></li>'
		);
		
		/* other images:
			http://10foldsolutions.com/do_not_remove/social-plugin-images/linkedin.png
			http://10foldsolutions.com/do_not_remove/social-plugin-images/ta.png
			http://10foldsolutions.com/do_not_remove/social-plugin-images/yelp.png
		*/
		
		var content = (
			'<div class="contentArea visible" id="fb"><iframe src="http://www.facebook.com/plugins/activity.php?site=facebook.com/splashland&amp;width=280&amp;height=380&amp;header=true&amp;colorscheme=light&amp;font&amp;border_color&amp;recommendations=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:280px; height:380px;" allowTransparency="true"></iframe></div>'+
			'<div class="contentArea" id="twit"></div>'+
			'<div class="contentArea" id="youtube"><object width="300" height="200"><param name="movie" value="http://www.youtube.com/p/A86103DB024AAE69?version=3&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/p/A86103DB024AAE69?version=3&hl=en_US&fs=1" type="application/x-shockwave-flash" width="300" height="200" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>'
			
		);
		
		
		
		// dynamically add the twitter feed
		/*$.getScript("http://widgets.twimg.com/j/2/widget.js",function(){
		
		var makeTwitterWidget = function makeTwitterWidget() {
                
                	new TWTR.Widget({
                    		version: 2,
                    		type: 'profile',
                    		rpp: 4,
                    		interval: 6000,
                    		width: 250,
                    		height: 280,
                    		theme: {
                    		    shell: {
                    		        background: '#333333',
                    		        color: '#ffffff'
                    		        },
                    		    tweets: {
                    		        background: '#ffffff',
                    		        color: '#444444',
                        		    links: '#e02046'
                        		}
                    		},
                    		features: {
                    		    scrollbar: false,
                    		    loop: false,
                    		    live: false,
                    		    hashtags: true,
                    		    timestamp: true,
                    		    avatars: false,
                    		    behavior: 'all'
                    		}
                		})
                		.render()
                		.setUser('SplashlandWI')
                		.start();
		}*/
		
			// dynamically add the get social sidebar
			$('body').prepend('<div id="social"><div id="outer"><span><img src="http://10foldsolutions.com/do_not_remove/social-plugin-images/getSocial.png" alt="Get Social" />' +
				  	  '<ul id="icons"><li><img class="tiny" src="http://10foldsolutions.com/do_not_remove/social-plugin-images/fb.png" alt="Facebook" /></li>'+
				  	  '<li><img class="tiny" src="http://10foldsolutions.com/do_not_remove/social-plugin-images/twit.png" alt="Twitter" /></li></ul></span>'+
				  	  '</div><div id="inner"><div id="innest"><div id="message">Get Social with AmericInn!</div>'+
				  	  '<div id="close"><a id="closeB" href="#">X</a></div><ul class="idTabs">'+
				  	  imgs +'</ul>'+content +'</div></div></div>');
		
			
    		//});
         	
         	$('#twit').jTweetsAnywhere({
			username: 'SplashlandWI',
        		count: 4,
       		 	showTweetBox: { label: '<span style="color: #D1C7BA">Spread the word ...</span>' }
			
		});
		
		// pop the sidebar open a little when it is hovered over
		$('#social').live('hover', function() {
			var $lefty = $(this);
			$lefty.stop().animate({
				marginLeft: parseInt($lefty.css('marginLeft')) == -352 ? 
				-345 : -352
			}, 200);
		});

		// open the sidebar when it is clicked		
		$('#outer').live('click', function() {
			var $lefty = $('#social');
			$lefty.stop().animate({
				marginLeft: parseInt($lefty.css('marginLeft')) == 0 ? 
				(40 - $lefty.outerWidth()) : 0
			}, 200);
		});
		
		// send the sidebar back in when the close button is clicked
		$('#closeB').live('click', function() {
			var $button = $(this).parent('#social');
			$button.stop().animate({
				marginLeft: parseInt($button.css('marginLeft')) == 0 ? 
				-352 : 0
			}, 200);
		});
		
		 
		
		$('.pic').live('click', function(){
  			$('.contentArea').hide();
  			var clicked = $(this).attr('href');
  			//console.log($(this).attr('href'));
  			$(clicked).show();

  			$('.triangle').remove('img.triangle');
    			$(this).append('<img class="triangle" src="http://10foldsolutions.com/do_not_remove/social-plugin-images/triangle.png" />');
    			//console.log($(this).html());
    			return false	// prevent the page from scrolling
		});
		
		// puts the triangle on the first icon to start with
		//$('li.first .pic').append('<img class="triangle" src="triangle.png" />');
		//console.log($('li.first .pic').html());
		
		// creates the tabs using the plugin idTabs - http://www.sunsean.com/idTabs/
		/*$("ul.idTabs").idTabs({
			click: function() {
    				$('.triangle').remove('img.triangle');
    				$(this).append('<img class="triangle" src="triangle.png" />');
    				return true;
    			}
		});*/
    		
    		


		
		if(typeof callback == 'function'){
		  callback.call(this);
		}
		return this;
	}
	
})(jQuery)




