
// reset form values
// http://www.learningjquery.com/2007/08/clearing-form-data
$.fn.clearForm = function() {
return 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;
});
};


// show loader while ajaxing
/* require some css and image:

		#loading {
			background:#fff;
			position: fixed;
			width: 100%;
			height: 100%;
			top:0;
			left:0;
			display: block;
			opacity: 0.6;
			-moz-opacity: 0.6;
			filter: alpha(opacity=60);
			z-index: 3333;
		}

		 #loadingimg {
			position:absolute;
			background: url("../images/loader.gif") no-repeat center center;
			left: 50%;
			margin-left: -130px;
			top:33%;
			width: 260px;
			height: 39px;
			z-index: 3334;
		}

*/

var hideloader = false;
jQuery(function($){
        $('<div id="loadingBox"><div id="loadingimg"></div><div id="loading"></div></div>').appendTo(document.body).hide();
        $('#loadingBox').ajaxStart(function() {
            if (!hideloader) $(this).show();
        }).ajaxStop(function (){
        	$(this).hide();
            hideloader = false;
        });
});

