/*
	jQuery OneFBLike v1.0 - http://www.onerutter.com/onefblike
	Copyright (c) 2010 Jake Rutter
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

(function($){  
    $.fn.extend({
        addLikeButton: function(options) {  
        
            //Set the default values, use comma to separate the settings 
            var defaults = {  
            	appID: '150004761743231',
            	siteTitle: '',
            	siteName: '',
            	siteImage: '',
            	buttonWidth: 80,
            	buttonHeight: 30,
            	showfaces: false,
            	font: 'arial',
            	layout: 'button_count',
            	action: 'like',
            	colorscheme: 'light',
            	channelUrl  : 'http://www.haustiere-info.de/js/fb.html'
            };  
            
            var options =  $.extend(defaults, options);  
                        
            return this.each(function() {  
                var o = options;  
                var obj = $(this);
                
                // Add Meta Tags for additional data - options
                jQuery('head').append('<meta property="og:title" content="'+o.siteTitle+'"/>');
                jQuery('head').append('<meta property="og:site_name" content="'+o.siteName+'"/>');
                jQuery('head').append('<meta property="og:image" content="'+o.siteImage+'"/>');
                
                // Add #fb-root div - mandatory - do not remove
                jQuery('body').append('<div id="fb-root"></div>');
                
                // setup FB Developers App Link - do not touch
                window.fbAsyncInit = function() {
				FB.init({appId: o.appID, status: true, cookie: true, xfbml: true});
				};
				(function() {
				var e = document.createElement('script'); e.async = true;
				e.src = document.location.protocol +
				'//connect.facebook.net/de_DE/all.js';
				document.getElementById('fb-root').appendChild(e);
				}());


                // Grab the URL and assign it to a variable
                var dynUrl = document.location;
                var fbDIV = obj;
                                
                              
                // Apply the like button to an element on the page and include all available options
                // If no options are passed in from the page, the defaults will be applied            
                jQuery(fbDIV).html('<fb:like href="'+dynUrl+'" width="'+o.buttonWidth+'" height="'+o.buttonHeight+'" show_faces="'+o.showfaces+'" font="'+o.font+'" layout="'+o.layout+'" action="'+o.action+'" colorscheme="'+o.colorscheme+'"/>');

                              
            });  
        },
       
        
        


        addFaceBox: function(options) {  
            
            //Set the default values, use comma to separate the settings 
            var defaults = {  
            	appID: '150004761743231',
            	pageurl: 'Infoportal-Haustiere/126985584049021',
            	width: '300',
            	height: '260'
            	
            };  
            
            var options =  $.extend(defaults, options);  
                        
            return this.each(function() {  
                var o = options;  
                var obj = $(this);
                
                // Add Meta Tags for additional data - options
                jQuery('head').append('<meta property="og:title" content="'+o.siteTitle+'"/>');
                jQuery('head').append('<meta property="og:site_name" content="'+o.siteName+'"/>');
                jQuery('head').append('<meta property="og:image" content="'+o.siteImage+'"/>');
                
                // Add #fb-root div - mandatory - do not remove
                jQuery('body').append('<div id="fb-root"></div>');
                
                // setup FB Developers App Link - do not touch
                window.fbAsyncInit = function() {
				FB.init({appId: o.appID, status: true, cookie: true, xfbml: true});
				};
				(function(d){
	                  var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
	                  js = d.createElement('script'); js.id = id; js.async = true;
	                  js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1";
	                  d.getElementsByTagName('head')[0].appendChild(js);
	                }(document));


                // Grab the URL and assign it to a variable
                var dynUrl = document.location;
                var fbDIV = obj;
                                
                              
                // Apply the like button to an element on the page and include all available options
                // If no options are passed in from the page, the defaults will be applied            
                jQuery(fbDIV).html('<div class="fb-like-box" data-href="http://www.facebook.com/pages/'+o.pageurl+'" data-width="'+o.width+'" data-height="'+o.height+'" data-show-faces="true" data-stream="false" data-header="false"></div>');
                
                /*
                <script>(function(d){
                  var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                  js = d.createElement('script'); js.id = id; js.async = true;
                  js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1";
                  d.getElementsByTagName('head')[0].appendChild(js);
                }(document));</script>
                <div class="fb-like-box" data-href="http://www.facebook.com/pages/Infoportal-Haustiere/126985584049021" data-width="230" data-height="220" data-show-faces="true" data-stream="false" data-header="false"></div>
                </div>
                */
                              
            });  
        }, 
    addPlus1Button: function(options) {  
            
            //Set the default values, use comma to separate the settings 
            var defaults = {  
            	size: 'medium'
            };  
            
            var options =  $.extend(defaults, options);  
                        
            return this.each(function() {  
                var o = options;  
                var gDIV = $(this);        
                jQuery(gDIV).html('<g:plusone size=\"'+o.size+'\"></g:plusone>');

                              
            });  
        }, 
        
    addTwitterButton: function(options) {  
            
            //Set the default values, use comma to separate the settings 
            var defaults = {  
            	via: 'iph'
            };  
            
            var options =  $.extend(defaults, options);  
                        
            return this.each(function() {  
                var o = options;  
                var tDIV = $(this);        
                jQuery(tDIV).html('<a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-via=\"'+o.via+'\" data-count=\"horizontal\" data-lang=\"de\">Tweet</a>');

                              
            });  
        }
    }); 
})(jQuery);
