/*
Включване на Google +1 бутон и/или Facebook Like бутон
Възможности: 
1. Добавя социалните бутони без да забавя зареждането на страницата - зареждат се асинхронно с JS
2. Запазва валиден XHTML, като се ползва
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

Използване: 
1. Включва се този файл в head частта с
<script src="/google_facebook.js" type="text/javascript"></script>

2. В този файл реда
var aID = '231628888547';
се променя с ID на вашето Facebook приложение.

3. Там където трябва да се покажат бутоните се пише
<div id="fb-root"></div><script type="text/javascript">showGF(true,true);</script>
първи параметър на showGF() включва Google +1 бутон, втория включва Facebook Like бутон за текущата страница.

4. Тагът html трябва да има следните атрибути
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">

5. В head частта се добавят meta таговете
<meta property="og:title" content="Заглавие на текущата страница" />
<meta property="og:type" content="website" />
<meta property="og:url" content="URL на текущата страница" />
<meta property="og:image" content="Изображение тип лого" />
<meta property="og:site_name" content="Заглавие на сайта" />
<meta property="fb:app_id" content="ID на Facebook приложение" />
<meta property="fb:admins" content="ID на администратор" />
<meta property="og:description" content="Описание на текушата страница"/>


Автор: Георги Стефанов
Сайт: http://ganbox.com
*/

function showGF(google,facebook) { 

    var lang = 'bg';
    var loc = 'bg_BG'; /* може да бъде us_US */
    var fwidth = '640'; /* ширина на полето на Facebook бутоните */
    var aID = '231628888547'; /* ID на Facebook приложение */
    var ss = true; /* дали да се показва бутон Изпрати */
    var sf = true; /* дали да се показват аватари на харесалите страницата */

    if(google){      
        var c = document.createElement('script');
        c.src = document.location.protocol + '//apis.google.com/js/plusone.js'; 
        c.innerHTML = '{lang: \''+lang+'\'}';
        c.async = true; 
        document.getElementById('fb-root').appendChild(c); 

        var g = document.createElement('g:plusone');
        g.async = true;
        document.getElementById('fb-root').appendChild(g); 
    }

    if(facebook){

        window.fbAsyncInit = function() { 
            FB.init({ 
              appId  : aID, 
              status : true, 
              cookie : true, 
              xfbml  : true  
            }); 
        };

        var e = document.createElement('script'); 
        e.src = document.location.protocol + '//connect.facebook.net/'+loc+'/all.js'; 
        e.async = true; 
        document.getElementById('fb-root').appendChild(e); 

        var f = document.createElement('fb:like');
        f.setAttribute('show_faces', sf);
        f.setAttribute('send', ss);
        f.setAttribute('width', fwidth);
        f.setAttribute('font', 'tahoma');
        f.async = true;
        document.getElementById('fb-root').appendChild(f); 
    }

}

function likeBox(){
    var loc='bg_BG';
    var pageID = '129621312785';
    var pageName = 'http://www.facebook.com/ganboxcom';
    var bwidth = '278';
    var bheight = '325';
    var sf = true;
    var stream = false;
    var header = true;

    var e = document.createElement('script'); 
    e.src = document.location.protocol + '//connect.facebook.net/'+loc+'/all.js#xfbml=1'; 
    e.async = true; 
    document.getElementById('likebox').appendChild(e); 

    var f = document.createElement('fb:like-box');
    f.setAttribute('href', pageName);
    f.setAttribute('width', bwidth);
    f.setAttribute('height', bheight);
    f.setAttribute('show_faces', sf);
    f.setAttribute('border_color', '');
    f.setAttribute('stream', stream);
    f.setAttribute('header', header);
    f.setAttribute('colorscheme', 'light');
    f.async = true;
    document.getElementById('likebox').appendChild(f); 
}

