 	/*==================================================================*\
	######################################################################
	#                                                                    #
	# Copyright 2009 dynno.net . All Rights Reserved.                    #
	#                                                                    #
	# This file may not be redistributed in whole or part.               #
	#                                                                    #
	# Developed by: $ID: 1 $UNI: Imad Jomaa                              #
	# ----------------------- THIS FILE PREFORMS ----------------------- #
	#                                                                    #
	# JS Counter                                                         #
	######################################################################
	\*==================================================================*/
      
    //create the var to set the max length
    var maxLength=140;
    var charCount = document.getElementById('charCount');

    function charLimit(el) 
    {
      
      //check if the textbox value is over the maximum length
      if (el.value.length > maxLength) 
      {
          //since it is, start counting the negatives
          charCount.innerHTML = el.value.length - maxLength;
      }
      return true;
    }
    
    function characterCount(el) 
    {
      var charCount = document.getElementById('charCount');
      
      //initiates the countdown
      if (charCount) 
      {
          charCount.innerHTML = maxLength - el.value.length;
          var generate = document.getElementById('generate');

          //if the length is greater then the maxlength disable the submit button
          if (el.value.length > maxLength) 
          {
            generate.disabled = true;
            generate.style.color = "#ccc";
          }
      
           //if the length is less than or equal to the maxlength enable the submit button
          if (el.value.length <= maxLength) 
          {
            generate.disabled = false;
            generate.style.color = "#000";
          }

           //if the length is less than 1, disable the submit button
          if (el.value.length < 1)
          {
            generate.disabled = true;
          }
      }
      
      //change colors
      if(charCount.innerHTML < 16) charCount.style.color="red";
      if(charCount.innerHTML > 16) charCount.style.color="#2d73b9";
      
      return true;
}
