function showCalForDependents(fieldname){
		fieldname.focus();	
		var prevDateVal = fieldname.value;
		fieldname.value="";
		var cal = new calendar2(fieldname);
		cal.year_scroll = true;
		cal.time_comp = false;	
		cal.popup();
		//If user selects the calendar, and does not select the date...this will replace the previously populated date.
		if(fieldname.value=="")
		fieldname.value=prevDateVal;
}	
function createTableCaption(srcTable,caption){
	try{
	if(navigator.appName=='Netscape'){
		var tmpRow = AppendRow(srcTable);
		var tmpCell=null;
		for(j=0; j<5; j++){
			tmpCell = AppendCell(tmpRow);
			//tmpCell.innerText = j;
			if(j==0){
				tmpCell.textContent = caption; 
			}else{
				tmpCell.textContent = ' '; 
			}
				tmpCell = null;
			}
	}else{
		var tmpRow = AppendRow(srcTable);
		var tmpCell=null;
		for(j=0; j<5; j++){
			tmpCell = AppendCell(tmpRow);
			//tmpCell.innerText = j;
			if(j==0){
				tmpCell.innerText = caption; 
			}else{
				tmpCell.innerText = ' '; 
			}
				tmpCell = null;
			}
	
	
	}
	}catch(e){
		//alert("createTableCaption"+e);
	}
}
function createTableData(srcTable,k,formType){
	try{
	var tmpRow = AppendRow(srcTable);
	var tmpCell=null;
	for(j=0; j<5; j++){
			tmpCell = AppendCell(tmpRow);
			if(j==0){
				tmpCell.innerHTML= "<input type='text' id='dependentFirstName' name='dependentFirstName' size='13' maxlength='20'>";
	 		}
			if(j==1){
				tmpCell.innerHTML = "<input type='text' id='dependentMiddleName' name='dependentMiddleName' size='1' maxlength='1'>"; 
			}
			if(j==2){
				tmpCell.innerHTML = "<input type='text' id='dependentLastName' name='dependentLastName' size='20' maxlength='20'>";
			}
			if(j==3){
				tmpCell.innerHTML = "<input type='radio' id='dependentGenderGroup_"+k+"' name='dependentGenderGroup_"+k+"' value='0'>M&nbsp;&nbsp;<input type='radio' id='dependentGenderGroup_"+k+"' name='dependentGenderGroup_"+k+"' value='1'>F&nbsp;&nbsp"; 
			}
			/*if(j==4){
				//tmpCell.innerHTML = "<input type='text' id='dependentDOB_"+k+"' name='dependentDOB_"+k+"' size='10'>&nbsp;&nbsp;<a href='#' onClick='javaScript:onClick=addCalDate(this.name); return false;' name='dependentDOB_"+k+"' id='dependentDOB_anchor_0'><img src='/Tx/images/cal.gif' width='16' height='16' border='0' alt='Select Date'></a>"; 
				  tmpCell.innerHTML = "<input type='text' id='dependentDOB_"+k+"' name='dependentDOB_"+k+"' size='10'>&nbsp;&nbsp;<a href='#' onClick='javaScript:onClick=showCalForDependents(dependentDOB_"+k+"); return false;'><img src='/Tx/images/cal.gif' width='16' height='16' border='0' alt='Select Date'></a>"; 
			}*/
			if(j==4 && formType=='oldEnrollmentForm'){
				tmpCell.innerHTML = "<input type='text' id='dependentDOB_"+k+"' name='dependentDOB_"+k+"' size='10' readOnly>&nbsp;&nbsp;<a href='#' onClick='javaScript:onClick=addCalDate(this.name); return false;' name='dependentDOB_"+k+"' id='dependentDOB_anchor_0'><img src='/Tx/images/cal.gif' width='16' height='16' border='0' alt='Select Date'></a>"; 
			}
			if(j==4 && formType=='newEnrollmentForm'){
				  tmpCell.innerHTML = "<input type='text' id='dependentDOB_"+k+"' name='dependentDOB_"+k+"' size='10'>&nbsp;&nbsp;<a href='#' onClick='javaScript:onClick=showCalForDependents(dependentDOB_"+k+"); return false;'><img src='/Tx/images/cal.gif' width='16' height='16' border='0' alt='Select Date'></a>"; 
			}
			tmpCell = null;
	}
	}catch(e){
		//alert("createTableData"+e);
	}
}
function createTableHeading(srcTable){
	try{
	var tmpRow = AppendRow(srcTable);
	var tmpCell=null;
	if(navigator.appName=='Netscape'){
		for(j=0; j<5; j++){
				tmpCell = AppendCell(tmpRow);
				if(j==0){
					tmpCell.textContent = 'First Name                         '; 
				}
				if(j==1){
					tmpCell.textContent = 'M.I.      '; 
				}
				if(j==2){
					tmpCell.textContent = 'Last Name                                 '; 
				}
				if(j==3){
					tmpCell.innerHTML = 'Gender&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
				}
				if(j==4){
					tmpCell.innerHTML = 'Date Of Birth (mm/dd/yyyy)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
				}
				tmpCell = null;
		}
	}else{
			for(j=0; j<5; j++){
				tmpCell = AppendCell(tmpRow);
				if(j==0){
					//tmpCell.innerText = 'First Name                         '; 
					tmpCell.innerHTML ='First Name';
				}
				if(j==1){
					//tmpCell.innerText = 'M.I.      ';
					tmpCell.innerHTML ='M.I.';
				}
				if(j==2){
					//tmpCell.innerText = 'Last Name                                 '; 
					tmpCell.innerHTML ='Last Name';
				}
				if(j==3){
					tmpCell.innerHTML = 'Gender&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
				}
				if(j==4){
					//tmpCell.innerText = 'Date Of Birth ( mm/dd/yyyy)'; 
					tmpCell.innerHTML= 'Date Of Birth (mm/dd/yyyy)'; 
				}
				tmpCell = null;
	
	
	}
	}}catch(e){
		//alert("createTableHeading"+e);
	}
}

function createESPTableHeading(srcTable){
	try{
	var tmpRow = AppendRow(srcTable);
	var tmpCell=null;
	if(navigator.appName=='Netscape'){
		for(j=0; j<5; j++){
				tmpCell = AppendCell(tmpRow);
				if(j==0){
					tmpCell.textContent = 'Nombre                         '; 
				}
				if(j==1){
					tmpCell.textContent = 'Inicial.      '; 
				}
				if(j==2){
					tmpCell.textContent = 'Apellido                                 '; 
				}
				if(j==3){
					tmpCell.innerHTML = 'Sexo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
				}
				if(j==4){
					tmpCell.innerHTML = 'Fecha de nacimiento(mm/dd/aaaa)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
				}
				tmpCell = null;
		}
	}else{
			for(j=0; j<5; j++){
				tmpCell = AppendCell(tmpRow);
				if(j==0){
					tmpCell.innerHTML ='Nombre';
				}
				if(j==1){
					tmpCell.innerHTML ='Inicial.';
				}
				if(j==2){
					tmpCell.innerHTML ='Apellido';
				}
				if(j==3){
					tmpCell.innerHTML = 'Sexo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
				}
				if(j==4){
					tmpCell.innerHTML= 'Fecha de nacimiento(mm/dd/aaaa)'; 
				}
				tmpCell = null;		
	}
	}}catch(e){
		//alert("createTableHeading"+e);
	}
}

function addCalDate(anchorName){
	try{
	//alert(anchorName);
	var ar_anchorName = anchorName.split("_");
	var objName = ar_anchorName[0];
	var k = ar_anchorName[1]
	var obj = document.getElementById(objName+"_"+k);
	var dp_cal  = new Epoch('epoch_popup','popup',obj);
	dp_cal.toggle();
	}catch(e){
		//alert("addCalDate"+e);
	}
}
function AppendRow(srcTable){
	try{
			if(srcTable != null){
				return srcTable.insertRow(-1);
			}
			else{
				//alert("Error while creating table. Cause: Container Table is null!");
			}
	}catch(e){
		//alert("AppendRow"+e);
	}
}
function AppendCell(srcRow)	{
	try{
			if(srcRow != null){
				return srcRow.insertCell(-1);
			}
			else{
				//alert("Error while creating table. Cause: Container row is null!");
			}
	}catch(e){
		//alert("AppendCell"+e);
	}
}
function removeChilds(srcHolder)
{
	if ( srcHolder.hasChildNodes() )
	{
		while ( srcHolder.childNodes.length >= 1 )
		{
			srcHolder.removeChild( srcHolder.firstChild );       
		} 
	}
}