
function getRegion(objCoun)
{
	var otherData = "counID=" + objCoun.value;
  
  ajaxCall("", "hasRegions", "lookups",hasRegionsCB, "",otherData);
}

function hasRegionsCB(content,type)
{
	if(type == 'string')
	{
	 	//has region defined, get region select drop down list
		if(parseInt(content) > 0)
		{
			getRegionList(content);
		}
		//no region defined, display text box for region
		else
		{
			getRegionText();
		}
	}
}
function getRegionList(counID)
{
  var otherData = "counID=" + counID +",selectName=selRegionInput";
  displayElement("divRegionText","hide")
  
  ajaxCall("", "getRegionSelect", "lookups",getRegionSelectCB, "",otherData)
  return;
}

function getRegionSelectCB(content, type)
{
  if(type == "string")
  {
  	 info = "<span style='font-size:8pt;'> * Required for USA and Canada</span>";
     document.getElementById("divRegionID").innerHTML = content + info;
     displayElement("divRegionID","show");
  }
  else
  {
    document.getElementById("errorDiv").innerHTML = content;
  }
}

function getRegionText()
{
	displayElement("divRegionID","hide");
	displayElement("divRegionText","show");
}

function proceedReg(process)
{
	if(typeof(getObj("txtRegionInput")) != 'undefined')
    getObj("txtRegion").value = getObj("txtRegionInput").value;
  
  if(typeof(getObj("selRegionInput")) != 'undefined')
    getObj("selRegionID").value = getObj("selRegionInput").value;
  getObj("Task").value = process;
  getObj("regForm").submit();

}
	
