function getElementsByClass(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function addEvent(obj,type,fn) {
	if (obj.addEventListener)
	{
		obj.addEventListener(type,fn,false);
		return true;
	}
	else if (obj.attachEvent)
	{
		obj['e'+type+fn] = fn;
		obj[type+fn] = function() { obj['e'+type+fn]( window.event ); }
		var r = obj.attachEvent('on'+type, obj[type+fn]);
		return r;
	}
	else
	{
		obj['on'+type] = fn;
		return true;
	}
}

function inputValueSwap(event)
{
	if (event.type == 'focus' && this.value == this.title)
	{
		this.value = '';
		this.style.color = '#000';
		this.style.fontStyle = 'normal';
	}

	if (event.type == 'blur' && this.value == '')
	{
		this.style.color = '#7f7778';
		this.style.fontStyle = 'italic';
		this.value = this.title;
	}
}
var inputValueSwapSetup = getElementsByClass(document, 'inputValueSwap');
for(var i in inputValueSwapSetup)
{
	if(typeof(inputValueSwapSetup[i]) == 'object')
	{
		var input = inputValueSwapSetup[i];

		input.value = input.title;
		addEvent(input, 'focus', inputValueSwap);
		addEvent(input, 'blur', inputValueSwap);

	}
}
