if ( window.addEventListener ){
	window.addEventListener('load', getInputs, false);
} else {
	window.attachEvent('onload', getInputs, false)
}

function getInputs()
{
	var inputs = document.getElementsByTagName('input');
	var input_num = inputs.length;
	
	for ( var x=0; x < input_num; x++ ){
		
		var input_type = inputs[x].getAttribute('type');
		var input_class = inputs[x].getAttribute('class');
		
		if ( input_type == 'text' && input_class == 'no_focus' ){
			
			if ( inputs[x].value == '' ){
				inputs[x].value = inputs[x].getAttribute('title');
			}
			
			inputs[x].onfocus = function(){
				clearField(this);
			}
		}
	}
	
	var textareas = document.getElementsByTagName('textarea');
	var text_num = textareas.length;
	for ( var x=0; x < text_num; x++ ){
		var text_class = textareas[x].getAttribute('class');
		
		if ( text_class == 'no_focus' ){
			
			if ( textareas[x].value == '' ){
				textareas[x].value = textareas[x].getAttribute('title');
			}
			
			textareas[x].onfocus = function(){
				clearField(this);
			}
		}
	}
}

function clearField(input)
{
	
	var title = input.getAttribute('title');
	
	if ( input.value.toLowerCase() == title.toLowerCase() ){
		input.value = '';
	}
	input.onblur = function(){
		return restoreText(input, title);
	}
	input.setAttribute('class', 'has_focus');
	input.className = 'has_focus';
}

function restoreText(input, defText){
	if ( input.value == '' ){
		input.value = defText;
		input.setAttribute('class', 'no_focus');
		input.className = 'no_focus';
	}
	
}

/*function validateForm(form)
{
	
	var inputs = form.getElementsByTagName('input');
	var input_num = inputs.length;
	
	for ( var x=0; x < input_num; x++ ){
		if ( inputs[x].className == 'no_focus' ){
			
		}
	}
	
	
}*/
