var bName = navigator.appName;
var targetControl = "";
var text = "";

function startQ9(layerName, fieldName){
	if (targetControl == "")
		targetControl = setTargetObject (layerName, fieldName);
	startUpText = eval(targetControl + ".value");
	if (startUpText == "")
		startUpText = "";
	document.q9Demo.startQ9(startUpText);
}

function setFormName (layerName, fieldName){
	targetControl = setTargetObject (layerName, fieldName);
	text = eval(targetControl + ".value");
	if( document.q9Demo.checkExist() == false)
		return;
	eval(targetControl + ".blur()");
	if (text == "") {
		text = "";
	}
	setTimeout("document.q9Demo.requestFocus (text)", 80);
}

function setTargetObject(targetLayer, targetObject){
	if (targetLayer != "") {
		//Used to handle multiple layer
		tempString = "";
		for (i=0; i<100; i++){
			j = targetLayer.indexOf(".", i);
			if (j == -1){
				tempString = tempString.concat(targetLayer.substring(i, targetLayer.length));
				break;
			}
			else
				tempString = tempString.concat(targetLayer.substring(i, j+1));				
			if (bName == "Netscape") 
				tempString = tempString.concat("document.");
			else
				tempString = tempString.concat("document.all.");
			i = j;
		}
		targetLayer = tempString;

		if (bName == "Netscape") {
			targetObject = "document.layers." + targetLayer + ".document." + targetObject;
		} else {
			targetObject = "document.all." + targetLayer + ".document." + targetObject;
		}
	}
	else {
		targetObject = "document." + targetObject;
	}
	return targetObject;
}

function getBrowser(){
	if (bName == "Netscape") {
		document.q9Demo.setBrowser("Netscape");
	} else {
		document.q9Demo.setBrowser("IE");
	}
}
function output (input){
	eval(targetControl + ".value=input");
}

