

window.glamMetricsData = 'pubId=' + encodeURIComponent(window.glam_affiliate_id ? window.glam_affiliate_id : '66873240')
   + '&pv=' + encodeURIComponent(window.atakoOrd ? window.atakoOrd : (window.GlamGetPageViewIdN ? window.GlamGetPageViewIdN() : 0))
   + '&sess=' + encodeURIComponent(window.GlamGetSessionId ? window.GlamGetSessionId() : 0)
   + '&adId=' + encodeURIComponent(window.atakoCurrentAdId ? window.atakoCurrentAdId : 4281)
   + '&idType=' + encodeURIComponent(window.atakoCurrentIdType ? window.atakoCurrentIdType : (window.atakoCurrentAdId ? 'd' : 'i'))
   + '&adTile=' + encodeURIComponent(window.GlamGetAdTile ? window.GlamGetAdTile() : 0);
if (window.GlamGetGeoData) {
    window.glamMetricsData += '&cc=' + encodeURIComponent(window.GlamGetGeoData("country_code")) + "&rc=" + encodeURIComponent(window.GlamGetGeoData("region_code"));
}
if (window.glamMetricsExtra) {
    window.glamMetricsData += window.glamMetricsExtra;
}



// The Sphere Related Content App 1 (404507758)
if (window.atakoH && atakoH[0] == '..') {
 //no-op
} else {
  if (!window.atakoH)
     window.atakoH = location.href.substr(location.href.indexOf('#') + 1).split('&');
  if (atakoH[0] == '..') { 
    try {
      parent.parent.gadgets.rpc.receive(atakoH);
    } catch (e) {
        if (window.console) console.log("receive failed " + e);
    }        
  } else {          
if (!window.glamGadgets) {
    
    document.write("<div id='gadgetsRpcAnchor'></div>");
    document.write("<scr" + "ipt type='text/javascript' src='http://www24.glam.com/shindig/gadgets/js/pubsub:glam.ads:glam.metrics?c=1'></scr" + "ipt>");
    
    document.write("<scr" + "ipt type='text/javascript' src='http://www24.glam.com/shindig/gadgets/files/container/cookies.util.opt.js'></scr" + "ipt>");
    document.write("<scr" + "ipt type='text/javascript' src='http://www24.glam.com/appdir/resources/gadgets.opt.js'></scr" + "ipt>");


    window.glamGadgets = [];
}

window.glamGadgets.push(function() {
    var gadgetParams = {specUrl: 'http://www25.glam.com/files/gadget-store/404507758/sphere_glam_gadget-v00-030.xml', 
        //debug : 1,
        extUrl: 'http://apps.glam.com/appdir/gadget-store/404507758/sphere_glam_gadget-v00-030.xml'};

    var appParams = '';
    if (appParams) { //sent by container.requestNavigateTo
        var viewParams = {};
        var pairs = appParams.split('&');
        for (var i=0; i<pairs.length; i++) {
          var pair=pairs[i].split('=');
          viewParams[pair[0]] = decodeURIComponent(pair[1]);
        }
        gadgetParams.viewParams = viewParams;
    }
        
    var gadget = gadgets.container.createGadget(gadgetParams);
    gadget.setServerBase("http://www24.glam.com/shindig/gadgets/");
    gadget.rpcRelayUrl = "http://www24.glam.com/rpc_relay.html";
    gadget.secureToken = escape("48326960::404507758:shindig:http%3A%2F%2Fapps.glam.com%2Fappdir%2Fgadget-store%2F404507758%2Fsphere_glam_gadget-v00-030.xml:547061");
    gadget.appId = 404507758;
    gadget.userId = '';
    gadget.installId = 4281;
    gadget.installedUserPrefs = {"$name":"The Sphere Related Content App 1","$width":"650","$height":"500"};
    gadget.height = 500;
    gadget.width = 650;
    gadget.viewOrigin = '';
    gadget.canvasUrl = 'http://www24.glam.com/appdir/resources/canvas.html';
    gadget.configUrl = 'http://www24.glam.com/appdir/resources/config.html';
    gadget.gsUrl = "http://www24.glam.com/appdir";
    gadget.mid = "547061";
    gadget.isConfig = "";
    gadget.developerId = 339028225;
    gadget.publisherId = 66873240;
    gadget.view = "profile";
    gadget.hashData = glamMetricsData; // XXX not safe
    
    gadget.hasInline = '1';
    gadget.inlineContent = '<div>\n\n\n<script>\n\n url = new String(escape(window.location));\n try{\n if(!sphere_layout){\n     sphere_layout = "twocolumn";\n  }}catch(anErr){ sphere_layout = "twocolumn"; }\n\n try{\n  if(!sphere_template){\n     sphere_template = "default";\n  }}catch(anErr){ sphere_template = "default"; }\n\n try{\n  if(!sphere_theme){\n     sphere_theme = "glam-default";\n  }}catch(anErr){ sphere_theme = "glam-default"; }\n\n  var themeQueryStr = "&template=" + sphere_template + "&layout=" + sphere_layout + "&theme=" + sphere_theme;\n\ndocument.write(\'<scr\'+\'ipt type="text/javascript" src="http://www.surphace.com/widgets/sphereit/js?siteid=glam_glmgadget&url=\'+url+themeQueryStr +\'"   charset="utf-8"></scr\'+\'ipt>\');\n</scri'+'pt>\n\n\n\n\n<!-- START SPHERE INLINE -->\n<!-- <form><input type="text" id="adUrlOutput" /></form> -->\n\n<div class="sphereInline" id="sphereInline" style="font-size:10px;">\n\n<script>var MODULE_ID = \'547061\';</scri'+'pt>\n\n<script charset="utf-8" src="http://www.surphace.com/partner/glam/glam_gadget.js" type="text/javascript"></scri'+'pt>\n\n</div>\n\n\n</div>';
    

    gadgets.container.addGadget(gadget);
    gadgets.container.layoutManager.addGadgetChromeId(gadget.id, 'gadget-679296913');

    var p = gadgets.container.gadgetService.getUrlForView(gadget.id, 'popup');
    if (p) { gadget.popupUrl = p; }

    gadgets.container.renderGadget(gadget);
});

var Atako = {};
Atako.renderGadget = function () {
  try {
    for (var i=0; i<window.glamGadgets.length; i++) {
        window.glamGadgets[i].call();
    }
  } catch (e) {
    if (window.console) console.log('error rendering gadget ' + e); 
  }
  window.glamGadgets = [];
};

document.write("<div id='gadget-679296913' class='gadgets-gadget-chrome'>&nbsp;</div>");

} }
