/*!
 * GG Network Recommendation JavaScript Library v1.0
 * http://www.gadu-gadu.pl/polec/help
 *
 * Copyright 2010
 */

function gg_share_widget() {
    
	gg_share = (arguments.length ? arguments[0] : {});

    if (!gg_share.title || typeof gg_share.title != 'string')
       gg_share.title = document.title;

    if (!gg_share.url || typeof gg_share.url != 'string')
	   gg_share.url = escape(window.location.href);

    var gg_share_location = 'http://www.gadu-gadu.pl/polec?';
    var gg_share_button   = 'http://www.gadu-gadu.pl/polec/img/button_share_[type].png';
       
    if (!gg_share.button_type || !(typeof gg_share.button_type == 'string'))
	   gg_share.button_type = 'small'; 
        
    gg_share_button = gg_share_button.replace('[type]', escape(gg_share.button_type));

    /**
     params
      - url
      - title
      - desc[opt]
      - icon[opt]
      - image[opt]
    **/

    for(i in gg_share) {
        if (typeof gg_share[i] == 'string' && gg_share[i] != 'button_type')
             gg_share_location += encodeURIComponent(i) + '=' + encodeURIComponent(gg_share[i]) + '&'; 
    }  
    if (typeof gg_share.same_window !== 'undefined' && gg_share.same_window === '1') {
        document.write('<a href="' + gg_share_location + '"><img src="' + gg_share_button + '" style="border: 0px" /></a>');
    } else {
        var clickCallback;
        if (typeof gg_share.onclick == 'function') {
            clickCallback = gg_share.onclick;
        } else {
            clickCallback = function () {
                window.open(gg_share_location, 'share', 'height=435,width=626,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
                return false;
            };
        }
        var linkId = 'gg_share_link_' + Math.floor(Math.random() * 10000);
        document.write('<a id="' + linkId + '" href="' + gg_share_location + '"><img src="' + gg_share_button + '" style="border: 0px" /></a>');
        document.getElementById(linkId).onclick = clickCallback;
    }
}


    
        
    
