
function addClass(target, classValue) {
	if (!hasClass(target, classValue)) {
		if (target.className == "") {
			target.className = classValue;
		} else {
			target.className += " " + classValue;
		}
	}
	return true;
};




function removeClass(target, classValue) {
	var removedClass = target.className;
	var pattern = new RegExp("(^| )" + classValue + "( |$)");
	removedClass = removedClass.replace(pattern, "$1");
	removedClass = removedClass.replace(/ $/, "");
	target.className = removedClass;
	return true;
};




function hasClass(target, classValue) {
	var pattern = new RegExp("(^| )" + classValue + "( |$)");
	if (target.className.match(pattern)) {
		return true;
	}
	return false;
};




addLoadEvent = function(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
};




findHeight = function(element, recalc) {
	if (element.height && recalc != true)
		return element.height;
	else {
		if (element.style.height)
			element.height = parseInt(element.style.height);
		else {
			element.style.height = element.clientHeight + 'px';
			element.height = parseInt(element.style.height);
		};
		return element.height;
	}
};




pageY = function(e) {
	if (!e.pageY)
		return e.clientY + window.document.documentElement.scrollTop;
	else
		return e.pageY;
};




findPosY = function(obj) {
	var curtop = 0;
	if (obj.offsetParent)
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
};




function isUndefined(v) {
	var undef;
	return v===undef;
};




function encodeURLText(theHTML) {
	if(theHTML.length) {
		theHTML = theHTML.replace(/\?/gim,"[q]");
		theHTML = theHTML.replace(/\&/gim,"[a]");
		theHTML = theHTML.replace(/\#/gim,"[h]");
		theHTML = theHTML.replace(/\./gim,"[d]");
		theHTML = theHTML.replace(/\=/gim,"[e]");
		theHTML = theHTML.replace(/\ /gim,"%20");
	}
	return theHTML;
};




function unEncodeURLText(theHTML) {
	if(theHTML.length) {
		theHTML = theHTML.replace(/\[q]/gim,"?");
		theHTML = theHTML.replace(/\[a]/gim,"&");
		theHTML = theHTML.replace(/\[h]/gim,"#");
		theHTML = theHTML.replace(/\[d]/gim,".");
		theHTML = theHTML.replace(/\[e]/gim,"=");
		theHTML = theHTML.replace(/\%20/gim,"");
	}
	return theHTML;
};

