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 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 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;
		//if(checkAllCheckboxes('item_'))
		//	document.getElementById('allItems').checked = chk;
	}
}

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

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

function populate(val,selectChildObj, parentArray)
{
	//var citySelect = document.searchform.city;
	selectChildObj.options.length = 0;
	if(val == '')
	{
		//citySelect.options[0] = new Option(obj[i],(i + 1));
		selectChildObj.disabled = true;
		return
	}
	mother = parentArray[val-1];
	
	obj = eval(mother);
	
	selectChildObj.disabled = false;
	for(i=0; i<obj.length;i++)
	{
		selectChildObj.options[i] = new Option(obj[i][0],obj[i][1]);
	}
}

function submitCheck(act)
{
	document.getElementById('cmd').value = '';
	if(act)
	{
		document.lalunaForm.action = act;
	}
	document.lalunaForm.submit();
}

function setImage(imgId, source)
{
	document.getElementById(imgId).src=source;
}


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

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

function popUpWindow(url, winName, w, h) 
{
	win = window.open( url, winName, 
	"status = 1, height = " + h + ", width = " + w + ", resizable = 0, scrollbars=1" )
	win.focus();
}

function sendOrder()
{
	//alert(totalCost)
	msg = "You have not reached the minimum order value. \nWould you still like to checkout?";
	if(totalCost < minCost)	
	{
		var answer = confirm(msg);
		if (answer)
		{
			document.finalForm.submit();
		}
		else
		{
			//alert("Thanks for sticking around!")
			return false;
		}
	}
	else
	document.finalForm.submit();
}

var currentResources = '';
function toogle(divName)
{
	if(typeof(document.getElementById(divName)) == 'undefined') alert('Object not found!');
	if(document.getElementById(divName).style.display == 'none')
		document.getElementById(divName).style.display = '';
	else
		document.getElementById(divName).style.display = 'none';
		
	if(currentResources)
	{
		//alert(currentResources)
		if(currentResources != divName)
		{
			document.getElementById(currentResources).style.display = 'none';
			currentResources = divName;
		}
	}
	else
	currentResources = divName;
	
	
}
	
