function changeBgColor(element, color){
	element.style.backgroundColor= color;
}

/*A method to hide or show a column of a table.
Param 1 - table id
Param 2 - column #
Param 3 - 1 or 0 for show or hide
*/
function show_hide_column(table_id, col_no, do_show) {
		var stl;
    	if (do_show) stl = 'block'
    	else         stl = 'none';
		
		var tbl  = document.getElementById(table_id);
    	var rows = tbl.getElementsByTagName('tr');
    	for (var row=0; row<rows.length;row++) {
      		var cels = rows[row].getElementsByTagName('td')		
			cels[col_no].style.display=stl;
    	}
}

function checkboxToggle(formName, fieldName, checked){
	if(!document.forms[formName])
		return;
	var objCheckBoxes = document.forms[formName].elements[fieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes){
		objCheckBoxes.checked = checked;
	}else{
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++){
			objCheckBoxes[i].checked = checked;
		}
	}
}
 
function radioSelected(radiobutton){
		for (var i=0; i<radiobutton.length; i++) {
   			if (radiobutton[i].checked) 
				return true;
		}
		return false;
}

function popup(url, name, width, height, popupoptions){
	if(!popupoptions){
		popupoptions = "scrollbars=yes,resizable=yes,menubar=yes";
	}
	window.open(url, name, 'width=' + width + ',height=' + height + ',' + popupoptions);
}

//CODE FOR POPUP DIV
function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}
//END POPUP
function isChecked(checkboxes){
		for(i=0; i<checkboxes.length;i++){
			if(checkboxes[i].checked){
				return true;	
			}
		}
		return false;
}



