function onAddNew(fieldName, srcTXT) {
	var fieldValue = document.f_Product[fieldName].value;
	
	if (fieldValue == "ADD") {
		document.getElementById("fieldNameShow").innerHTML = srcTXT;
		document.f_addNew.newFieldName.value = fieldName;
		document.f_addNew.newFieldNameTXT.value = srcTXT;
		document.f_addNew.newValue.value = "";
		//document.getElementById("wholeWindowDisable").style.height = "100%";
		//document.getElementById("wholeWindowDisable").style.width = "100%";
		document.getElementById("wholeWindowDisable").style.display = "";
		document.getElementById("addNewDiv").style.display = "";
		
		document.f_addNew.newValue.focus();
	}
}

function closeAddNew() {
	// HIDE
	document.getElementById("wholeWindowDisable").style.display = "none";
	document.getElementById("addNewDiv").style.display = "none";
}

function updateDropDown(fieldName, qID, qValue) {
	var currentOptions = document.f_Product[fieldName].options;
	var currentOptionLen = currentOptions.length;

	currentOptions[currentOptionLen] = new Option(qValue, qID, true, true);
	
	closeAddNew();
}


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function submitAddNew(dotdotpath, fieldName, fieldNameTXT, newTXT)
{
	var xmlHttp;
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX.");
	  return;
	  } 
	  
	var url=dotdotpath + "_include/asp/post_Game_PRE_AddNew.asp";
	url=url+"?q="+newTXT;
	url=url+"&table="+fieldNameTXT;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function stateChanged() 
	{ 
		if (xmlHttp.readyState==4)
		{
			var responseText = xmlHttp.responseText;
			
			var responseTextArray = responseText.split(",");
			
			var qID = responseTextArray[0];
			var qValue = responseTextArray[1];
		
			updateDropDown(fieldName, qID, qValue);
		}
	}
} 

function creditPersonSearch(dotdotpath, newTXT, e) {
	var code = (e.charCode) ? e.charCode :
       ((e.keyCode) ? e.keyCode :
       ((e.which) ? e.which : 0));
	   
	// IGNORE THESE KEYS
	
	
	// HANDLE ARROW KEYS
	if (1 == 2) {//code == 40) {
		/*
		newTR=document.getElementById("tr"+(++position));
        oldTR=document.getElementById("tr"+(--position));
        // deselect the old selected suggestion   
        if(position>=0 && position<suggestions-1)
          oldTR.className = "";
 
        // select the new suggestion and update the keyword
        if(position < suggestions - 1)
        {
          newTR.className = "highlightrow";
          updateKeywordValue(newTR);
          position++;         
        }     
        e.cancelBubble = true;
        e.returnValue = false;
        isKeyUpDownPressed = true;        
        // scroll down if the current window is no longer valid
        if(position > maxVisiblePosition)
        {   
          oScroll = document.getElementById("scroll");
          oScroll.scrollTop += 18;
          maxVisiblePosition += 1;
          minVisiblePosition += 1;
        }
		*/
	}
	// ELSE QUERY DB
	else {
		var xmlHttp;
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX.");
		  return;
		  } 
		  
		var url=dotdotpath + "_include/asp/get_Credit_Person_Suggest.asp";
		url=url+"?q="+newTXT;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	
	function stateChanged() 
	{ 
		if (xmlHttp.readyState==4)
		{
			var ss = document.getElementById("creditPersonSearchSuggest");
			ss.innerHTML = '';
			var str = xmlHttp.responseText.split(",");
			
			if (str.length > 1) {
				ss.style.visibility = "visible";
			} else {
				ss.style.visibility = "hidden";
			}
			
			for(i=0; i < str.length - 1; i++) {
				//Build our element string.  This is cleaner using the DOM, but
				//IE doesn't support dynamically added attributes.
				if (str[i] != "") {
					var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
					suggest += 'onmouseout="javascript:suggestOut(this);" ';
					suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
					suggest += 'class="suggest_link">' + str[i] + '</div>';
				}
				ss.innerHTML += suggest;
			}
		}
	}
}

function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}
function setSearch(value) {
	document.getElementById('creditPerson').value = value;
	document.getElementById('creditPersonSearchSuggest').innerHTML = '';
	document.getElementById('creditPersonSearchSuggest').style.visibility = "hidden";
}

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}