/* 
Tokofu Common JS Library Functions
Requires jquery 1.2.6+

Copyright (c) 2009 Tokofu, All Rights Reserved

1.0	| 04.Mar.2009 | Initial Release
*/

if (jQuery) {
  // IE CSS abbr fix
  jQuery(window).load(function() {
      document.createElement('abbr');
  });


  // store these as functions so they can be called on ajax loads
  function toggleDefaultValues() {
      $ = jQuery;

      // remove default value in text box when it gets the focus
      $("input[type='text']").focus(function() {
  		if (($(this).val() == this.defaultValue) && ($(this).hasClass('show-default'))) {
  			$(this).val('');
  		}
  	});
	
  	// add default text back into input box if it's empty and loses the focus
  	$("input[type='text']").blur(function() {
  		if (($(this).val() == '') && ($(this).hasClass('show-default'))) {
  			$(this).val(this.defaultValue);
  		}
  	});    
  }

  // from: http://www.learningjquery.com/2007/08/clearing-form-data
  function clearForm(form) {
    // iterate over all of the inputs for the form
    // element that was passed in
    $(':input', form).each(function() {
      var type = this.type;
      var tag = this.tagName.toLowerCase(); // normalize case
      if (type == 'text' || type == 'password' || tag == 'textarea')
        this.value = '';
      else if (type == 'checkbox' || type == 'radio')
        this.checked = false;
      else if (tag == 'select')
        this.selectedIndex = -1;
    });
  };

  // on DOM ready actions
  jQuery(function($) {
      toggleDefaultValues();
      $('a[rel~="external"]').attr('target', '_blank');
  });
}

function emote(data) {
    console.log(data);
}