function showHighlightImage(rowElem, imageURL, imageHeight) {
	var rightCell = getChildNode(rowElem,"LinkBtnRight");
	if( rightCell!=null ) {
		if( getChildNode(rightCell,"LinkBtnImagePositionDiv")!=null )
			return;
		var divElem = document.createElement("DIV");
		divElem.style.position="relative";
		divElem.id = "LinkBtnImagePositionDiv";
		rightCell.appendChild(divElem);
		var imgElem = document.createElement("IMG");
		imgElem.style.position = "absolute";
		imgElem.style.right = "0px";
		imgElem.style.top = Math.floor((rowElem.offsetHeight - imageHeight)/2) + "px";
		imgElem.src = imageURL;
		imgElem.id="LinkBtnHighlightImage";
		divElem.appendChild(imgElem);
	}
}
function hideHighlightImage(rowElem) {
	var rightCell = getChildNode(rowElem,"LinkBtnRight");
	if( rightCell!=null ) {
		var hElem = getChildNode(rightCell,"LinkBtnImagePositionDiv");
		if( hElem!=null )
			rightCell.removeChild(hElem);
	}
}
function changeBackgroundImage(rowElem,imgURL){
	var centerCell = getChildNode(rowElem,"LinkBtnCenter");
	if( centerCell!=null ) {
		centerCell.style.backgroundImage='url(' + imgURL + ')';
	}
}
function getChildNode(parent, childID)
{
	var list = parent.childNodes;
	if (list == null) return null;
	for (var i=0; i<list.length; i++)
		if (list.item(i).id == childID)
			return list.item(i);
	return null;
}
function attachLinkBtnRowHandlers(buttonsTableID, mouseEnterFunction, mouseLeaveFunction, clickFunction) {
	var tableElem = document.getElementById(buttonsTableID);
	if( tableElem!=null ) {
		var list = tableElem.getElementsByTagName("tr");
		if (list == null) return;
		for (var i=0; i<list.length; i++) {
			if (list.item(i).id == "LinkBtnRow") {
				list.item(i).onmouseout = mouseLeaveFunction;
				list.item(i).onmouseover = mouseEnterFunction;
				list.item(i).onclick = clickFunction;
			}
		}
	}
}
function getLinkElement(rowElem) {
	var list = rowElem.getElementsByTagName("a");
	if (list == null || list.length<1) return null;
	return list.item(0);
}
function clickLinkButtonLink(linkBtnRowElem) {
	var hLink = getLinkElement(linkBtnRowElem);
	if(hLink!=null)
		hLink.click();
}
var __ResizeContainerID = null;
var __ResizeContainerPreferredWidth = 0;
function handleResize() {
	var hContainer = document.getElementById(__ResizeContainerID);	
	if( hContainer!=null ) {
		if( document.body.clientWidth < __ResizeContainerPreferredWidth ) {
			hContainer.style.width = (document.body.clientWidth) + "px";
		}
		else {
			hContainer.style.width = __ResizeContainerPreferredWidth + "px";
		}
	}
}
function attachResizeHandler(sResizeContainerID,iPreferredWidth) {
	__ResizeContainerID = sResizeContainerID;
	__ResizeContainerPreferredWidth = iPreferredWidth;
	window.onresize = handleResize;	
	handleResize();
}

function swapcss (obj,class1,class2) {
	obj.className=!checkcss(obj,class1)?obj.className.replace(class2,class1): obj.className.replace(class1,class2);
}

function addcss (obj,class1) {
    if(!checkcss(obj,class1)){
      	obj.className+=obj.className?' '+class1:class1;
    }
}

function removecss (obj, class1){
      var rep=obj.className.match(' '+class1)?' '+class1:class1;
      obj.className=obj.className.replace(rep,'');
}

function checkcss (obj, class1){
      return new RegExp('\\b'+class1+'\\b').test(obj.className)
}

function ClearClass(obj, classtoclear){
	var tableElem = document.getElementById(obj);
	if( tableElem!=null ) {
		var list = tableElem.getElementsByTagName("tr");
		if (list == null) return;
		for (var i=0; i<list.length; i++) {
			if (list.item(i).id == "LinkBtnRow") {
				removecss(list.item(i), classtoclear);
			}
		}
	}
}
