/****************************************************************************************************************
 Common Javascript 
 Prepared by Ryan Cramer Design, LLC, August 2006

 ****************************************************************************************************************/

window.onload = function() {
	// Functions called when page loads

	if(!document.getElementById) return; 
	if(!document.getElementsByTagName) return;

	prep_form_defaults("topsearchform"); 

	// Fix minor display/width issue with Safari form fields not recognizing padding (as of v417). May need to be removed in the future.
	// if(navigator.appVersion.indexOf('Safari') != -1) document.getElementById('topsearchtext').style.width = "80px";
}

function prep_form_defaults(id) {
	// Prepare form fields so that they delete or restore their default value depending on focus/blur status
	// Works in tandem with .inputfoucs and .inputblur styles in common.css

	theform = document.getElementById(id); 
	if(!theform) return;

	for(var i = 0; i < theform.elements.length; i++) {
		var element = theform.elements[i];
		if(element.type == 'submit') continue; 
		if(!element.defaultValue) continue;

		element.onfocus = function() {
			if(this.value == this.defaultValue) {
				this.value = '';
				this.className = 'inputfocus';
			}			
		}
		
		element.onblur = function() {
			if(this.value == '') {
				this.value = this.defaultValue;
				this.className = 'inputblur';
			}
		}
	}
}


