// JavaScript Document

function init() {
	textFieldBehavior();
}

function textFieldBehavior() {
	var textFields = document.getElementsByTagName("input");
	var textAreas = document.getElementsByTagName("textarea");
	for(var i in textFields) {
		if(textFields[i].type == "text") {
			textFields[i].className = "inputFieldNormal";
			textFields[i].initialVal = textFields[i].value;
			textFields[i].onfocus = focusHandler;
			textFields[i].onblur = blurHandler;
		}
	}
	
	for(var i in textAreas) {
		textAreas[i].className = "inputFieldNormal";
		textAreas[i].initialVal = textAreas[i].value;
		textAreas[i].onfocus = focusHandler;
		textAreas[i].onblur = blurHandler;
	}
	
}

function focusHandler() {
	if(this.value == this.initialVal) this.value = "";
	this.className = "inputFieldActive";
}

function blurHandler() {
	if(this.value == "") this.value = this.initialVal;
	this.className = "inputFieldNormal";
}

function setSidebarHeights() {
	var lsb = document.getElementById("l_sidebar");
	var rsb = document.getElementById("r_sidebar");
	var cont = document.getElementById("contentleft");

	var h;
	var l_sidebarHeight = lsb.offsetHeight;
	var r_sidebarHeight = rsb.offsetHeight;
	var content_height = cont.offsetHeight;
	
	h = Math.max(l_sidebarHeight, r_sidebarHeight);
	h = Math.max(h, content_height);
	
	lsb.style.height = h + "px";
	rsb.style.height = h + "px";			
}

addLoadEvent(setSidebarHeights);
addLoadEvent(init);

function addLoadEvent(func) {  
    var oldonload = window.onload;  
    if (typeof window.onload != 'function') {  
        window.onload = func;  
    } else {  
        window.onload = function() {  
            if (oldonload) {  
                oldonload();  
            }  
            func();  
        }  
    }  
}