﻿// Switch panesl between sign-in/sign-up
function CInUpS(v)
{
    if (v)
    {
        $('#SignInDiv').hide();
        $('#SignUpDiv').show();
    }
    else
    {
        $('#SignInDiv').show();
        $('#SignUpDiv').hide();
    }
    return false;
}


// Select all checkboxes under id and set checked to s
function SelTweep(id, s)
{
    $("#" + id + " INPUT[type='checkbox']").attr('checked', s);
    return false;
}

// Resize the curent iframe height
function RIFrame(id)
{
    $("#" + id, parent.document.body).height($(document.body).height() + 30);
    parent.scrollTo(0, 9999);
}

function SI(i)
{
    var h = $("#" + i).html();
    h = h.replace(" target=\"_tab\"", "");
    h = h.replace(" target=_tab", "");
    $("#" + i + "i").val(h);
}

var _oauthw = null;
function DoOAuth()
{
    // Open the window to do Twitter OAuth
    var h = '' + document.location.href;
    try
    {
        var argl = 'directories=no,location=no,menubar=0,status=no,titlebar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=800';
        //var argl = 'directories=no,location=yes,menubar=1,status=no,titlebar=no,toolbar=yes,resizable=no,scrollbars=no,height=400,width=800';
        _oauthw = window.open('/oauthgo.aspx', null, argl);
        if (_oauthw)
        {
            _oauthw.focus();
            if (!_oauthw.opener)
                _oauthw.opener = window;
        }
    }
    catch (e)
    {
        _oauthw = null;
    }
    if (_oauthw == null)
    {
        // Pop-up blocker caught it?
        //alert('A new browser window couldn\'t be created. Your browser or a Pop-up blocker prevented it.');
        document.location.href = '/oauthgo.aspx?r=' + encodeURIComponent(h);
    }
    
    return false;
}

var _opbFire = null; // button to fire on post-back
function DoOAuthPB()
{
    // After twitter redirect to us we call this function
    if (_opbFire)
    {
        $('#' + _opbFire).click();
    }
    if (_oauthw != null)
    {
        _oauthw.close();
        _oauthw = null;
    }
}

