﻿/**
* Copyright (c) Miroslav Holec http://www.googleplus.mirecek.cz, 2011
*
* Designer and Get Started configurator  on http://www.googleplus.mirecek.cz
*
*/

function urlencode(str) {
    str = escape(str);
    str = str.replace('+', '%2B');
    return str;
}


function GPWidget(o) {
   
    // Initialize URL
    var url = "http://googleplus.mirecek.cz/API/GooglePlusWidget";
    var request_location = window.location.hostname;

    // Check variable state
    if (typeof o.uid != 'undefined') {
        url += "?uid=" + o.uid;
    }

    if (typeof request_location != 'undefined') {
        url += "&req=" + request_location;
    }

    if (typeof o.showPhoto != 'undefined') {
        url += "&showPhoto=" + o.showPhoto;
    }

    if (typeof o.showStream != 'undefined') {
        url += "&showStream=" + o.showStream;
    }

    if (typeof o.showAbout != 'undefined') {
        url += "&showAbout=" + o.showAbout;
    }

    if (typeof o.headerBgBottom != 'undefined') {
        url += "&headerBgBottom=" + o.headerBgBottom;
    }

    if (typeof o.headerBgTop != 'undefined') {
        url += "&headerBgTop=" + o.headerBgTop;
    }

    if (typeof o.headerFont != 'undefined') {
        url += "&headerFont=" + o.headerFont;
    }

    if (typeof o.bodyBgBottom != 'undefined') {
        url += "&bodyBgBottom=" + o.bodyBgBottom;
    }


    if (typeof o.bodyBgTop != 'undefined') {
        url += "&bodyBgTop=" + o.bodyBgTop;
    }

    if (typeof o.bodyFont != 'undefined') {
        url += "&bodyFont=" + o.bodyFont;
    }

    if (typeof o.bodyHr != 'undefined') {
        url += "&bodyHr=" + o.bodyHr;
    }

    if (typeof o.bodyTitleFont != 'undefined') {
        url += "&bodyTitleFont=" + o.bodyTitleFont;
    }

    if (typeof o.buttonBgBottom != 'undefined') {
        url += "&buttonBgBottom=" + o.buttonBgBottom;
    }

    if (typeof o.buttonBgTop != 'undefined') {
        url += "&buttonBgTop=" + o.buttonBgTop;
    }

    if (typeof o.buttonFont != 'undefined') {
        url += "&buttonFont=" + o.buttonFont;
    }

    if (typeof o.radius != 'undefined') {
        url += "&radius=" + o.radius;
    }

    if (typeof o.theme != 'undefined') {
        url += "&theme=" + o.theme;
    }

    if (typeof o.headerText != 'undefined') {
        url += "&headerText=" + o.headerText;
    }

    if (typeof o.buttonText != 'undefined') {
        url += "&buttonText=" + o.buttonText;
    }


    if (typeof o.width != 'undefined') {
        url += "&width=" + o.width;
    }
    else {
        url += "&width=300";
        o.width = 300;
    }

    if (typeof o.height != 'undefined') {
        url += "&height=" + o.height;
    }
    else {
        url += "&height=100";
        if (o.showStream) {
            o.height = 320;
        } else {
            o.height = 103;
        }
        
    }

    // Show widget
    if (typeof o.uid != 'undefined') {
        document.write("<iframe src='" + encodeURI(url) + "' frameborder='0' scrolling='no' height='" + o.height + "' width='" + o.width + "'></iframe>");
    } else {
        document.write('<div><p>Google+ not found</p></div>');
    }


}
