
// Locates objects in the form.
function JJ_findObject(objName, docType) { //v1.01
	var i;  
	if(!docType) docType=document; 
	
	var p = objName.indexOf("?")
	if(p>0 && parent.frames.length) {
		docType=parent.frames[objName.substring(p+1)].document; 
		objName=objName.substring(0,p);
	}
	
	var explorerObject = docType[objName]
	if(!explorerObject && docType.all){ explorerObject=docType.all[objName]; }
	
	for(i=0; !explorerObject && i<docType.forms.length; i++){ explorerObject = docType.forms[i][objName]; }
	for(i=0; !explorerObject && docType.layers && i<docType.layers.length; i++) explorerObject = JJ_findObject(objName,docType.layers[i].document);
	if(!explorerObject && docType.getElementById){ explorerObject=docType.getElementById(objName); }
	
	return explorerObject;
}

function autoPopulateSelects(selectName, setValue){ // ver 1.4- Cross-Browser Compatible + FindObject
	var targetObject = JJ_findObject(selectName)
	for(i=0; i<targetObject.length; i++){ if(targetObject.options[i].value == setValue){ targetObject.options[i].selected = true; }}
}

function trim(stringToTrim){
	var startPoint = stringToTrim.length;
	var endPoint = stringToTrim.length;
	for(var i=0; i<stringToTrim.length; i++) if(stringToTrim.charCodeAt(i) != 32){startPoint = i; break;}
	for(var i=stringToTrim.length-1; i>=0; i--) if(stringToTrim.charCodeAt(i) != 32){endPoint = i; break;}
	return stringToTrim.slice(startPoint, endPoint + 1);
}