function setHtmlById(divName, divStr)
{
	document.getElementById(divName).innerHTML = divStr;	
}

function getHtmlById(divName)
{
	return document.getElementById(divName).value;
}

function setHtmlByIdValue(divName, val)
{
	document.getElementById(divName).value = val;
}

function rollTr(trId, valColor, typ)
{
	trId.style.background=(typ=='over')?valColor:'';
}


function swapImages(obj, img, ext)
{
	obj.src = 'images/' + img + '.' + ext;
}

function changeBackGround(id, clr)
{
	id.style.backgroundColor = clr
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function confirmDelete()
{
	del = document.getElementById('allItems').checked
	//delConfirm = confirm('Are you sure you want to delete these item(s)?');
	if(del)
	{
		delConfirm = confirm('Are you sure you want to delete?');
		if(delConfirm)
			document.getElementById('pageForm').submit();
		else
			return false;
	}
	
}

function popUpWindown(url,winName, width, height, others)
{
	others = others?others:"location=1,status=1,scrollbars=1";
	myWindow= window.open (url, winName, others + ",width=" + width + ",height=" + height);
	myWindow.moveTo(0,0);
	myWindow.focus();
}

function hiliteMe(trId, val, valColor)
{
	if(!val)
	{
		document.getElementById('allItems').checked = false;
		document.getElementById(trId).style.background=''
	}
	else
	{
		
		
		chk = checkAllCheckboxes('item_');
		document.getElementById(trId).style.background=valColor;
		
		//alert(chk?'all':'not all');
		//if(checkAllCheckboxes('item_'))
		document.getElementById('allItems').checked = chk;
	}
}

function rollTr(trId, valColor, typ)
{
	trId.style.background=(typ=='over')?valColor:'';
}

function checkAllCheck(prefix, num, val)
{
	for(i=1; i<=num; i++)
	{
		document.getElementById(prefix + String(i)).checked = val;	
	}
}

function highlightTr(prefixChkBox, prefixTr, num, valColor)
{
	for(i=1; i<=num; i++)
	{
		chk = document.getElementById(prefixChkBox + String(i)).checked;	
		document.getElementById(prefixTr + String(i)).style.background=(chk)?valColor:'';
	}
}

function checkAllCheckboxes(prefixChkBox)
{
	
	for(i=1; i<=totalNum; i++)
	{
		chk = document.getElementById(prefixChkBox + String(i)).checked;
		if(!chk)
		{
			return false;
		}
	}
	return true;
}

function getAllValue(prefixChkBox)
{
	listId = new Array();
	for(i=1; i<=totalNum; i++)
	{
		chk = document.getElementById(prefixChkBox + String(i)).checked;
		
		if(chk)
		{
			//alert('check');
			val = document.getElementById(prefixChkBox + String(i)).value;
			listId.push(val);
		}
	}
	if(listId.length)
	{
		val = listId.toString();
		setHtmlByIdValue('listItemIds', val);
	}
	else
		setHtmlByIdValue('listItemIds', '');
}
