function capitalize(f,m) {

if (m) /*cap words*/ {
	var temp, tempC, pre, post, strlen;
	temp = f.value.toLowerCase();
	stringLen = temp.length;
	  if (stringLen > 0) {
		for (i = 0; i < stringLen; i++) {
		  if (i == 0) {
			tempC = temp.substring(0,1).toUpperCase();
			post = temp.substring(1,stringLen);
			temp = tempC + post;
		  } else {
			tempC = temp.substring(i,i+1);
			if (tempC == " " && i < (stringLen-1)) {
			tempC = temp.substring(i+1,i+2).toUpperCase();
			pre = temp.substring(0,i+1);
			post = temp.substring(i+2,stringLen);
			temp = pre + tempC + post;
		  }
		}
	  }
	}
  } else /*cap all*/ {
    var temp = f.value.toUpperCase();
  }
  f.value = temp;
};
