var values = new Array();
var index = 0;

window.onload = function() {
    var holder = document.getElementById('contactform');
    
    if (!holder) {
    	return;
    }
    
    initInputs(holder, 'input');
    initInputs(holder, 'textarea');
}

function initInputs(holder, tag) {
    var arr = holder.getElementsByTagName(tag);

    for (var i = 0; i < arr.length; i++) {
    	values.push(arr[i].getAttribute('rel'));

    	arr[i].mem = index++;

    	arr[i].onfocus = function() {
    		if (this.tagName.toLowerCase() == 'input') {
	    		//this.parentNode.className = 'textfield-wrapper-focused';
	
	    		if (this.value == values[this.mem]) {
	    			this.value = '';
	    			this.style.color = '#000';
	    		}
	    	} else if (this.tagName.toLowerCase() == 'textarea') {
	    		//this.parentNode.className = 'textfield-wrapper-focused';

	    		if (this.innerHTML == values[this.mem]) {
	    			this.innerHTML = '';
	    			this.style.color = '#000';
	    		}
	    	}
    	}
    	
    	arr[i].onblur = function() {
    		if (this.tagName.toLowerCase() == 'input') {
	    		if (this.value == '') {
	    			//this.parentNode.className = 'textfield-wrapper';
	    			this.value = values[this.mem];
	    			this.style.color = '#999';
	    		} else {
	    			//this.parentNode.className = 'textfield-wrapper-done';
	    		}
	    	}
    	}
    }
}
