// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function kmlogging(logined_log, nonlogined_log,params ){
	if (window.mrtweet_user){
    // KM.record (logined_log, params);
		// console.log (logined_log);
		// console.log (params);
	} else {
    // KM.record (nonlogined_log, params);
		// console.log (nonlogined_log);
		// 	console.log (params);	
	}
}


function update_counter(textarea, counter, submit_btn, padding)
{
  var val = $(textarea).value;
  var left = 140 - (padding || 0) - val.length;
  $(counter).update(left);
  if (left < 10) {
    $(counter).style.color = "#D0090D";
  } else if (left < 20) {
    $(counter).style.color = "#5C0002";
  } else {
    $(counter).style.color = "#AAAAAA";
  }
  if (submit_btn != null) {
    if ($(submit_btn) != null){
      if (left < 0) {
        $(submit_btn).next('.oopstoolong').show();
        $(submit_btn).disable();
        if ($(textarea).style.display == 'block') {
          $(textarea).focus();
        }
      } else {
        $(submit_btn).next('.oopstoolong').hide();
        $(submit_btn).enable();
        if ($(textarea).style.display == 'block') {
          $(textarea).focus();
        }
      }
    }
  }
}
function setCaretPosition(elemId, caretPos) {
  var elem = document.getElementById(elemId);

  if(elem != null) {
    if(elem.createTextRange) {
      var range = elem.createTextRange();
      range.move('character', caretPos);
      range.select();
    } else {
      if(elem.selectionStart != null) {
        if (elem.style.display == 'block') {
          elem.focus();
        }
        elem.setSelectionRange(caretPos, caretPos);
      } else {
        if (elem.style.display == 'block') {
          elem.focus();
        }
      }
    }
  }
}

// jQuery exist
if (window.jQuery) jQuery(function() {
  jQuery(".simple_see_more").live('click', function(event)
  {
  	event.preventDefault();
  	var jele = jQuery(this);
    var steps = parseInt(jele.attr('more_steps'));
    //var steps = jele.attr('more_steps');
    jele.parent().prev().children(":hidden").slice(0, steps).show();
    if (jele.parent().prev().children(":hidden").length == 0) {
      jele.hide();
    }
  });
  

  // thanks http://javascript.crockford.com/remedial.html
  String.prototype.supplant = function (o) {
    return this.replace(/{([^{}]*)}/g, function (a, b) {
      var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? escape_html(r) : a;
    });
  };
  // thanks http://javascript.crockford.com/remedial.html
  String.prototype.supplant_raw = function (o) {
    return this.replace(/{([^{}]*)}/g, function (a, b) {
      var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a;
    });
  };

  // extend jquery
  var old_jquery_submit = jQuery.fn.submit;
  jQuery.fn.extend({
    submit: function(callback) {
      if (! callback) {
        old_jquery_submit.apply(this, arguments);
      } else {
        old_jquery_submit.apply(this, [function(event) {
          if (event) event.preventDefault();
          // if we're already guarded, ignore this event
          if (! this.guarded) {
            this.guarded = (callback.apply(this, arguments) == false ? false : true);
            // if callback explicitly returned false, we'll adhere and set guarded=false
            // i.e. calling submit() again will invoke the callback again
          }
        }]);
      }
    },
    highlight: function(newColor, originalColor, callback_fn) {
      newColor = 'yellow';
      if (! originalColor) {
        var coloredElem = this;
        while (!originalColor && originalColor != 'transparent' && coloredElem) {
          originalColor = coloredElem[0].originalColor || coloredElem.css('background-color');
          coloredElem[0].originalColor = originalColor;
          coloredElem = coloredElem.parent();
        }
        originalColor = (originalColor && originalColor != 'transparent') ? originalColor : 'white';
      }
      return this.css({ backgroundColor: newColor }).animate( { backgroundColor: originalColor }, 500, callback_fn);
    }
  });

  var htmls = {
    some_html:
    "<form id='facebox_form' action='{form_url}' method='post'><input name='authenticity_token' type='hidden' value='{authenticity_token}' /><h3>{title_text}</h3><p>{subtitle_text}</p><p class='notice'></p><dl class='fields'><dt><label for='fb_session_username_or_email'>Username:</label><span></span></dt><dd class='username'><input type='text' id='fb_session_username_or_email' name='session[username_or_email]' value='{session_username_or_email}' /></dd><dt><label for='fb_session_password'>Password:</label><span></span></dt><dd><input type='password' id='fb_session_password' name='session[password]' value='' /></dd></dl><dl class='call_to_action'><dt><input class='btn_login_here' type='submit' value='Login Here' /> <a href='#' class='btn_goto_twitter'>or use OAuth</a></dt></dl></form>",
    login_and_confirm_action_html:
    "<form id='facebox_form' action='{form_url}' method='post'><input name='authenticity_token' type='hidden' value='{authenticity_token}' /><h3>Login to Twitter</h3><p>{subtitle_text}</p><p class='notice'></p><dl class='fields'><dt><label for='fb_session_username_or_email'>Username:</label><span></span></dt><dd class='username'><input type='text' id='fb_session_username_or_email' name='session[username_or_email]' value='{session_username_or_email}' /></dd><dt><label for='fb_session_password'>Password:</label><span></span></dt><dd><input type='password' id='fb_session_password' name='session[password]' value='' /></dd></dl><dl class='call_to_action'><dt><input class='btn_login' type='submit' value='Login' /></dt></dl></form>",
    likeus_html:
    "<dt class='likeus'><label><strong>Would you recommend MrTweet?</strong></label></dt><dt><label for='recommend_mrtweet_yes'><input type='radio' class='radiobutton' name='recommend_mrtweet' id='recommend_mrtweet_yes' value='1'>Sure!</label><label for='recommend_mrtweet_no'><input type='radio' class='radiobutton' name='recommend_mrtweet' id='recommend_mrtweet_no' value='0'>{no_text}</label></dt><dd class='reveal_recommend_mrtweet'><div class='recommend_mrtweet_yes' style='display: none;'><label for='recommend_mrtweet_tweet'><strong>Tweet this:</strong></label><textarea name='recommend_mrtweet_tweet'>{recommend_mrtweet_tweet}</textarea></div><div class='recommend_mrtweet_no' style='display: none;'><p class='theskyisfalling'>No worries, only do so when you find us useful! Let us know how we can help YOU make better connections!</p></div></dd><br/>",
    email_html:
    "<dt><label for='fb_session_email'>Email:</label><span></span></dt><dd><input type='text' value='' name='session[email]' id='fb_session_email'/></dd>",
    oauth_html:
    "<form id='facebox_form' action='{form_url}' method='post'><input name='authenticity_token' type='hidden' value='{authenticity_token}' /><h3>{title_text}</h3><p>{subtitle_text}</p><p class='notice'></p><dl class='fields'></dl><dl class='call_to_action'><dt><a href='#' class='btn_goto_twitter'><button class='twitter_connect' style='border:default'> Sign in to Twitter </button></a></dt></dl></form>"
  };

  jQuery.facebox.settings.overlay = false;

  jQuery('#facebox a.close').live('mouseup', function(){
    if(jQuery('#facebox #fb_session_username_or_email').length > 0){
		
	}
      
  });

  window.some_function = function(options, on_submit_fn, log){
    if (window.mrtweet_user) return on_submit_fn();
    jQuery.facebox(htmls.some_html.supplant({
      form_url: options.form_url || '/users/signon',
      authenticity_token: jQuery("input[name='authenticity_token']").val(),
      title_text: options.title_text || 'Login to Twitter',
      subtitle_text: options.subtitle_text || 'We will never reveal your credentials to 3rd parties.',
      session_username_or_email: options.session_username_or_email || 'username'
    }));

    var username = jQuery('#fb_session_username_or_email').val().strip();
    if (username == 'username' || username == '')
      jQuery('#fb_session_username_or_email').focus().select();
    else
      jQuery('#fb_session_password').focus().select();

    if(options.recommend_mrtweet_tweet){
      jQuery('#facebox_form dl.fields').append(htmls.likeus_html.supplant({
        no_text: options.recommended_mrtweet ? 'Nope' : 'Nope',
        recommend_mrtweet_tweet: options.recommend_mrtweet_tweet
      }));
    }

    if(options.recommended_mrtweet){
      jQuery('#facebox_form .fields p.theskyisfalling').css('background', 'url("/images/happy.png") no-repeat top left');
      jQuery('#facebox_form .fields p.theskyisfalling').html('No problem, thanks for your support. Remember to give us <a target="_blank" href="http://getsatisfaction.com/mrtweet/">feedback</a>!');
    }

    jQuery('#recommend_mrtweet_yes').click(function() {
      jQuery('.recommend_mrtweet_hidden').val('tweeted_yes');
      jQuery('.recommend_mrtweet_yes').show().select().focus();
      jQuery('.recommend_mrtweet_no').hide();
    });
    jQuery('#recommend_mrtweet_no').click(function() {
      jQuery('.recommend_mrtweet_hidden').val('tweeted_no');
      jQuery('.recommend_mrtweet_no').show();
      jQuery('.recommend_mrtweet_yes').hide();
    });
    jQuery('#facebox_form .btn_goto_twitter').unbind('click');

    if(options.email){
      jQuery('#facebox_form dl.fields').append(htmls.email_html);
    }

    function email_is_valid(){
      if(options.email && !jQuery('#fb_session_email').val().match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)) {
        jQuery('#fb_session_email').highlight().focus();
        return false;
      }
      return true;
    }

    function oauth_is_valid() {
      if(options.recommend_mrtweet_tweet && !jQuery('#recommend_mrtweet_yes:checked,#recommend_mrtweet_no:checked').val()){
        jQuery('.likeus').next('dt').add('.likeus').highlight();
        jQuery('#recommend_mrtweet_yes').focus();
        return false;
      }
      return true;
    }

    function form_is_valid() {
      if (! jQuery('#fb_session_username_or_email').val().strip()) {
        jQuery('#fb_session_username_or_email').highlight().focus();
        return false;
      }
      if (! jQuery('#fb_session_password').val().strip()) {
        jQuery('#fb_session_password').highlight().focus();
        return false;
      }
      if (! oauth_is_valid()) return false;
      if (! email_is_valid()) return false;
      return true;
    }

    jQuery('#facebox_form').submit(function(event) {
      event.preventDefault();
      if (! form_is_valid()) return false;
      jQuery('.btn_login_here').attr('disabled', 'true');
      var form = jQuery('#facebox_form');
      jQuery('#facebox_form .notice').hide();
      if(jQuery('#recommend_mrtweet_yes:checked').size() > 0)
        log += '.tweeted_yes';
      else if(jQuery('#recommend_mrtweet_no:checked').size() > 0)
        log += '.tweeted_no';
      function tweet_if_yes(){
        if(jQuery('#recommend_mrtweet_yes:checked').size() > 0){
          jQuery.post('/users/recommend_mrtweet', {
            authenticity_token: jQuery("input[name='authenticity_token']").val(),
            msg: jQuery('.recommend_mrtweet_yes textarea').val()
          });
        }
        window.mrtweet_user = true;
        if (window.on_mrtweet_user_true) { window.on_mrtweet_user_true.apply(that, args); }
      }
      var serialized = 'v=' + log + '&' + form.serialize();
      jQuery.post(form[0].action, serialized, function(json) {
        if (json && json.success) {
          tweet_if_yes();
          on_submit_fn(json);
        } else if (json && json.message) {
          jQuery('#facebox_form p').hide();
          jQuery('#facebox_form .notice').text(json.message).slideDown('fast');
          jQuery('.btn_login_here').removeAttr('disabled');
          return;
        }
      }, 'json');
      return false;
    });

    jQuery('#facebox_form .btn_goto_twitter').click(function(event) {
      event.preventDefault();
      if(! oauth_is_valid()) return false;
      jQuery(document).trigger('close.facebox');
      if(jQuery('#recommend_mrtweet_yes:checked').size() > 0)
        log = log.replace(/(\.tweeted_(yes|no))?$/, '.tweeted_yes');
      else if(jQuery('#recommend_mrtweet_no:checked').size() > 0)
        log = log.replace(/(\.tweeted_(yes|no))?$/, '.tweeted_no');
      function tweet_if_yes(json){
        if(jQuery('#recommend_mrtweet_yes:checked').size() > 0){
          jQuery.post('/submittweet', {
            authenticity_token: jQuery("input[name='authenticity_token']").val(),
            msg: jQuery('.recommend_mrtweet_yes textarea').val(),
            type: 'oauth'
          });
        }
        on_submit_fn(json);
      }
      oauth_and_confirm_action({}, tweet_if_yes, log);
    });
  };

  window.oauth_to_continue = function(options, on_submit_fn, log){
    if (window.mrtweet_user) return on_submit_fn();

	kmlogging ("FACEBOX_TO_CONTINUE_APPEAR_LOGINED",  "FACEBOX_TO_CONTINUE_APPEAR_NOT_LOGINED");

    jQuery.facebox(htmls.oauth_html.supplant({
      form_url: options.form_url || '',
      authenticity_token: jQuery("input[name='authenticity_token']").val(),
      title_text: options.title_text || 'Login to Twitter',
      subtitle_text: options.subtitle_text || ''
    }));

    if(options.recommend_mrtweet_tweet){
      jQuery('#facebox_form dl.fields').append(htmls.likeus_html.supplant({
        no_text: options.recommended_mrtweet ? 'Nope' : 'Nope',
        recommend_mrtweet_tweet: options.recommend_mrtweet_tweet
      }));
    }

    if(options.recommended_mrtweet){
      jQuery('#facebox_form .fields p.theskyisfalling').css('background', 'url("/images/happy.png") no-repeat top left');
      jQuery('#facebox_form .fields p.theskyisfalling').html('No problem, thanks for your support. Remember to give us <a target="_blank" href="http://getsatisfaction.com/mrtweet/">feedback</a>!');
    }

    jQuery('#recommend_mrtweet_yes').click(function() {
      jQuery('.recommend_mrtweet_hidden').val('tweeted_yes');
      jQuery('.recommend_mrtweet_yes').show().select().focus();
      jQuery('.recommend_mrtweet_no').hide();
    });
    jQuery('#recommend_mrtweet_no').click(function() {
      jQuery('.recommend_mrtweet_hidden').val('tweeted_no');
      jQuery('.recommend_mrtweet_no').show();
      jQuery('.recommend_mrtweet_yes').hide();
    });
    jQuery('#facebox_form .btn_goto_twitter').unbind('click');

    function oauth_is_valid() {
      if(options.recommend_mrtweet_tweet && !jQuery('#recommend_mrtweet_yes:checked,#recommend_mrtweet_no:checked').val()){
        jQuery('.likeus').next('dt').add('.likeus').highlight();
        jQuery('#recommend_mrtweet_yes').focus();
        return false;
      }
      return true;
    }

    function form_is_valid() {
      if (! oauth_is_valid()) return false;
      return true;
    }

    jQuery('#facebox_form .btn_goto_twitter').click(function(event) {
      event.preventDefault();
      if(! oauth_is_valid()) return false;
      jQuery(document).trigger('close.facebox');
      if(jQuery('#recommend_mrtweet_yes:checked').size() > 0)
        log = log.replace(/(\.tweeted_(yes|no))?$/, '.tweeted_yes');
      else if(jQuery('#recommend_mrtweet_no:checked').size() > 0)
        log = log.replace(/(\.tweeted_(yes|no))?$/, '.tweeted_no');
      function tweet_if_yes(json){
        if(jQuery('#recommend_mrtweet_yes:checked').size() > 0){
          jQuery.post('/submittweet', {
            authenticity_token: jQuery("input[name='authenticity_token']").val(),
            msg: jQuery('.recommend_mrtweet_yes textarea').val(),
            type: 'oauth'
          });
        }
        on_submit_fn(json);
      }
	  kmlogging ("FACEBOX_OAUTH_INIT_LOGINED",  "FACEBOX_OAUTH_INIT_LOGINED" , {"tweet":tweet_if_yes } );
      oauth_and_confirm_action({}, tweet_if_yes, log);
    });
  };

  window.login_and_confirm_action = function(options, on_submit_fn){
    if(window.mrtweet_user) return on_submit_fn();
    var prefilled_username = jQuery('#session_username_or_email').val();
    jQuery.facebox(htmls.login_and_confirm_action_html.supplant({
      form_url: options.form_url || '/users/signon',
      authenticity_token: jQuery("input[name='authenticity_token']").val(),
      session_username_or_email: options.prefilled_username || prefilled_username || window.signin_username,
      subtitle_text: options.subtitle_text || 'We will never reveal your credentials to 3rd parties.'
    }));
    function form_is_valid() {
      if (! jQuery('#fb_session_username_or_email').val().strip()) {
        jQuery('#fb_sessionoh w_username_or_email').highlight().focus();
        return false;
      }
      if (! jQuery('#fb_session_password').val().strip()) {
        jQuery('#fb_session_password').highlight().focus();
        return false;
      }
      return true;
    }
    jQuery('#facebox_form').submit(function(event) {
      event.preventDefault();
      if (! form_is_valid()) return false;
      var form = jQuery('#facebox_form');
      jQuery('#facebox_form .notice').hide();
      jQuery.post(form[0].action, form.serialize(), function(json) {
        if (json && json.success) {
          window.mrtweet_user = true;
          on_submit_fn(json);
        } else if (json && json.message) {
          jQuery('#facebox_form p').hide();
          jQuery('#facebox_form .notice').text(json.message).slideDown('fast');
          return;
        }
      }, 'json');
      return false;
    });
    jQuery(prefilled_username ? '#fb_session_password' : '#fb_session_username_or_email').focus();
  };

  // a tweaked version of "login_and_confirm_action"
  window.oauth_and_confirm_action = function(options, on_submit_fn, log) {
    if (window.mrtweet_user) return on_submit_fn();
    var that = this;
    window.oauth_success = function() {
      var args = arguments;
      window.mrtweet_user = true;
      if (window.on_mrtweet_user_true) setTimeout(function() { window.on_mrtweet_user_true.apply(that, args); }, 1000);
      on_submit_fn({user_name: args[0]});
    }
    window.open('/users/oauth_init?popup=1&log='+(log || 'login'), 'twitwin', 'location=0,status=0,width=800,height=450');
  };

  window.oauth_fail = function() {
    login_and_confirm_action({
      prefilled_username: 'username',
      subtitle_text: 'Looks like OAuth didn\'t work out. You can also login using your username and password.'
    }, function(){
      jQuery(document).trigger('close.facebox');
      window.location.reload();
    });
  };

//  window.on_mrtweet_user_true = function(json) {
//    name = json.username;
//    // re-render this page
//    path = window.location.href;
//    if (path.indexOf("?") < 0) {
//      path += "?";
//    } else {
//      path += "&";
//    }
//    path += "format=html";      // explicitly request html format
//// Synchronous page refresh before continuing
//    jQuery.ajax({
//      url: path,
//      success: function(html) {
//        // jQuery doesn't like to parse <html><body>..</body></html>.. so make it <div><div>...</div></div> instead!
//        var doc = jQuery(html.replace(/<(\/)?(html|body)/ig, '<$1div'));
//        // transplant innerHTML of specific DIVs into this page's matching DIVs
//        jQuery.each(["div.header", "div.sidebar", "div.bottombar"], function(index, css_class) {
//          var new_html = jQuery(css_class, doc).html();
//          jQuery(css_class, document).html(new_html);
//        });
//      },
//      async:false
//    });
////// Asynchronous page refresh
////    jQuery.get(path, function(html) {
////      // jQuery doesn't like to parse <html><body>..</body></html>.. so make it <div><div>...</div></div> instead!
////      var doc = jQuery(html.replace(/<(\/)?(html|body)/ig, '<$1div'));
////      // transplant innerHTML of specific DIVs into this page's matching DIVs
////      jQuery.each(["div.header", "div.sidebar", "div.bottombar"], function(index, css_class) {
////        var new_html = jQuery(css_class, doc).html();
////        jQuery(css_class, document).html(new_html);
////      });
////    });
//  }

  window.ajaxify_form_submit = function(form, message, format) {
    form.submit(function(event) {
      event.preventDefault();
      jQuery.post(form[0].action, form.serialize(), function(json) {
        jQuery.facebox('<form><h3>' + message + '</h3></form>');
      }, format);
    });
  }

	//redirect_previous

  jQuery('.btn_login').click(function(event){
    event.preventDefault();
    function redirect_to_dashboard(json){
      jQuery(document).trigger('close.facebox');
      returnUrl = json.return_url;

      if(returnUrl != null && returnUrl != ""){
        window.location.href = returnUrl;
      } else if(window.location.pathname == '/'){
        window.location.href = '/home';
//        window.location.pathname == '/signin'
      } else if(window.location.pathname.match(/\/community\//g)){
        window.location.reload();
      } else { window.location = '/redirect_previous'; }
    }
    some_function({
      title_text: 'Login to MrTweet',
      session_username_or_email: jQuery("input[name='expected_twitter_username']").val() || window.signin_username || 'username'
    }, redirect_to_dashboard, 'login');
  });

  jQuery(window).ready(function(){
    setTimeout(function(){
      jQuery('.personlisting img, .url_block img').each(function(){
		// alert(jQuery(this).attr('src'));
        if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) || this.readyState == 'uninitialized')
          jQuery(this).attr('src', '/images/imgnotfound.png');
      });
    }, 5000);
  });

  window.escape_html = function(string) {
    return string.
      replace(/&/g, '&amp;').
      replace(/>/g, '&gt;').
      replace(/</g, '&lt;').
      replace(/"/g, '&quot;').
      replace(/'/g, '&#39;');
  }

  window.Util = {
    time_ago: function(str) {
      function quantify(num, unit) { return parseInt(num) + " " + unit + (num >= 2 ? "s" : ""); }
      var diff_minutes = ((new Date()).getTime() - Date.parse(str)) / 1000 / 60;
      if (diff_minutes < 1) {
        return "moments ago";
      } else if (diff_minutes < 60) {
        return quantify(diff_minutes, "minute") + ' ago';
      } else if (diff_minutes < 1440) {
        return quantify((diff_minutes / 60), "hour") + ' ago';
      } else if (diff_minutes < 43200) {
        return quantify((diff_minutes / 1440), "day") + ' ago';
      } else {
        return quantify((diff_minutes / 43200), "month") + ' ago';
      }
    },
    // currently we invoke separate queries (via setTimeout) to search.twitter.com
    // can actually do join(' OR ') to do single query if we want, transparently
    twitter_search: function(queries, callback_fn) {
      if (queries.length < 1) return;
      var query = queries.shift();
      var search_url = "http://search.twitter.com/search.json?q={query}&callback=?".supplant_raw({
        query: encodeURIComponent(query)
      });
      jQuery.getJSON(search_url, callback_fn);
      setTimeout(function() { Util.twitter_search(queries, callback_fn); }, 500);
    },
    twitter_user_timeline: function(username, count, callback_fn) {
      var api_url = "http://twitter.com/statuses/user_timeline.json?screen_name={username}&count={count}&callback=?".supplant_raw({
        username: encodeURIComponent(username),
        count: encodeURIComponent(count)
      });
      jQuery.getJSON(api_url, callback_fn);
    },
    twitter_is_following: function(username, idolname, callback_fn) {
      var api_url = "http://twitter.com/friendships/exists.json?user_a={username}&user_b={idolname}&callback=?".supplant_raw({
        username: encodeURIComponent(username),
        idolname: encodeURIComponent(idolname)
      });
      jQuery.getJSON(api_url, callback_fn);
    },
    abvar: function(jele, casestr){
      var prefix = jele.hasClass('test_a') ? 'A_' : 'B_';
      return prefix + casestr;
    },
    abtest_a: function(jele){
      return jele.hasClass('test_a');
    }
  }

	
});

function member_action(member_function, rec_mrtweet){
  if (window.mrtweet_user){
    return member_function();
  } else {
    if (rec_mrtweet) {
      oauth_to_continue({
        title_text: 'Sign in with Twitter to Continue',
        recommend_mrtweet_tweet: window.default_recommend_us_msg || "Check out the awesome new MrTweet! http://mrtweet.com?s=lt",
        recommended_mrtweet: window.recommended_mrtweet
      }, member_function, "");
    } else {
      oauth_to_continue({
        title_text: 'Sign in with Twitter to Continue'
      }, member_function, "");
    }
//    window.location = '/signin_first?current_uri=' + window.location.href;
  }
}

var v_param= (gup("v"));
if (v_param=="" || v_param==null) {
  v_param="noparam";
}
