/*
	kanji.koohii.com / forums
	Misc. utility functions
	Author : Fabrice Denis / May 2006
*/

var TEXTBOX_CSS_CLASS = 'textfield';

// Source : Unobstrusive Javascript ( http://www.onlinetools.org/articles/unobtrusivejavascript/ )
function kk_addEvent(obj, evType, fn)
{
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}


// Apply a CSS class to the text fields so that they can be styled in IE6.
// This is only for the Admin & Profile areas of punBB where I don't want to customize the markup.
function kk_styleTextfields()
{
	if (!document || !document.getElementById)
		return;
	var block = document.getElementById('profile');
	if (!block)	block = document.getElementById('adminconsole');
	if (!block)	return;
	var inp = block.getElementsByTagName('input');
	for (var i=0; i<inp.length; i++)
	{
		if (inp[i].getAttribute('type') == 'text')
		{
			inp[i].className += inp[i].className ? ' '+TEXTBOX_CSS_CLASS : TEXTBOX_CSS_CLASS;
		}
	}
}

function kk_forumInit()
{
	kk_styleTextfields();
}


kk_addEvent(window, 'load', kk_forumInit);
