// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function swapClasses (theID, oldClass, newClass)
{
	$(theID).removeClassName(oldClass);
	$(theID).addClassName(newClass);
}


function swapSmiley(theID,smiley_url)
{	
	$(theID).innerHTML = '<img src='+ smiley_url + '>'; 
}

function updateTaskStatus(theID,taskStatus,statusExplanation)
{
	$(theID).innerHTML = '<a href= "#" class="tooltip">'+ taskStatus +'<span class="tl tr bl br">'+ statusExplanation +'</span></a>'
	
	// <a href="#" class="tooltip">?<span><%= @status_explanation %></span></a>
	
}

function updateTweetLink(sharedStatus)
{		
	// $('tweet_link').href = 'http://twitter.com/home?status=' + (sharedStatus)
	$('tweet_link').href = 'http://twitter.com/share?url=http://rootein.com&via=rootein&text=' + (sharedStatus)
	
	

}


function updateDueCount(theID,count)
{
	// $(theID).innerHTML = '<a href= "#" class="tooltip">'+ taskStatus +'<span class="tl tr bl br">'+ statusExplanation +'</span></a>'
	$(theID).innerHTML = count
	
	// <a href="#" class="tooltip">?<span><%= @status_explanation %></span></a>
	
}

function swapBadgeColors(theID,newColor)
{
	
	$(theID).removeClassName('orange');
	$(theID).removeClassName('red');
	$(theID).removeClassName('green');
	$(theID).removeClassName('yellow');

	$(theID).addClassName(newColor);
}

function updateElement (theID, newText)
{
	$(theID).update(newText);
}

document.observe("dom:loaded", function() {
  setTimeout(hideFlashMessages, 10000); // hide in 10 seconds
});

function hideFlashMessages() {
  $$('div#notice, div#warning, div#error').each(function(e) { 
    if (e) Effect.Fade(e, { duration: 5.0 });
  });
	$('addTask').addClassName('prepend-19');
}

function enableText(checkBool, textID)
{
  textFldObj = document.getElementById(textID);
  //Disable the text field
  textFldObj.disabled = !checkBool;
  //Clear value in the text field
  //if (!checkBool) { textFldObj.value = ''; }
  textFldObj.focus();
}
