/*(function(jQuery){
    //  inspired by DISQUS
    jQuery.oauthpopup = function(options)
    {
        options.windowName = options.windowName ||  'ConnectWithChanceo'; // should not include space for IE
        options.windowOptions = options.windowOptions || 'location=0,status=0,width=800,height=600';
        options.callback = options.callback || function(){ window.location.reload(); };
        var that = this;

        that._oauthWindow = window.open(options.path, options.windowName, options.windowOptions);
        that._oauthInterval = window.setInterval(function(){
            if (that._oauthWindow.closed) {
                window.clearInterval(that._oauthInterval);
                options.callback();
            }
        }, 1000);
    };
})(jQuery);

function redirect(){
	document.location='http://www.chanceo.com/prive';
}
*/
$(function()
{
    var comet =
    {
        popup: null,  
        newPopup: function(url, w, h)
        {
            this.popup = window.open(url, url, 'width=' + w + ',height=' + h);
            var self = this;
          
            this.popup.onload = function ()
            {
              var doc = this.document,
              script = doc.createElement('script');
              script.src = 'http://www.chanceo.com/prive/js/jquery.js';
              script.onload = function ()
              {
                  function setup()
                  {
                      $('#logout').click(function () { alert('It worked!'); });
                  }
                  
                  script = doc.createElement('script');
                  script.textContent = "(" + setup.toString() + ")();";
                  doc.body.appendChild(script);
              };
              
              doc.head.appendChild(script);
            };
        },
  
        foo: function()
        {
            this.newPopup('http://www.chanceo.com/oauth2/index.php', 800, 500);
        }
    };

    $('a[name="google"]').live('click',function ()
    {
        comet.foo();
    });
});
