function MM_findObj(n, d) { //v4.01 
	var p,i,x;
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0 && parent.frames.length) {
  		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	} 
	if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n]; 
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document); 
	if(!x && d.getElementById)
		x=d.getElementById(n); 
	return x;
}

function getElement(id) {
	return (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
}
function displayToggle(id) {
	var lyr = getElement(id);
	if (lyr) {
		lyrcss = (lyr.style)? lyr.style: lyr;
		if (lyrcss.display == "none") {
			lyrcss.display = "";
		} else {
			lyrcss.display = "none";
		}
	}
}
function displayOff(id) {
	var lyr = getElement(id);
	if (lyr) {
		lyrcss = (lyr.style)? lyr.style: lyr;
		lyrcss.display = "none";
	}
}
function displayOn(id) {
	var lyr = getElement(id);
	if (lyr) {
		lyrcss = (lyr.style)? lyr.style: lyr;
		lyrcss.display = "";
	}
}

function displayOnly(id) {
	var lyr = getElement(id);
	var parent = lyr.parentNode;
	for (var i=0; i < parent.childNodes.length; i++) {
		if (parent.childNodes[i].nodeType == 1) {
			lyrcss = (parent.childNodes[i].style)? parent.childNodes[i].style: parent.childNodes[i];
			lyrcss.display = (parent.childNodes[i].id == id) ? "" : "none";
		}
	}
}
function makeChecked (id) {
	var obj = getElement(id);
	obj.checked = true;
}
function makeUnchecked (id) {
	var obj = getElement(id);
	obj.checked = false;
}
function toggleChecked (id) {
	var obj = getElement(id);
	if (obj.checked) {
		makeUnchecked(id);
	} else {
		makeChecked(id);
	}
}

function makeSelected(select_id, value) {
	var select_box = document.getElementById(select_id);
	
	for(var i = 0 ; i < select_box.length ; ++i)
	{
		if(select_box.options[i].value == value)
			select_box.selectedIndex = i;
	}
}
function makeMultiSelected(select_id, option_id) {
	var option = document.getElementById(option_id);
	option.selected = true;
}

function setFocus (id) {
	var obj = getElement(id);
	obj.focus();
}
function selectText (id) {
	var obj = getElement(id);
	obj.select();
}

function jumpSelect(id, url) {
	var obj = getElement(id);
	window.location=url+obj.options[obj.selectedIndex].value;
	return true;
}

function makeUpperCase(id) {
	var obj = getElement(id);
	obj.value = obj.value.toUpperCase();
}

function setClass(id, classname) {
	var obj = document.getElementById(id).className = classname;
}

function popWindow(url,name,width,height,scrollbars){
	popWindow_n = window.open(url,name,"left=20,top=20,screenX=20,screenY=20,menubar=false,location=false,scrollbars=" + (scrollbars ? "yes" : "false") + ",toolbar=false,width=" + width + ",height=" + height + ",status=false,resizable=0");
	popWindow_n.focus();
}

function highlight(row_id, checkbox_id, bgcolor) {
	if (document.getElementById(checkbox_id).checked) {
 		document.getElementById(row_id).style.backgroundColor = "lightgreen";
   	} else {
		document.getElementById(row_id).style.backgroundColor = bgcolor;
	}
}

function checkChecking(checkbox, parentCheckboxID) {
	
	if(document.getElementById(parentCheckboxID) != null) {
		if(document.getElementById(parentCheckboxID).checked == true) {
			alert("All checkboxes listed under "+document.getElementById(parentCheckboxID).nextSibling.nodeValue+" must be checked, since it is checked.");
			checkbox.checked = true;
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}

function formatRequired(id,field) {
	var obj = getElement('title_'+id+'_'+field);
	obj.innerHTML = '<b>*'+field.capitalize()+'</b>:';
}
String.prototype.capitalize = function(){ //v1.0
    return this.replace(/\w+/g, function(a){
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};


