$(document).ready(function () {
	// Replace submit with anchor ------------------------>
	$("#form-footer").html('<div class="button-lg" id="submit"><a href="#">Send Anonymous Tweet</a></div><div class="clear">&nbsp;</div>');
	
	if($.browser.msie){
	  	$(".twitter-status").corner();
	  }else{
	 
		// Style div corners ------------------------>
		$(".twitter-status, .button-sm, .button-lg").corner();
		$("#main-form, #main-result, #side-feature").corner("bl br");
		$("#main-form-content, #main-result-content, #side-feature-content").corner("round 8px bl br");
		
		// Use fading hovers ------------------------>
		
		$(".button-sm, .button-lg").hover( 
		  function () {
			$(this).addClass("hidehover");
			$(this).prepend('<div class="fade">&nbsp;</div>');
			$(this).children(".fade").hide();
			$(this).children(".fade").fadeIn("fast"); 
		  }, 
		  function () {
			$(this).removeClass("hidehover");
			$(this).children(".fade").fadeOut("fast",function() {$(this).remove()});
		  }
		);
		
		$("#logo-b").hover( 
		  function () {
			$(this).fadeTo("fast",1.0); 
		  }, 
		  function () { 
			$(this).fadeTo("fast",0.33); 
		  }
		);
     
     };
    
    $("#submit").click(function() {
    	document.statusform.submit();
    });
    
	$(function() {
		
		// Set character counter ------------------------>
		$('#status').keyup(function(){
			limitChars('status', 140, 'charlimitinfo');
		});
		
		// Trigger hover to set it up ------------------------>
		if($.browser.msie){
			} else {
				$(".button-sm, .button-lg").hover();
				$("#logo-b").fadeTo("fast",0.33);
			}
		
		// Set the focus ------------------------>
		$('#status').focus();
	});    
});

function limitChars(textid, limit, infodiv) {
	var text = $('#'+textid).val(); 
	var textlength = text.length;
	if(textlength > limit) {
		$('#' + infodiv).html('<span class="error">The limit is '+limit+' characters!</span>');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	} else {
		$('#' + infodiv).html(limit - textlength);
		return true;
	}
}

var RecaptchaOptions = {
   theme : 'white',
   tabindex : 2
};

Shadowbox.init({
    players:    ["html","iframe"]
});