// <![CDATA[
$(document).ready( function() {
	$("a[@rel$=external]").click(function(){
		this.target = "_blank";
	});
			
	$('input[title!=""]').hint();
				
});  



$.fn.serialize = function() {
	var a = [];
	var ok = {INPUT:true, TEXTAREA:true, OPTION:true, HIDDEN:true};

	$('*', this).each(function() {
			var par = this.parentNode;
			var p = par.nodeName.toUpperCase();
			var n = this.name || p == 'OPTGROUP' && par.parentNode.name || p == 'SELECT' && par.name || this.id;

			if ( !n || this.disabled || this.type == 'reset' || 
					(this.type == 'checkbox' || this.type == 'radio') && !this.checked || 
					!ok[this.nodeName.toUpperCase()] ||
					(this.type == 'submit' || this.type == 'image') && this.form.clicked != this ||
					(p == 'SELECT' || p == 'OPTGROUP') && !this.selected ) { return; }

			if (this.type == 'image' && this.form.clicked_x) {
					return a.push(
							{name: this.name+'_x', value: this.form.clicked_x},
							{name: this.name+'_y', value: this.form.clicked_y}
					);
			}
			a.push({name: n, value: this.value});
	}).end();

	this.vars = a;

	return this;
};	

$.fn.formdata = function(){
		this.serialize();
		return this.vars;
};

$.fn.clearForm = function() {
  $('*', this).each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();					
	if (tag == 'form')
	  return $(':input',this).clearForm();
	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;
  }).end();;
};	

jQuery.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }

  return this.each(function () {
    // get jQuery version of 'this'
    var $input = jQuery(this),

    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = jQuery(this.form),
      $win = jQuery(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title

      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

// ]]>