/*--------------------------------------------------

Buttons - 4/26/07
Description: Series of scripts to automatically
restrict characters within given inputs and then 
optionally format said field on blur.

--------------------------------------------------*/

function setButtons(){
	// Test for DOM Method
	if(!document.getElementsByTagName)return false;
	// Get all elements on page
	var f=document.getElementsByTagName('*');
	// Initialize variables
	var g,newElement,tempPadLeft;
	// Loop through page elements
	for(var i=0;i<f.length;i++){
		// Test to see if the class name begins with "btn"
		if((f[i].className)&&(f[i].className.match(/^btn/i))){
			// Create new Span element
			newElement=document.createElement('span');
			// Test for Mozilla-based browsers
			var agt=navigator.userAgent.toLowerCase();
			var is_gecko=(agt.indexOf('gecko') != -1);
			// Set display of existing element if browser is Mozilla-based
			if(is_gecko)f[i].style.display='-moz-inline-stack;'
			// Remove Right Padding on existing Element
			f[i].style.paddingRight='0px';
			// Move background inmage on existing element to show left curved corners
			f[i].style.backgroundPosition="top left";
			if(f[i].tagName.toLowerCase()=='a'){
				f[i].onmouseover=function(){
					this.style.backgroundPosition="bottom left";
				}
				f[i].onmouseout=function(){
					this.style.backgroundPosition="top left";
				}
			}
			// Remove borders from existing element
			f[i].style.borderWidth='0px';
			// Copy innerHTML of existing element into new Span element
			newElement.innerHTML=f[i].innerHTML;
			// Delete innerHTML of existing element
			f[i].innerHTML='';
			// Append new Span element into existing element
			f[i].appendChild(newElement);
			f[i].onfocus=function(){
				if(this.blur)this.blur();	
			}
		}
	}
}