function ShowDIV(divid)
{
	HideAll();
	SelTD = divid + 'class';
	document.getElementById(divid).style.display = "block";
	
}
function HideAll()
{
	document.getElementById('plano').style.display = "none";
	document.getElementById('plus').style.display = "none";
	document.getElementById('minus').style.display = "none";
}



function isNumeric(str)
{
	for (var i=0; i < str.length; i++)
	{
		var ch = str.substring(i, i+1)
		if( ch < "0" || ch>"9" || str.length == null)
		{
			return false
		}
	}
	return true
}


function AjaxAddProduct(pars)
{
	var ob = $('divProductList');
	//pars = 'action=resendlogin&memberid='+memid;
	//ob.innerHTML = "<span class='mid'><strong>Processing....</strong></span>";
	var myAjax = new Ajax.Request('AjaxAddProduct.php', {method:'post', postBody:pars, onSuccess: success});
//alert(pars);
	function success(t) {
	//ob.innerHTML = "<span class='mid'><strong>Successfully Added....</strong></span>";
	
	}
}



function trim(a){
var tmp=new Array();
for(j=0;j<a.length;j++)
if(a[j]!='')
tmp[tmp.length]=a[j];
a.length=tmp.length;
for(j=0;j<tmp.length;j++)
a[j]=tmp[j];
return a;
}

function TotWrite(DIVID,totVal)
{
	if(document.layers){
		fredlayer = document.layers[DIVID];
		fredlayer.document.open();
		fredlayer.document.write(totVal);
		fredlayer.document.close();
			}

	if(document.all){
		fredlayer = document.all[DIVID];
		fredlayer.innerHTML=totVal;
					 }

		if(document.getElementById){
		fredlayer = document.getElementById(DIVID);
		fredlayer.innerHTML =totVal;
		 }

}


// This is For Add Rows
function addNewRow()
{
	//get the table body for which to add a row
	var tbody = document.getElementById('tabid').getElementsByTagName ("tbody")[1];
	var lastRow = tbody.rows.length;
	k=lastRow+5;
			
			var row = document.createElement("TR");
		
			var celltd  = document.createElement("TD");			
			celltd.vAlign = 'middle';
			celltd.nowrap = 'nowrap';
			celltd.className="application_lables";
			celltd.innerHTML = "<strong>Child ("+(lastRow+3)+"):</strong>";

			
			var cellnewtd = document.createElement("TD");
			cellnewtd.vAlign = 'middle';
			cellnewtd.nowrap = 'nowrap';
			cellnewtd.className="application_lables";
			cellnewtd.innerHTML = '<div align="center"><strong><select name="gender'+k+'" class="field "><option value="-" selected="selected">Select One</option><option value="M">Male</option><option value="F">Female</option></select></strong></div>';
			
			var cellformtd = document.createElement("TD");
			cellformtd.vAlign = 'middle';
			cellformtd.nowrap = 'nowrap';
			cellformtd.className="application_lables";
			id1="dob"+k+"1";
			id2="dob"+k+"2";
			id3="dob"+k+"3";
			cellformtd.innerHTML = '<div align="center"><strong><input type="text" class="field" name="txtdobmn'+k+'" style="width:15px" size="2" maxlength="2" id="dob'+k+'1"  onKeyPress="Next(2,id1,id2);" onKeyUp="Next(2,id1,id2);" /> / <input  type="text" class="field" name="txtdobdt'+k+'" style="width:15px" size="2" maxlength="2" id="dob'+k+'2" onKeyPress="Next(2,id2,id3);" onKeyUp="Next(2,id2,id3);"/> / <input  type="text" class="field" name="txtdobyr'+k+'" style="width:30px" size="4" maxlength="4" id="dob'+k+'3" /></strong></div>';
			
			var cellheighttd = document.createElement("TD");
			cellheighttd.vAlign = 'middle';
			cellheighttd.nowrap = 'nowrap';
			cellheighttd.className="application_lables";
			cellheighttd.innerHTML = '<div align="center"><input name="ht_ft'+k+'" type="text" class="field" style="width:10px" size="1" maxlength="1" id="ht_ft'+k+'" /> ft. <input name="ht_in'+k+'" type="text" class="field" style="width:15px" size="2" maxlength="2" id="ht_in'+k+'" /> in.</div></td>';
			
			
			var cellweighttd = document.createElement("TD");
			cellweighttd .vAlign = 'middle';
			cellweighttd .nowrap = 'nowrap';
			cellweighttd .className="application_lables";
			cellweighttd .innerHTML = '<div align="center"><strong><input name="wt_applicant'+k+'" type="text" class="field" style="width:25px" size="3" maxlength="3" "wt_applicant'+k+'" /></strong></td>';
			
					
			var celltexttd = document.createElement("TD");
			celltexttd.style.textAlign='center';
			celltexttd.className="application_lables";
			celltexttd.innerHTML = '<input type="checkbox" name="chktobacco'+k+'" value="1" />';

/*			var cellnew = document.createElement("TD");
			cellnew.style.textAlign='center';
			cellnew.className="application_lables"
			cellnew.innerHTML = '<input type="checkbox" name="chlcollegestudent'+k+'" value="1" />';*/

						
			row.appendChild(celltd);
			row.appendChild(cellnewtd);
			row.appendChild(cellformtd);
			row.appendChild(cellheighttd);
			row.appendChild(cellweighttd);
			row.appendChild(celltexttd);
			//row.appendChild(cellnew);
			tbody.appendChild(row);
			document.frmIHI.txtfamilytotal.value=parseInt(document.frmIHI.txtfamilytotal.value)+1;
	
}

function Validateform()
{
if (document.frmIHI.txtcoveragebegin.value=="")
	{
		alert("Enter Coverage to begin on")
		document.frmIHI.txtcoveragebegin.focus();
		return false
	
	}
else if (parseInt(document.frmIHI.txtfamilytotal.value)>0)
{
for(i=1;i<=parseInt(document.frmIHI.txtfamilytotal.value);i++)
{
	genderval=eval('document.frmIHI.gender'+i+'.value');
	mnval=eval('document.frmIHI.txtdobmn'+i+'.value');
	dtval=eval('document.frmIHI.txtdobdt'+i+'.value');
	yrval=eval('document.frmIHI.txtdobyr'+i+'.value');
	if(!isInteger(mnval))
	{
		alert("Please enter a valid Month")
		eval('document.frmIHI.txtdobmn'+i+'.focus();');
		return false;
	}
	else
	if(!isInteger(dtval))
	{
		alert("Please enter a valid Date");
		eval('document.frmIHI.txtdobdt'+i+'.focus();');
		return false;
	}
	else
	if(!isInteger(yrval))
	{
		alert("Please enter a valid Year")
		eval('document.frmIHI.txtdobyr'+i+'.focus();');
		return false;
	}
	
	if(genderval=="-")
	{
	if (mnval!="" || dtval!="" || yrval!="") 
		 if(!isDate(mnval+"/"+dtval+"/"+yrval,i))
		 {
		 	//alert("Invalid Date");
		 	//eval('document.frmIHI.txtdobmn'+i+'.focus();');
		 	return false;
		 }
		 else
		 {
		 	alert("Please select the Gender");
		 	eval('document.frmIHI.gender'+i+'.focus();');
		 	return false;
		 }
	}
	 else
	 {
		 if(!isDate(mnval+"/"+dtval+"/"+yrval,i))
		 {
		 	//alert("Invalid Date");
		 	//eval('document.frmIHI.txtdobmn'+i+'.focus();');
		 	return false;
		 }
	 }
	
}
}
else if(document.frmIHI.gender1.value=="-")
{
	alert("Please select Applicant's Gender");
	document.frmIHI.gender1.focus();
	return false;
}
initRestoreDefault();
}


