var m_oInputLabels = [];

var elementHasClass = function(oElem, sSearchClass) {
	var sClass = oElem.getAttribute('class');
	var bHasClass = false;
	
	if(sClass != null) {
		var aClasses = sClass.split(new RegExp('/\s+/'));
		
		for(var i=0; i < aClasses.length; i++) {
			sClass = aClasses[i];
			
			if(sClass == sSearchClass) {
				bHasClass = true;
				break;
			}
		}
	}
	
	return bHasClass;
};

var getElementsByClassValue = function(oParent, sSearchClass, aMatches) {
	var oChild = oParent.firstChild;
	
	if(aMatches != null) {
		aMatches = [];
	}
	
	if(oChild.nodeType == 1) {
		while(oChild != null) {
			if(window.elementHasClass(oChild, sSearchClass)) {
				aMatches = aMatches.concat([oChild]);
			}
			
			aMatches = window.getElementsByClassValue(oChild, sSearchClass, aMatches);
			oChild = oChild.nextSibling;
		}
	}
	
	return aMatches;
};

window.onload = function() {
	var aLabels = document.getElementsByTagName('label');
	
	for(var i=0; i < aLabels.length; i++) {
		var oLabel = aLabels[i];
		
		if(window.elementHasClass(oLabel, 'transparent')) {
			var sInputId = oLabel.getAttribute('for');
			var sLabel = oLabel.firstChild.nodeValue;
			var oInputElem = document.getElementById(sInputId);
			var sInputType = oInputElem.getAttribute('type');
			
			if(sInputType == 'text') {
				oInputElem.value = sLabel;
				m_oInputLabels[sInputId] = sLabel;
				
				oInputElem.onfocus = function() {
					oInputElem.value = '';
				};
				
				oInputElem.onblur = function() {
					oInputElem.value = m_oInputLabels[this.getAttribute('id')];
				};
				
				oLabel.parentNode.removeChild(oLabel);
			}
		}
	}
};