function getNoChildrenHTML()
{
	var retHTML='';
	for(var i=0; i<7; i++)
	{
		if (i==0) 
			retHTML+=  '<option selected="selected" value=0>0</option>';
		else
			retHTML+=  '<option value='+i+'>' + i + '</option>';
	}
	return retHTML;
}

function getDependantCellHTML()
{
	var retHTML='';
	for(var j=0; j<6; j++)
	{
		retHTML+='  <td><div id="dtc' + j +'">';
		retHTML+='      <input size="2" name="dependant'+ j+ '" id="dependant'+ j+ '" onKeyPress="return numbersonly(event);" maxlength="2" >';		
		retHTML+='  </div></td>';
	}
	return retHTML;
}

function getDeductibleHTML(vdeductible, vdbl, selvalue)
{
		var retHTML='';
		for(var i=0; i <vdeductible.length; i++)
		{
			if (vdeductible[i] == selvalue)
				retHTML+=' <option selected="selected" value="' + vdeductible[i] +'">' + vdbl[i] + '</option>';
			else
				retHTML+=' <option value="' + vdeductible[i] +'">' + vdbl[i] + '</option>';
		}  	
		return retHTML;
}

function getMonthHTML()
{
	var retHTML='';
	 var mArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep", "Oct", "Nov", "Dec");
	for (var i=1; i<= mArray.length; i++)
    {							
          if (i==1)
             retHTML+=' <option selected="selected" value="' + i + '">' + mArray[i-1] + '</option>';
          else												
             retHTML+=' <option value="'+ i +'">' + mArray[i-1] +'</option>';
    }
	return retHTML;		
							
}

function getDayHTML()
{
	var retHTML='';
	for (var i=1; i<32; i++)
	{							
		if (i==1)
			retHTML+='		<option selected="selected" value="' + i + '">' + i + '</option>';
		else												
			retHTML+='		<option value="'+ i +'">' + i +'</option>';
	}	
	return retHTML;	
}

function getYearHTML()
{
	var retHTML='';
	var d = new Date();
	var frmyy = d.getFullYear();
	for (var i=0; i<3; i++)
	{
		if (i==0)
			retHTML+= ' <option selected="selected"  value="' + frmyy + '">' + frmyy + '</option>';
		else
			retHTML+= ' <option value="' + frmyy + '">' + frmyy + '</option>';
		frmyy=frmyy+1;
	}
	return retHTML;
}

function getMaxPolLimitHTML(maxpolLim, mpl, selval)
{
	var retHTML = '';
	for(var i=0; i < maxpolLim.length; i++)
	{
		if (maxpolLim[i] == selval)
			retHTML += '<option selected="selected" value="' + maxpolLim[i] +'">' + mpl[i] + '</option>';
		else
			retHTML += '<option value="' + maxpolLim[i] +'">' + mpl[i] + '</option>';	
	}	
	return retHTML;		
}
function getCtyCitizenshipHTML()
{	
	var retHTML = '';
	retHTML += '<option selected="selected" id="NONUSA" value="2">Non-USA</option>';
	retHTML += '<option id="USA" value="1">USA</option>';
	return retHTML;
}

function getUSStatesForCombo()
{
	var us_states='';
	us_states = '<option value="AL">AL Alabama</option><option value="AK">AK Alaska</option>     <option value="AZ">AZ Arizona</option><option value="AR">AR Arkansas</option><option value="CA">CA California</option><option value="CO">CO Colorado</option><option value="CT">CT Connecticut</option><option value="DE">DE Delaware</option><option value="DC">DC District of Columbia</option><option value="FL">FL Florida</option><option value="GA">GA Georgia</option><option value="HI">HI Hawaii</option><option value="ID">ID Idaho</option><option value="IL">IL Illinois</option><option value="IN">IN Indiana</option><option value="IA">IA Iowa</option><option value="KS">KS Kansas</option><option value="KY">KY Kentucky</option><option value="LA">LA Louisiana</option><option value="ME">ME Maine</option><option value="MD">MD Maryland</option><option value="MA">MA Massachusetts</option><option value="MI">MI Michigan</option><option value="MN">MN Minnesota</option><option value="MS">MS Mississippi</option><option value="MO">MO Missouri</option><option value="MT">MT Montana</option><option value="NE">NE Nebraska</option><option value="NV">NV Nevada</option><option value="NH">NH New Hampshire</option><option value="NJ">NJ New Jersey</option><option value="NM">NM New Mexico</option><option value="NY">NY New York</option><option value="NC">NC North Carolina</option><option value="ND">ND North Dakota</option><option value="OH">OH Ohio</option><option value="OK">OK Oklahoma</option><option value="OR">OR Oregon</option><option value="PA">PA Pennsylvania</option><option value="RI">RI Rhode Island</option><option value="SC">SC South Carolina</option><option value="SD">SD South Dakota</option><option value="TN">TN Tennessee</option><option value="TX">TX Texas</option><option value="UT">UT Utah</option><option value="VT">VT Vermont</option><option value="VA">VA Virginia</option><option value="WA">WA Washington</option><option value="WV">WV West Virginia</option><option value="WI">WI Wisconsin</option><option value="WY">WY Wyoming</option>';
	return us_states;
}

function getUSArrivalHTML()
{
	var retHTML = "";
	retHTML += '<option selected="selected" value="5">Not in USA yet</option>';
	retHTML += '<option value="6">Most recent US entry is within last 30 days</option>';
    retHTML += '<option value="0">Most recent US entry is within last 3 months</option>';
	retHTML += '<option value="1">Most recent US entry is within last 12 months</option>';	
	retHTML += '<option value="2">Most recent US entry is within last 18 months</option>';
    retHTML += '<option value="3">Most recent US entry is within last 24 months</option>';
    retHTML += '<option value="4">Most recent US entry is more than 2 years ago</option>';	
	return retHTML;
}

function writeCommonControls()
{

document.write('		<table border="0" cellspacing="0" cellpadding="5">');
document.write(	'		    <tr id="row">');
document.write('			    <td id="pad1">&nbsp;1.</td>');
document.write('				<td id="pad2">Enter the age of the traveler or visitor</td>');
document.write('				<td colspan="8" id="pad">');
document.write('					<input size="2" name="Age" id="Age" onKeyPress="return numbersonly(event);" maxlength="2"/>');
document.write('					<input name="affiliate" type="hidden" value="nriol"></td>');
document.write('	  </tr>');
document.write('	  <tr id="row1">');
document.write('         	<td  id="pad1">&nbsp;2.</td>');
document.write('	    	<td id="pad2">Enter age of the traveler&rsquo;s spouse if coverage for spouse is required</td>');
document.write('	   		<td colspan="8" id="pad">');
document.write('	   			<input size="2" name="spouseAge" id="spouseAge" onKeyPress="return numbersonly(event);" maxlength="2"/></td>');
document.write('	  </tr>');
document.write('		<tr id="row">');
document.write('          	 <td id="pad1">&nbsp;3. </td>');
document.write('		  	 <td id="pad2">Enter number &amp; ages of dependents under 18 requiring coverage');
document.write('			     <span class="smallFont">&nbsp;(Child less than 18 years and accompanied by a parent or guardian.)</span></td>');
document.write('		  	<td id="pad">');
document.write('             	<select name="NumberOfChildren" id="NumberOfChildren" onChange="showtextbox(this.selectedIndex);">');
document.write(getNoChildrenHTML()); 
document.write('				</select>');
document.write('	     	</td>');
document.write(getDependantCellHTML());
document.write('		</tr>');
document.write('        <tr id="row1">');
document.write('              <td id="pad1">&nbsp;4. </td>');
document.write('              <td id="pad2">Select the coverage limit for medical expenses');
document.write('                  <span class="smallFont">&nbsp;(Maximum that the plan will cover)</span></td>');
document.write('             <td id="pad" colspan="8"><select name="MaxPolicyLimit" id="MaxPolicyLimit">');
		var maxpolLim = new Array("0-25000","26000-60000", "61000-100000","101000-499000", "500000", "1000000");
		var mpl = new Array("$25,000 or less","$26,000 to $60,000","$61,000 to $100,000","$101,000K to $499,000K","$500,000","$1,000,000");
document.write(getMaxPolLimitHTML(maxpolLim, mpl, "26000-60000"));
document.write('            </select></td>');
document.write('        </tr>');
document.write('        <tr id="row">');
document.write('            <td id="pad1">&nbsp;5.</td>');
document.write('            <td id="pad2">Select the deductible amount ');
document.write('				<span class="smallFont">(The initial amount that you are responsible for before the insurance pays for medical expense.)</span></td>');
document.write('            <td id="pad" colspan="8"><select name="Deductible" id="Deductible">');
								var vdeductible=new Array("0","50-100","101-250", "500", "1000", "2500");
								var vdbl = new Array("US$ 0","US$ 50 to 100","US$ 101 to 250","US$ 500","US$ 1000","US$ 2500 ");
document.write(getDeductibleHTML(vdeductible, vdbl, "101-250"));	
document.write('                 </select></td>');
document.write('         </tr>');
document.write('         <tr id ="row1">');
document.write('             <td id="pad11">&nbsp;6. </td>');
document.write('             <td id="pad22">Select the dates for coverage </td>');
document.write(' 				   <td colspan="8" id="pad"><div>');
document.write('                       <select name="DepartureMonth"  id="DepartureMonth" onChange="setperiods();">');
document.write(getMonthHTML());
document.write('                      </select>');
document.write('                      <select name="DepartureDay" id="DepartureDay" onChange="setperiods();">');
document.write(getDayHTML());
document.write('                      </select>');
document.write('                      <select name="DepartureYear" id="DepartureYear" onChange="setperiods();">');
document.write(getYearHTML());
document.write('                      </select>');
document.write(' 				      </div>');
document.write(' 				      <select name="ReturnMonth" id="ReturnMonth" onChange="setperiods();">');
document.write(getMonthHTML());
document.write('                      </select>');
document.write('                      <select name="ReturnDay" id="ReturnDay" onChange="setperiods();">');
document.write(getDayHTML());
document.write('                      </select>');
document.write('                      <select name="ReturnYear" id="ReturnYear" onChange="setperiods();">');
document.write(getYearHTML());
document.write('                      </select>&nbsp;');
document.write('                      <input type="text" name="monthsOfCoverage" id="monthsOfCoverage" onChange="if(this.value < 0)this.value=0" readonly="true" size="1">  months');
document.write(' 				      <input type="text" name="daysOfCoverage" id="daysOfCoverage" readonly="true" onChange="if(this.value < 0)this.value=0" size="1">  days	');			        
document.write(' 			          </td>');
document.write('        </tr>');
document.write('        <tr id="row">');
document.write('              <td  id="pad1">&nbsp;7. </td>');
document.write('              <td  id="pad2">Select the visitor/traveler&#39;s country of citizenship	</td>');
document.write('              <td id="pad" colspan="8"><select name="CountryofCitizenship" id="CountryofCitizenship" onChange="questiondisplay(this[this.selectedIndex].id);">');
document.write(getCtyCitizenshipHTML());
document.write('             </select>	        </td>');
document.write('        </tr>');
document.write('        <tr id="row1">');
document.write('            <td  id="pad1">&nbsp;8. </td>');
document.write('            <td  id="pad2">Select the country/countries where coverage is required</td>');
document.write('            <td id="pad" colspan="8"><div id="q8"><select id="CountryforCoverage" name="CountryforCoverage">');
document.write('                    <option selected="selected" value="1">USA only</option>');
document.write('                     <option value="3">ALL nations including USA</option>');
document.write('                     <option value="4">ALL nations excluding USA</option>');
document.write('                   </select>');
document.write('                 </div></td>');
document.write('              </tr>');
document.write('              <tr id="row">');
document.write('                <td  id="pad1">&nbsp;9. </td>');
document.write('                <td id="pad2">Where is the mailing address');
document.write('                    <span class="smallFont">(Address to mail the insurance ID card and certificate)</span></td>');
document.write('                <td id="pad" colspan="8"><div id="q9c">');	
document.write('						<select name="MailingAddress" id="MailingAddress">');
document.write('                    		<option selected="selected" value="2">Outside-USA </option>');
document.write(                    			getUSStatesForCombo());
document.write('                		</select>	');			   
document.write('						   </div></td>');	
document.write('              </tr>');
document.write('              <tr id="row1">');	
document.write('                <td  id="pad1">&nbsp;10. </td>');	
document.write('                <td id="pad2">Where is the traveler/visitor&#39;s permanent home');
document.write('				<span class="smallFont">(Applicant&#39;s permanent home to which he/she has the intention of returning to.)</span></td>');	
document.write('                <td id="pad" colspan="8"><div id="q10c">');	
document.write('                	<select  name="Residence" id="Residence">');
document.write('                     <option selected="selected" value="2">Outside-USA </option>');
document.write(                   getUSStatesForCombo());
document.write('    							</select>');
document.write('							   </div></td>');	
document.write('              </tr>');
document.write('              <tr id="row">');
document.write('					<td  id="pad1"><div id="q11a">&nbsp;11. </div></td>');
document.write('					<td id="pad2"><div id="q11b">If the traveler is already in USA, how long has the traveler been in USA');
document.write('					<span class="smallFont">(Choose your latest entry to USA.)</span></div></td>');	
document.write('               		<td  colspan="8" id="pad"> <div id="q11c">');
document.write('                		<select name="USarrival" id="USarrival">');
document.write('                  			<option selected="selected" value="0">Not in US yet or arrived less than 1 year ago</option>');
document.write('                    		<option value="1">Arrived in the US less than 2 years ago</option>');
document.write('                    		<option value="2">Arrived in the US more than 2 years ago</option>');
document.write('                  		</select> </div>');
document.write('                	</td>');
document.write('              </tr>');
document.write('              </table>');

}
