function populateSection() {
	//alert("populate");
	if (document.forms[0].parcel_id.value.length>=4) {
		document.forms[0].section_num.value=document.forms[0].parcel_id.value.substring(2, 4);
	}
}
/***************************************************************
* Function: saveWOption 								   
* Description: This function is used by the save functionality #
****************************************************************/  
function saveWOption(soption) {
	//do basic validation
	//check township
	if(document.forms[0].township.selectedIndex == 0)
	{
		alert("Before you save, you have to select a valid township");
		document.forms[0].township.focus();
		return ;
	}	
	if(document.forms[0].parcel_id.value=="")
	{
		alert("Before you save, you have to enter a parcel ID");
		document.forms[0].parcel_id.focus();
		return ;
	}
	//alert("saving all the information");
	document.forms[0].option.value = soption ;
	document.forms[0].action.value = "SAVE" ;
	document.forms[0].submit();	
}




/***************************************************************
* Function: toUpperCaseSTR(Object)  								   
* Description: This function will check for a valid Application #
****************************************************************/  
function toUpperCaseSTR(object)  
{	  
     object.value = object.value.toUpperCase();
	 return ;
}  

/***************************************************************
* Function: isValidApplID(num)  								   
* Description: This function will check for a valid Application #
****************************************************************/  
function isValidApplID(num)  
{	  
        if (num.length < 8 || !isValidInt(num))
		{
             return false;
		}
	 return true;
}  

/***************************************************************
* Function:  isValidParcelID(num)								   
* Description: This function will check for a valid Parcel ID 
****************************************************************/ 
function isValidParcelID(num)
{	  
        if (num.length < 10 || !isValidInt(num))
		{
             return false;
		}
	 return true;
}  

/***************************************************************
* Function: isPermitNO(num)								   
* Description: This function will check for a valid Permit #
****************************************************************/
function isPermitNO(num)
{	  
        if (num.length < 11 || !isValidInt(num))
		{
             return false;
		}
	 return true;
}  

/***************************************************************
* Function: isValidFloat(num)								   
* Description: This function will check for a valid Float
****************************************************************/
function isValidFloat(num)
{	  
       var valid = "0123456789.";
	var temp;
	for (var i = 0; i < num.length; i++)
		{
		temp = num.substring(i, i + 1);
		if (valid.indexOf(temp) == "-1")
		{
		
		return false;
		}
	}
	return true;
}  
/***************************************************************
* Function: isValidInt(num)								   
* Description: This function will check for a valid Integer
****************************************************************/
function isValidIntLogon(num)
{   
 	var valid = "-0123456789GISgis";
	var temp;
	for (var i = 0; i < num.length; i++)
		{
		temp = num.substring(i, i + 1);
		if (valid.indexOf(temp) == "-1")
		{
			return false;
			}
	}
	return true;	  
		 
}
/***************************************************************
* Function: isValidInt(num)								   
* Description: This function will check for a valid Integer
****************************************************************/
function isValidInt(num)
{   
 	var valid = "0123456789";
	var temp;
	for (var i = 0; i < num.length; i++)
		{
		temp = num.substring(i, i + 1);
		if (valid.indexOf(temp) == "-1")
		{
			return false;
			}
	}
	return true;	  
		 
}

/***************************************************************
* Function: isValidPhoneNumber(num)								   
* Description: This function will check for a valid PhoneNumber
****************************************************************/
function isValidPhoneNumber(num)
{	    
	     
		if (num.length <10 || !isValidNumber(num))
			{
				return false; 
			}
		 
    return true; 
}

/***************************************************************
* Function: isValidZipCode(num)								   
* Description: This function will check for a valid Zipcode
****************************************************************/
function isValidZipCode(num)
{
	    
		if (num.length < 5 || !isValidNumber(num))
			{
				return false; 
			}
		 
    return true; 
}

/***************************************************************
* Function: isValidLimit(num,limit)								   
* Description: This function will check for a valid limit
****************************************************************/
function isValidLimit(field,limit)
{
	 
		if (field.value.length < 0 || field.value.length > limit)
			{	field.focus();
				return false; 
			}
		 
    return true; 
}


/***************************************************************
* Function: trim(str)								   
* Description: This function will trim the spaces in a string
****************************************************************/
function  trim(str)
{ 
  var startingPos=-1;
  var endPos=-1; 
  var strLength = str.length;
  for(var i=0;i<strLength;i++)
   {
	 if(startingPos == -1 && str.charAt(i) != ' ')
        {
        startingPos=i;
	 }
       if(endPos == -1 && str.charAt((strLength-i)) != ' ')
        {
        endPos=strLength-i;
	 }
	if(startingPos > -1 && endPos > -1)
	{
	 return str.substring(startingPos,endPos);
	}
 
  }

return "";
 }	  
 
 function y2k(number)
 { return (number < 1000) ? number + 1900 : number; }
/**/
var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
/**/


/***************************************************************
* Function: getCurrentDate()								   *
* Description: This returns current date in mm/dd/yyyy format. *
****************************************************************/
function getCurrentDate()
 {
 var today = new Date();
 var day   = today.getDate();
 var month = today.getMonth() + 1;
 var year  = y2k(today.getYear());

 if ( month <=  9)
    {month = "0" + month;}

 if (day <= 9)
    {day  = "0" + day;}

 var mydate =  month + "/" + day + "/" + year;
 return mydate;
 }

/***************************************************************
* Function: validateEmail(emailStr)							   *
* Description:												   *
****************************************************************/
 <!-- Begin
function validateEmail(emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->

function isValidNumber(num)
{
    var valid = "0123456789";
	var temp;
	for (var i = 0; i < num.length; i++)
		{
		temp = num.substring(i, i + 1);
		if (valid.indexOf(temp) == "-1")
		{
			return false;
			}
	}
	return true;

}


function checkInt(evt, field)
{
 charCode = evt.keyCode;
 if(charCode != 13 && (charCode<48  || charCode > 57))
 {
	alert("Please enter a number!");
	evt.keyCode= null;  
	return false;
 }
 else 
	return true;
}
 
function checkFloat(evt, field)
{
	charCode = evt.keyCode;
	if((field.value).indexOf(".")!=-1 && charCode==46 && charCode != 13)
	{
		alert("You can only have one decimal point.");
		evt.keyCode= null;  
		return false;
	}
	if(!(charCode == 46 || (charCode >= 48  && charCode <= 57) || (charCode == 13)) )
	{
		alert("Please enter a valid number.");
		evt.keyCode = null;
		return false;
	} 
	return true;
}


   
/***************************************************************
* Function: getFormPos(formName)                                                                                                                             *
* Description: will get form number                                                                                                                              *
****************************************************************/
function getFormPos(formName)
{
	for (var i = 0; i < document.forms.length; i++)
	{
		if (formName == document.forms[i].name)
		{
			return i;
		}
	}
}
/****************************************************************
* Function: getElementPos(formNo, elementName)                                                                                                 *
* Description: will get element position within the given form                                                                               *
*****************************************************************/
function getElementPos(formNo, elementName)
{
	 
	for (var i = 0; i < document.forms[formNo].length; i++)
	{
		if (elementName == document.forms[formNo].elements[i].name)
		{
			return i;
		}
	}
}
/****************************************************************
* Function: setDropDownIndex(formPos, elementPos, selField)                                                                          *
* Description: will set index for a drop down                                                                                                             *
****************************************************************/
function setDropDownIndex(formPos, elementPos, selField)
{
	var selected_dep_index = 0;
	var checked = false;
	 
	for (var j = 0; j < window.document.forms[formPos].elements[elementPos].length; j++)
	{
		if (selField == window.document.forms[formPos].elements[elementPos].options[j].value)
		{
			selected_dep_index = j;
			checked = true;
			break;
		}
	}
	if (checked)
	{
		window.document.forms[formPos].elements[elementPos].selectedIndex = selected_dep_index;
	}
	else
	{
		window.document.forms[formPos].elements[elementPos].selectedIndex = 0;
	}
}
/*******************************************************************
* Function: setDropDown(formName, elementName, selField)                                                                             *
* Description: will set index for a drop down for given element                                                                            *
********************************************************************/
function setDropDown(formName, elementName, selField)
{	
	var selected_dep_index = 0;
	var checked = false;
	var tempObj = eval("window.document."+formName+"." +elementName);  
	for (var j = 0; j < tempObj.length; j++)
	{
		if (selField == tempObj.options[j].value)
		{
			selected_dep_index = j;
			checked = true;
			break;
		}
	}
	if (checked)
	{
		tempObj.selectedIndex = selected_dep_index;
	}
	else
	{ 
		tempObj.selectedIndex = 0;
	} 
}
/*******************************************************************
* Function: setDropDown(formName, elementName, selField)                                                                             *
* Description: will set index for a drop down for given element                                                                            *
********************************************************************/
function setDropDownInParent(formName, elementName, selValue)
{
    
     var selected_dep_index = 0;
	 var checked = false;
	 var tempObj = eval("window.opener.document."+formName+"." +elementName);
	 
	for (var j = 0; j < tempObj.length; j++)
	{
		if (selValue == tempObj.options[j].value)
		{
			selected_dep_index = j;
			checked = true;
			break;
		}
	}
	if (checked)
	{
		tempObj.selectedIndex = selected_dep_index;
	}
	else
	{
		tempObj.selectedIndex = 0;
	}
}

/***************************************************************************************
* Function: empNametoCaps(empName)                                                                             *
* Description: This Function will Convert the First Alphabet and Last Alphabet to Caps                    *
***************************************************************************************/

function empNametoCaps(empName)
{
	var tempStr= empName ;
	var len=empName.length;
	var name =   empName.substr(0,1).toUpperCase()+empName.substr(1,len-2)+" "+ (empName.substr(empName.length - 1)).toUpperCase();
	return name;   
}

/**********************************************************************************
* Function: isGreaterThanToday(givenDate)        *                                                                  *
* Description: This Function will check if given date is greater than today's date								                    *
***********************************************************************************/
function isGreaterThanToday(givenDate)
{
	var today = new Date(); // today
	var valdate = new Date(givenDate); // your launch date
	if (today.getTime() < valdate.getTime()) 
		{  
			 return true;
		}
	return false;	
 }
  
 /**********************************************************************************
 * Function: isGTCurrentDate(givenDate)                 
 * Description: This Function will check if given date is greater than today's date
 ***********************************************************************************/
function isGTCurrentDate(givenDate)
{ 
	if ( new Date(givenDate).getTime() >  new Date(getCurrentDate()).getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }

 /****************************************************************************************
 * Function: isGTECurrentDate(givenDate)               
 * Description: This Function will check if given date is greater or equal to today's date
 *****************************************************************************************/
function isGTECurrentDate(givenDate)
{
	if ( new Date(givenDate).getTime() >=  new Date(getCurrentDate()).getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }

 /****************************************************************************************
 * Function: isGTECurrentDate(givenDate)               
 * Description: This Function will check if given date and time 
   is greater than today's date and time 
 *****************************************************************************************/
function isGTCurrentDateTime(givenDateTime)
{
	if ( new Date(givenDateTime).getTime() >  new Date().getTime()) 
	 {  
	  return true;
	 }
	return false;	
}

 /****************************************************************************************
 * Function: isGTECurrentDateTime(givenDateTime)            
 * Description: This Function will check if given date and time 
   is greater or equal to today's date and time 
 *****************************************************************************************/
function isGTECurrentDateTime(givenDateTime)
{
	if ( new Date(givenDateTime).getTime() >=  new Date().getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }

 /****************************************************************************************
 * Function: isLTCurrentDate(givenDate)         
 * Description: This Function will check if given date  
   is less than  today's date 
 *****************************************************************************************/
function isLTCurrentDate(givenDate)
{ 
	if ( new Date(givenDate).getTime() <  new Date(getCurrentDate()).getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }

 /****************************************************************************************
 * Function: isLTECurrentDate(givenDate)         
 * Description: This Function will check if given date  
   is less than or equal to  today's date 
 *****************************************************************************************/
function isLTECurrentDate(givenDate)
{
	if ( new Date(givenDate).getTime() <=  new Date(getCurrentDate()).getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }

 /****************************************************************************************
 * Function: isLTCurrentDateTime(givenDate)         
 * Description: This Function will check if given date and time 
   is less than  today's date and time
 *****************************************************************************************/
function isLTCurrentDateTime(givenDateTime)
{
	if ( new Date(givenDateTime).getTime() <  new Date().getTime()) 
	 {  
	  return true;
	 }
	return false;	
}

 /****************************************************************************************
 * Function: isLTECurrentDateTime(givenDate)         
 * Description: This Function will check if given date and time 
   is less than or equal to  today's date  and time
 *****************************************************************************************/
function isLTECurrentDateTime(givenDateTime)
{
	if ( new Date(givenDateTime).getTime() <=  new Date().getTime()) 
	 {  
	  return true;
	 }
	return false;	
 }
 
/*****************************************************************************
* Function: Date1GTEDate2(dt1,dt2)                                                                          
* Description: This Function will Compare two Dates for Greater Than or equal		       		 
******************************************************************************/

function Date1GTEDate2(dt1,dt2)    
{

	if (new Date(dt1).getTime() >=  new Date(dt2).getTime())  
	 {  
	  return true;     
	 }
	return false;	
 }

/*****************************************************************************
* Function: Date1GTEDate2(dt1,dt2)                                                                          
* Description: This Function will Compare two Dates for Greater Than or equal		       		 
******************************************************************************/
function Date1LTEDate2(dt1,dt2)    
{

	if (new Date(dt1).getTime() <=  new Date(dt2).getTime())  
	 {  
	  return true;     
	 }
	return false;	
 }
 
/*****************************************************************************
* Function: Date1GTEDate2(dt1,dt2)                                                                          
* Description: This Function will Compare two Dates for Greater Than or equal		       		 
******************************************************************************/
function Date1GTDate2(dt1,dt2)   
{
	if (new Date(dt1).getTime() > new Date(dt2).getTime())  
	 {  
	  return true;     
	 }
	return false;	
 } 
 
/*****************************************************************************
* Function: Date1GTEDate2(dt1,dt2)                                                                          
* Description: This Function will Compare two Dates for Greater Than or equal		       		 
******************************************************************************/
function Date1LTDate2(dt1,dt2)
{
	if (new Date(dt1).getTime() < new Date(dt2).getTime())    
	 {  
	  return true;     
	 }
	return false;	
 } 

/***********************************************************
* Function: compareDate(givenDate)                      *                                            
* Description: This Function will Compare Dates			*		 
************************************************************/

function compareDate(Date1,Date2)    
{
	var DateOne = new Date(Date1); // today
	var Datetwo = new Date(Date2); // your launch date
	

	if( DateOne.getTime() == Datetwo.getTime())
		{
			 return false;  
		}
	 
	if ( DateOne.getTime() <  Datetwo.getTime())  
		{  
			 return true;     
		}
	return false;	
 }
 

/*****************************************************
* Function:   submitMenuItem(option)                 *
* Description: This Function will Submit a menu item *									                    *
******************************************************/

function submitMenuItem(option)
{
document.forms[0].option.value = option;   
document.forms[0].submit(); 
} 
function submitMenuItem(option,searchOption,pageID,mode)
{
	document.forms[0].pageID.value = pageID; 
	document.forms[0].option.value = option; 
	document.forms[0].searchOption.value = searchOption;  
	document.forms[0].naviPath.value = mode;   
	document.forms[0].submit(); 
}
/********************************************************************************
* Function: submitTab(pageid,option,servletTosubmit,searchTitle,requiredTabMenu)                                                                          
* Description: This Function will submit tabForm		       		 
*********************************************************************************/
function submitTab(pageid,option,servletTosubmit,searchTitle,tooltip,requiredTabMenu) 
 {
	 if (document.tabForm.DummyPageInd.value == 'Y' || document.tabForm.GenInfoExists.value == 'N'){
	 	alert("General Information has not been saved or submitted");
		return;
	 }
	 document.tabForm.pageID.value = pageid;   
	 document.tabForm.option.value = option;  
	 document.tabForm.searchTitle.value = searchTitle;
//	 alert(document.tabForm.searchTitle.value);
	 if (searchTitle.indexOf("DryHoleView") > -1) {
		document.tabForm.sub_well_type.value = "DRYHOL" 
	 }
	 if (searchTitle.indexOf("Create") > -1){
	 	document.tabForm.searchValue.value = document.forms[0].appl_id_nbr.value;
		document.tabForm.appl_id_nbr.value = document.forms[0].appl_id_nbr.value; 
		document.tabForm.naviPath.value = "create";
		
		if (requiredTabMenu == "ARCreateWLToGeneralInfoC")
		{
			document.tabForm.well_type.value = 'REPLAC';       
		}else if (searchTitle.indexOf("General") > -1){
			document.tabForm.well_type.value = "General";
			document.forms[0].well_type.value = "General";
		}else if (document.forms[0].well_type.value == 'DRYHOL'){
			document.tabForm.well_type.value = document.forms[0].pageWellType.value; 
		}else if (document.forms[0].well_type.value == 'ABND'){
			document.tabForm.well_type.value = 'REPLAC';  
		}
		if(document.forms[0].ocWellID !=null){
		 	document.tabForm.ocWellID.value = document.forms[0].ocWellID.value;
		 }
	 	if(document.forms[0].oc_well_id !=null){
		 	document.tabForm.oc_well_id.value = document.forms[0].oc_well_id.value;
		 }
	 	if(document.forms[0].forced_oc_well_id !=null){
		 	document.tabForm.oc_well_id.value = document.forms[0].forced_oc_well_id.value;
		 }
		
	 }else if (searchTitle.indexOf("View") > -1){
	    if (searchTitle.indexOf("General") > -1){
			document.tabForm.well_type.value = "General";
		}else if (searchTitle.indexOf("Abandment") > -1){
			document.tabForm.well_type.value = "REPLACABND";
			document.tabForm.searchValue.value = document.forms[0].appl_id_nbr.value; 
		}else if (searchTitle.indexOf("Dry") > -1){
			document.tabForm.well_type.value = "DRYHOL";
		}else if (searchTitle.indexOf("Pump") > -1){
			document.tabForm.well_type.value = "PUMPINFO"; 
		}
//Jody.  I question this line because it's passing the navipath around and maybe it shouldn't be...
	 	document.tabForm.naviPath.value = "view";
	 	if(document.forms[0].ocWellID.value!=null)
		 	document.tabForm.ocWellID.value = document.forms[0].ocWellID.value;
		document.tabForm.appl_id_nbr.value = document.forms[0].appl_id_nbr.value;
		if(document.forms[0].curPageId.value == "dryHoleInfo"){
			document.tabForm.ocWellID.value = document.forms[0].oc_well_id.value; 
		}
	 }else{
	 	document.tabForm.naviPath.value = "leftMenu"; 
	 }
	 if(searchTitle == "AbandmentCreate"){
			document.tabForm.well_type.value = "REPLACABND"
		} 
	 if (document.tabForm.well_type.value == ""){ 
	 	document.tabForm.well_type.value = document.forms[0].well_type.value; 
	 }
	 document.tabForm.pageMenuBar.value = requiredTabMenu; 
	 document.tabForm.action="/EHLT0003/EHS.WL";
	 document.tabForm.submit(); 
 }  
/********************************************************************************
* Function: displayPhoneNo(DisPhNo)                                                                       
* Description: This Function will format and display the phone number  		       		 
*********************************************************************************/
function displayPhoneNo(DisPhNo)
{
	var DisPhoneNo = "";
	if(DisPhNo != "" && DisPhNo.length  == 10){
			DisPhoneNo = "("+DisPhNo.substring(0,3)+")"+DisPhNo.substring(3,6)+"-"+DisPhNo.substring(6,10);
			return DisPhoneNo;
	}else{
		return DisPhNo ;    
	}
}

/*****************************************************************************************
* Function: formatPhoneNo(PhoneNo)                                                                    
* Description: This Function will format and display the phone number for key press event 		       		 
******************************************************************************************/
function formatPhoneNo(PhoneNo)    
{
	PhNo = PhoneNo.value;
	if(PhNo.length == 1){
		PhoneNo.value = "("+PhNo ;
	}
	if(PhNo.length == 4){
		PhoneNo.value = PhNo+")" ;
	}
	if(PhNo.length == 8){
		PhoneNo.value = PhNo+"-" ;
	}
}

/*****************************************************************************************
* Function: mergePhoneNo(PhoneNoObj)                                                                      
* Description: This Function will merge the phone number for submission
******************************************************************************************/
function mergePhoneNo(PhoneNoObj){
	var PNo = PhoneNoObj.value;
	return PNo.substring(1,4)+PNo.substring(5,8)+PNo.substring(9,13);
}

function mergePhoneNoForHidden(PNo){
	 if (PNo != "" && PNo.length == 13){
			return PNo.substring(1,4)+PNo.substring(5,8)+PNo.substring(9,13);
	}else{
		return PNo;
	}
}


/*****************************************************************************************
* Function: displayParcelIdNo(ParcelVal)                                                               
* Description: This Function will format and display the Parcel Id   		       		 
******************************************************************************************/
function displayParcelIdNo(ParcelVal)
{
	var ParcelNo = ParcelVal.substring(0,2)+"-"+ParcelVal.substring(2,4)+"-"+ParcelVal.substring(4,7)+"-"+ParcelVal.substring(7,10);
	return ParcelNo;
}

/*****************************************************************************************
* Function: formatParcelId(Parcel_id)                                                                  
* Description: This Function will format and display the Parcel Id for key press event 		       		 
******************************************************************************************/
function formatParcelId(Parcel_id)
{
	ParcelId = Parcel_id.value;    
	if(ParcelId.length == 2)
	{
		Parcel_id.value = ParcelId + "-";
	}
	if(ParcelId.length == 5)
	{
		Parcel_id.value = ParcelId + "-";
	}
	if(ParcelId.length == 9)
	{
		Parcel_id.value = ParcelId + "-";   
	}
}

/***********************************************************************************
* Function: mergeParcelId(ParcelNo)                                                                      
* Description: This Function will merge the Parcel Id for submission
***********************************************************************************/
function mergeParcelId(ParcelNo)
{
var Parcel_No = ParcelNo.substring(0,2)+ParcelNo.substring(3,5)+ParcelNo.substring(6,9)+ParcelNo.substring(10,13);
return Parcel_No;
}

/***********************************************************************************
* Function: displayNull(fieldName)                                                                   
* Description: This Function will display "" if value  is 0.0
***********************************************************************************/
function displayNull(fieldName)
{    
alert(fieldName + " = "  +  fieldName.value)
	if(fieldName.value == "0.0")
	{
		fieldName.value = "";
    }
alert(fieldName + " = "  +  fieldName.value)
}

function GetCookies() {
    // Get cookies
     var  ck = document.cookie;
     var  ix=0;
     //
     // split the cookie string at ";"
     //
     var strs = ck.split (';');
     for (ix=0; ix <strs.length; ix++) {
          //document.write ("<br><br>Cookie " + ix + " " + unescape(strs[ix]));
          //split current strs[ix] at "="
          var ckvar= strs[ix].split('=');
          //
          // Write the current document.
          //
          document.write ("<br>Cookie Name " + ckvar[0]);
          //
          // Get cookie value;
          //          
          GetCookieValue(ckvar[0]);
     }
     return ;
}
// this function gets the cookie, if it exists
function GetCookieValue(cookiename)
{
    // get all cookies
     
     var  ck = document.cookie;
     // append "=" to cookiename
     var  cn = cookiename + "=";
     // search for cookie
     var pos = ck.indexOf (cn);
     // if found 
     if (pos != -1) {
             // set start location
             var start = pos + cn.length;
               // Get the end of cookie, start search from 'start' position.
               var end   = ck.indexOf (";", start);
               // If end not found, set the end location equal to cookies length.               
               if (end == -1) end = ck.length;
               //
               // Get Value of Cookies
               //
               var cookieValue= ck.substring (start, end);
               //
               // Write the current document.
               //
               document.write  ( "<br>Cookie value : " + unescape (cookieValue));
     }
     return;
}
// Delete cookie

function DeleteCookie(cookiename)
{
     if (!cookiename.length) {
           alert ('No cookie name specified'); 
          return;
     } 
    // Get All cookies;
     var  ck = document.cookie;

     // append "=" to cookiename
     
     var  cn = cookiename + "=";
     
     // Get cookie
     
     var pos = ck.indexOf (cn);
     // Cookie found 

     if (pos != -1) {
             // Set the start location for substring
             var start = pos + cn.length;
               // Get the end of cookie, start search from 'start' position.
               var end   = ck.indexOf (";", start);               
               // If end not found, set the end location equal to cookies length.
               if (end == -1) end = ck.length;
               //
               // Get Value of Cookies
               //
               var cookieValue= ck.substring (start, end);
			   
               //alert ( "Cookie value : " + unescape (cookieValue));
               //create an instance of the Date object  
               var expDate = new Date(); 
               //set the date value to the past 
               expDate.setTime(expDate.getTime() - 1000 * 60 * 60 * 24 * 365); 
               //convert date to a GMT string 
               expDate = expDate.toGMTString(); 
			  // alert( unescape(expDate));
               // recreate cookie string               
              var cookieString = cookiename + "=" + cookieValue + ";expires=" + expDate; 
			   
			   
			   //alert ( "cookieString value : " + unescape (cookieString));
               // update cookie
               document.cookie = cookieString; 
     }
     return;
}


/***********************************************************************************
* Function: logout()                                                                 
* Description: This Function will make the user to exit from the application
***********************************************************************************/
function logout()
{
//alert(document.forms[0].UserType.value);    
	 
	 if(document.forms[0].UserType.value >2)
 	{
		if (window.confirm("Want to logout"))   
		 {       
		    document.forms[0].action = "/EHLT0003/ehealthWellLog/jsp/EHSLogout.jsp";  
 		 	document.forms[0].submit();      
		 }     
   	}
	else
 	{
	 if (window.confirm("Want to logout"))                              
 		{
		 	document.forms[0].action.value = "/EHLT0003/EHS.WL";
 		 	document.forms[0].option.value = 0; 
 		 	document.forms[0].submit();
		}
	 }
	 
  //document.forms[0].submit();
	 
	 
	 
 
 
/*
if (window.confirm("Want to logout"))                              
 {
	  //Netegrity  set the date value to the past 
	  DeleteCookie( "SMSESSION" );
	  DeleteCookie( "SMIDENTITY" );
	   DeleteCookie( "JSESSIONID" );
	     DeleteCookie( "__utma" );
	    DeleteCookie( " __utmz" );
	    DeleteCookie( " __utmb" );
	    DeleteCookie( " __utmc" );





	
 

  
 }*/
} 



/***********************************************************************************
* Function: isValidateCommentsLen(tempString)                                                                 
* Description: This Function will check for comments less than 1000 chars
***********************************************************************************/
function isValidateCommentsLen(tempString)  
	{
			
		if (tempString.length > 1000)
		{
			return true;    				
		}
		else
		{
			return false;
		}
		
	}

/**********************************************************************************************
* Function: formatRegnNo(Regn_No)                                                                
* Description: This Function will format and display the well Driller Regn #for key press event 		       		 
**********************************************************************************************/
function formatRegnNo(Regn_No)  
{	
	RegnNo = Regn_No.value;    
	if(RegnNo.length == 2)
	{
		Regn_No.value = RegnNo + "-";

	}
}

/*****************************************************************************
* Function: formatRegnNo(Regn_No)                                                                
* Description: This Function will merge the well Driller Regn # for submission 		       		 
*****************************************************************************/
function mergeRegnNo(Regn_No)
{
var RegnNo = Regn_No.substring(0,2)+Regn_No.substring(3,7);
return RegnNo;  

}

/*****************************************************************************
* Function: editCheck(fieldToBeEdited,checkField)                                                                
* Description: This Function will check the checkfield to allow editing on
* required field 		       		 
*****************************************************************************/
function editCheck(fieldToBeEdited,checkField)
{
 
 if(eval("document.forms[0]."+checkField+".checked"))
 {
    eval("document.forms[0]."+fieldToBeEdited+".disabled = false") ;	
 }
 else
 {
   eval("document.forms[0]."+fieldToBeEdited+".disabled = true") ;
 }
}

/*****************************************************************************
* Function: enableField(fieldName)                                                               
* Description: This Function will  enable the given field
*****************************************************************************/
function enableField(fieldName)
{ 
  eval("document.forms[0]."+fieldName+".disabled = false") ;	 
}
/*****************************************************************************
* Function: disableField(fieldName)                                                               
* Description: This Function will  enable the given field
*****************************************************************************/
function disableField(fieldName)
{ 
  eval("document.forms[0]."+fieldName+".disabled = true") ;	 
}
/*****************************************************************************
* Function: editCheck(fieldToBeEdited,checkField)                                                                
* Description: This Function will check the checkfield to allow editing on
* required field 		       		 
*****************************************************************************/
function validateEditing(fieldvalue,checkField)
{ 
 if(fieldvalue.length > 0)
 {
    eval("document.forms[0]."+checkField+".disabled = true") ;	
 }
 else
 {
   eval("document.forms[0]."+checkField+".disabled = false") ;
 }
}

/**********************manadatorty Stars*********************************/

	function showStar(fieldName)
	{
			var mandatoryStar = eval('document.all["'+fieldName+'"].style');
			mandatoryStar.visibility="visible"; 
			 
			
	}
	 
	function hideStar(fieldName)
	{
			var mandatoryStar = eval('document.all["'+fieldName+'"].style');
			mandatoryStar.visibility="hidden";      
	}
	 

/****************************************************************
* Function: getElementPos(formNo, elementName)                                                                                                 *
* Description: will get element position within the given form                                                                               *
*****************************************************************/
function disablePage()
{
	 var formLen = document.forms[0].length;  
	for (var i = 0; i < formLen; i++)
	{
		if (document.forms[0].elements[i].type != "hidden")
		{
			  document.forms[0].elements[i].disabled = true;
		}
	}
} 

/***************************************************************************
* Function: printPage()								   
* Description: This function will print the form
***************************************************************************/
function printPage()
{            
	if (confirm("Do you wish to Print? Click 'OK' to print or Click 'Cancel' to Continue"))
	{
		
	footertable.style.display="none";

	headertable.style.display="none";
	var tabtbl = document.getElementById("tabtable");
	//alert(tabtbl);
	if (tabtbl !=null)
		tabtbl.style.display="none";
	menuTD.style.display="none";
	EHSHeader.style.display="none";
	pageButtons.style.display="none";
		  
	print();
	
	footertable.style.display="inline";
	headertable.style.display="inline";
	if (tabtbl !=null)	
		tabtbl.style.display="inline";
	menuTD.style.display="inline";
	EHSHeader.style.display="inline";
	pageButtons.style.display="inline";

	}
	else
	{
		return;
	}
	  
}
function printProfilePage()
{            
	if (confirm("Do you wish to Print? Click 'OK' to print or Click 'Cancel' to Continue"))
	{ 
		
	footertable.style.display="none";
	headertable.style.display="none";
	//oaktab.style.display="none";
	//menuTD.style.display="none";
	EHSHeader.style.display="none";
	pageButtons.style.display="none";
		  
	print();
	
	footertable.style.display="inline";
	headertable.style.display="inline";
	//oaktab.style.display="inline";
	//menuTD.style.display="inline";
	EHSHeader.style.display="inline";
	pageButtons.style.display="inline";

	}
	else
	{
		return;
	}
	  
}
function printPage1()
{            
	if (confirm("Do you wish to Print? Click 'OK' to print or Click 'Cancel' to Continue"))
	{
		
	footertable.style.display="none";
	headertable.style.display="none";
	oaktab.style.display="none";
	menuTD.style.display="none";
	EHSHeader.style.display="none";
	pageButtons.style.display="none";
		  
	print();
	
	footertable.style.display="inline";
	headertable.style.display="inline";
	oaktab.style.display="inline";
	menuTD.style.display="inline";
	EHSHeader.style.display="inline";
	pageButtons.style.display="inline";

	}
	else
	{
		return;
	}
}	  
/***************************************************************************
* Function: resetForm()		   
* Description: This function will reset the form
***************************************************************************/

function resetForm()
{
	if (confirm("Reset will undo all changes made to this screen.  Do you wish to continue? Click 'OK' to reset  changes or Click 'Cancel' to Continue"))
	{
		document.forms[0].reset()
		return;	
	}
	else
	{
		return;
	}

}
/***************************************************************************
* Function: enableContractor()   
* Description: This function enable man star for contractor
***************************************************************************/
function enableContractor()
{	var doc = document.forms[0];
	var manStarConType = document.all["manStarConType"].style;
	if(doc.employment_type.value =="SUBCON")
	{	
    manStarConType.visibility="visible"; 
	doc.contract_type.disabled= false;
	doc.contract_type.focus();
	return;	
	}
	else
	{
	doc.contract_type.selectedIndex=0;
	manStarConType.visibility="hidden"; 
	//doc.contract_type.disabled= true;
	}
}
/***************************************************************************
* Function: cancelForm()   
* Description: This function send user to well log search sreen
***************************************************************************/
function cancelForm()
{
	if (confirm("This will discard all changes and take you out of this screen.  Do you wish to continue?  or Click 'Cancel' to cancel action"))
	{
	
	var WellLogConstants_DISPLAYPAGE = 51;
	//document.forms[0].option.value = WellLogConstants_DISPLAYPAGE ;
	//document.forms[0].pageID.value = "WLWellCome" ; 
	//document.forms[0].submit();
	//document.tabForm.option.value = WellLogConstants_DISPLAYPAGE ; 
	//document.tabForm.pageID.value = "WLWellCome" ; 
 	
	//document.tabForm.submit(); 
	//got to home page
	submitMenuItem(47);
	}
	else
	{
	return;
	}
}
/***************************************************************************
* Description: auto tab to next field
***************************************************************************/
<!-- Begin script for auto tab
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->
/*****************************************************************************************
* Function: formatRegNo(RegNo)                                                                    
* Description: This Function will format and display the Reg number for key press event 		       		 
******************************************************************************************/
function formatRegNo(RegNo)    
{
	
	
	RgNo = RegNo.value;
	
	if(isValidIntLogon(RgNo) && RgNo.length == 2 )     
	{
		RegNo.value = RgNo+"-" ;
	}
	else if(!isValidIntLogon(RgNo) )  
		  {
		 alert("Please use the Intranet Login Page.");
		 //alert("asd1");
		 document.location.href="/EHLT0003/logon";
		 // document.forms[0].action = "/EHLT0003/logon";  	
		 //document.forms[0].submit();
			}
}


/*****************************************************************************************
* Function: formatRegNo(RegNo)                                                                    
* Description: This Function will format and display the Reg number for key press event 		       		 
******************************************************************************************/
function checkCommentsLength(evt,field,commlen)
{ 
		 if (field.value.length >  (commlen-1))  
		 {
		 alert("Exceeded the comment limit(" + commlen +").");
		 evt.keyCode = null;
		 return false;
		 }
		 
		 return true;
} 
function checkFloatLimit(field,lmt)
{ 
	 var limit = new String(lmt);
	if (field.value.length > 0 && isValidFloat(field.value))
	{
		limitDecimalPos = limit.indexOf(".");
		fieldDecimalPos = field.value.indexOf(".");
		  
		 if(fieldDecimalPos > -1 && ((limit.length-1) - limitDecimalPos) < (field.value.substring(fieldDecimalPos+1)).length)
		 {	 
				alert("Only "+ ((limit.length-1) - limitDecimalPos) +  " digits after decimal point allowed."); 
				field.focus();
				return false;
		 }
		 else if (parseFloat(field.value) < 0 || parseFloat(field.value) > parseFloat(limit))
				{
				alert("Exceeded field limit "+limit);
				field.focus(); 	
				return false; 
				}
	}
	return true; 
} 
function checkMandatory(mandatoryField, message) { 
	if (mandatoryField.value.length == 0) 
	{
		alert (message);
		eval(mandatoryField + ".focus()");
		return false;
	}
	return true;
}
function getAddr(formName)
{
	var regnNOname = "";    
    var formVar = eval("document." + formName);
	regnNOname = formVar.regn_nbr.value; 
	if (regnNOname.length == 0)
		{  
			alert("Please enter Regn no.");
			return;
		}  
	var url = "/EHLT0003/EHS.WL?option=39&formName="+formName+"&regn_nbr=";
	url = url.concat(regnNOname);
	myMsg = window.open(url, "addrWin", "dependent=yes,screenX=10,screenY=10");
	window.focus();
}  
 
function escapeAll (thisForm) {
	var tempStr;
	var singleQuote = "'";

	//loop through all "TEXT" & "TEXTAREA" elements on the form...
	for (var i = 0; i < thisForm.length; i++) {
		var thisField = thisForm[i];
		if (thisField.type == "text" || thisField.type == "textarea") {
			tempStr = thisField.value;
			//escape single quotes...
			thisField.value = tempStr.replace(/"/g, singleQuote) ;
			thisField.value = tempStr.replace(/'/g, "''") ;
		}
	}

}
//stop enter key
function stopRKey(evt) {
	var evt  = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	
	//alert(evt.keyCode);
	//alert(node.type);
	if (evt.keyCode == 13 && node.type=="textarea")
	{
		alert("Enter key or return key are not allowed in this field.");	
		return false;
	 	
	}  
}
document.onkeypress = stopRKey;

//parcel id check for creat applicaitons
function parcelIdCheck()
{
	//check parcel_id
	if(document.forms[0].parcel_id.value.length !=10)
	{
	alert("Enter a valid parcel id");
	document.forms[0].parcel_id.focus();
	return;
	}else
	{
	var parcelID = document.forms[0].parcel_id.value;
	var well_type = document.forms[0].well_type.value;
	var url = "/EHLT0003/EHS.WL?option=42&parcelID=";
		url = url.concat(parcelID+"&well_type="+well_type); 
		myMsg = window.open(url, "pdfWin", "dependent=yes,status=no,location=no,directories=no,menubar=no,copyhistory=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=500,left=0,top=100,screenX=0,screenY=100"); 
	if (myMsg.opener == null) myMsg.opener = self;
    	  myMsg.focus();
	}
}