//function to handle onClick events
addEvents = function(obj, text){

	//set the event handler for the onClick event
	obj.addEventListener('focus', function(){
		if(obj.value == text) obj.value = "";
	}, false);

	//set the event handler for the onBlur event
	obj.addEventListener('blur', function(){
		if(obj.value.length == 0) obj.value = text;
	}, false);
}

//loads when the page has finished loading
window.onload = function(){

	//load newsletter and contact form elements
	var loadInputs = document.getElementsByTagName("input");

	//create array of elements & default values
	var inputArray = new Array();
	var defaultText = new Array();

	//create a counter for the input array
	var inputCounter = 0;

	//load up
	for(i=0;i<loadInputs.length;i++){
		if(loadInputs[i].type == "text"){
			inputArray[inputCounter] = loadInputs[i];
			defaultText[inputCounter] = loadInputs[i].value;
			inputCounter = inputCounter + 1;
		}
	}

	//load the textarea element
	var loadTextArea = document.getElementById("contact-textarea");

	//add the textarea element to the array
	inputArray[inputCounter] = loadTextArea;

	//add the textarea default text to the array
	defaultText[inputCounter] = loadTextArea.innerHTML;

	//add event handlers to all elements in the array
	for(i=0;i<inputArray.length;i++){
/*  		alert(defaultText[i]); */
		addEvents(inputArray[i], defaultText[i]);
	}
}
