// Set the secondary column to full height (beat the CSS specs)
function setColumnHeights(){
	if (document.getElementById("primary") && document.getElementById("secondary")) {
		primaryCol = document.getElementById("primary");
		secondaryCol = document.getElementById("secondary");
		if (primaryCol.offsetHeight > secondaryCol.offsetHeight) {
			secondaryCol.style.height=primaryCol.offsetHeight + "px";
		}
	} else if (document.getElementById("introPrimary") && document.getElementById("introSecondary")) {
		primaryCol = document.getElementById("introPrimary");
		secondaryCol = document.getElementById("introSecondary");
		if (primaryCol.offsetHeight > secondaryCol.offsetHeight) {
			targetHeight = (primaryCol.offsetHeight) + "px";
		} else if (primaryCol.offsetHeight < secondaryCol.offsetHeight) {
			targetHeight = (secondaryCol.offsetHeight) + "px";
		}
		if (document.getElementById && !document.all) {
			primaryCol.style.minHeight=targetHeight;
			secondaryCol.style.minHeight=targetHeight;
		} else {
			primaryCol.style.height=targetHeight;
			secondaryCol.style.height=targetHeight;
		}
	}
}

// Clear text fields when clicked - but only if they're showing the default value
// The form uses hidden fields with an id beginning in "clrval". The 'value' attribute should match that of the relevant input or textarea
originalValues = new Array();
function clearInputs() {
	if (document.getElementsByTagName("form").length > 0) {
		inputs=document.getElementsByTagName("input");
		for (i=0; i<inputs.length; i++) {
			if(inputs[i].type =="hidden" && inputs[i].id.indexOf("clrval")!=-1) {
				originalValues[inputs[i].id.substring(6)]=inputs[i].value;
			}
		}
		for (i=0; i<inputs.length; i++) {
			if(inputs[i].type =="text" && originalValues[inputs[i].id.substring(3)]) {
				inputs[i].onfocus = function() {
					if (this.value==originalValues[this.id.substring(3)]){
						this.value=""
					}
				}
			}
		}
		textareas=document.getElementsByTagName("textarea");
		for (i=0; i<textareas.length; i++) {
			if(originalValues[textareas[i].id.substring(3)]) {
				textareas[i].onfocus = function() {
					if (this.value==originalValues[this.id.substring(3)]){
						this.value=""
					}
				}
			}
		}

	}
}

if (window.attachEvent) {	
	window.attachEvent("onload", setColumnHeights);
	window.attachEvent("onresize", setColumnHeights);
	window.attachEvent("onload", clearInputs);
} else if (window.addEventListener){
	window.addEventListener("load", setColumnHeights, false); 
	window.addEventListener("resize", setColumnHeights, false); 
	window.addEventListener("load", clearInputs, false); 
} else if (document.addEventListener){ 
	document.addEventListener('load', setColumnHeights, false);
	document.addEventListener('resize', setColumnHeights, false);
	document.addEventListener('load', clearInputs, false);
}
