/* NO MORE USED : does not work inside a TABLE

function clearElement(element, elementType){
    switch( elementType )
    {
        case "text":
            element.value="";
            break;
        case "radiocheck":
            element.checked=false;
            break;
        case "select":
            element.selectedIndex=0;
            break;
    }
}
function clearForm2() {
    var formChilds = document.myform.table[0].childNodes;
    // parser tous les enfants
    for( var i =0; i < formChilds.length; i++) {
       var elementType="none";
//       confirm("the type=" + formChilds[i].tagName);
       if( formChilds[i].tagName=="INPUT") {
          switch( formChilds[i].getAttribute("type") )
          {
          case "text":
          //case "textarea":
              elementType="text";
              break;
          case "radio":
          case "checkbox":
              elementType="radiocheck";
              break;
          default: 
            elementType="none";
          }//endswitch
       }
       if(formChilds[i].tagName=="TEXTAREA") elementType="text";
       if ( formChilds[i].tagName=="SELECT") elementType="select";
       if ( elementType != "none") clearElement( formChilds[i], elementType);
	}//end for
}

*/




/* IDEM BUT USING JQUERY */

//$.fn.clearFields = $.fn.clearInputs = function() {
$.fn.clearFields = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea')
            this.value = '';
        else if (t == 'checkbox' || t == 'radio')
            this.checked = false;
        else if (tag == 'select')
            //this.selectedIndex = -1;
            this.selectedIndex = 0;
    });
};

/*
$.fn.clearForm = function() {
    return this.each(function() {
        $('input,select,textarea', this).clearFields();
    });
};
*/
function clearForm() {
	$('input,select,textarea').clearFields();
}

/* Another way to clear a form with JQuery, but does not work in IE for the SELECT attributes !!!
function clearForm_AnOtherWay() {
	//$('#myForm').clearForm();
	//$("#myform").resetForm();
	//$("#myform").clearForm();
	//$('#myform :text').attr("value","");

	//$("input[@type=text]").attr("value","");
	$("input[@type=text], textarea").val('');

	//$("input[@type=radio][@checked]")
	//$("input[@type=checkbox]").attr("checked","");
	$("input[@type=checkbox], input[@type=radio]").removeAttr("checked");
	//$("input[@type=radio]").removeAttr("checked");
	
	//$("textarea").val('');
	//$("textarea").hide();
	
	//$("select").selectedIndex=-1;
	//$("option").removeAttr("selected");
	//$("select").children("option").removeAttr("selected");
	$("select option").removeAttr("selected");
}
*/
