/*
	@Developer		: Sushil.
	@DateCreated	: 6-jan-2011
	@Purpose		: To populate js drop down boxes to hidden fields.
*/
var childIsTobaccoUser 		= 0;	// Initially assign tabbaco user to 0
var applicantValues = Array();	// ['fName'] = charLength(50), ['lName'] = charLength(50),['email'] = email,['phone'] = phone(10), ['gender'] = Gender Value, ['date'] = Date Of Birth.date, ['month'] = Date Of Birth.month, ['year'] = Date Of Birth.year ['tobacco'] = Is Tobacco Users
applicantValues[0] = Array();	// Hold Applicant
applicantValues[1] = Array();	// Hold Spouse
applicantValues[0]['gender'] = "";
applicantValues[0]['date'] = "";
applicantValues[0]['month'] = "";
applicantValues[0]['year'] = "";
applicantValues[0]['tobacco'] = "";
applicantValues[1]['gender'] = "";
applicantValues[1]['date'] = "";
applicantValues[1]['month'] = "";
applicantValues[1]['year'] = "";
applicantValues[1]['tobacco'] = "";
var coverageFrom = "";
/* [ APPLICANT VALUES BLOCK ] */
	var applicantIsTobaccoUser 	= 0;	// Initially assign tabbaco user to 0
	function HoldApplicantGenderValue(gender)
	{
		
		applicantValues[0]['gender'] = gender;
		applicantValues[1]['gender'] = '--';
		
//		applicantValues[1]['gender'] = (gender  =='Male') ? 'Female' :'Male';
				
		$("#drop_box_5").html(applicantValues[1]['gender']);				
				
		
	}
	function HoldApplicantDateOfBirth(data,type)
	{
		if(type == "date")
		{
			applicantValues[0]['date'] = data;	// Add Date
			$("#drop_box_3").html(data);
		}
		if(type == "month")
		{
			applicantValues[0]['month'] = data;	// Add Month
			$("#drop_box_2").html(data);
		}
		if(type == "year")
		{
			applicantValues[0]['year'] = data;	// Add Year
			$("#drop_box_4").html(data);
		}
		$("#drop_list_2").css("display","none");
		$("#drop_list_3").css("display","none");
		$("#drop_list_4").css("display","none");
	}
	function HoldApplicantTobaccoUsers()
	{
		if(applicantIsTobaccoUser == 0)
		{
			applicantIsTobaccoUser = 1;
		}
		else
		{
			applicantIsTobaccoUser = 0;
		}
		applicantValues[0]['tobacco'] = applicantIsTobaccoUser;
	}
/* [/ APPLICANT VALUES BLOCK ] */


/* [ SPOUSE VALUES BLOCK ] */
	var spouseIsTobaccoUser 	= 0;	// Initially assign tabbaco user to 0
	function HoldSpouseGenderValue(gender)
	{
					
		if((gender=='Male' )|| (gender=='Female'))		
			applicantValues[1]['gender'] = gender;
		else				
			applicantValues[1]['gender'] = "";	
		
		
		
	}
	function HoldSpouseDateOfBirth(data,type)
	{
	
		var value = '';
		
		if(data !='--')
			value = data; 
			
		if(type == "date")
		{
			applicantValues[1]['date'] = value;	// Add Date
			$("#drop_box_7").html(data);
		}
		if(type == "month")
		{
			applicantValues[1]['month'] = value;	// Add Month
			$("#drop_box_6").html(data);
		}
		if(type == "year")
		{
			applicantValues[1]['year'] = value;	// Add Year
			$("#drop_box_8").html(data);
		}
		$("#drop_list_7").css("display","none");
		$("#drop_list_6").css("display","none");
		$("#drop_list_8").css("display","none");
	}
	function HoldSpouseTobaccoUsers()
	{
		if(spouseIsTobaccoUser == 0)
		{
			spouseIsTobaccoUser = 1;
		}
		else
		{
			spouseIsTobaccoUser = 0;
		}
		applicantValues[1]['tobacco'] = spouseIsTobaccoUser;
	}
/* [/ SPOUSE VALUES BLOCK ] */

/* [ CHILD VALUES BLOCK ] */
	var childIsTobaccoUser 	= Array();;	// Initially assign tabbaco user to 0
	var childValues = Array();
	childValues[0] = Array();	// Hold Tabacco users.
	childValues[0]['gender'] = Array();
	childValues[0]['tobacco'] = Array();
	childValues[0]['birthDate'] = Array();
	childValues[0]['birthDate']['month'] = Array();
	childValues[0]['birthDate']['date'] = Array();
	childValues[0]['birthDate']['year'] = Array();
	childGenderID = 0;
	function HoldChildGenderValue(id,gender)
	{
	
			
		if((gender=='Male' )|| (gender=='Female'))		
			childValues[0]['gender'][id] = gender;			
		else				
			childValues[0]['gender'][id] = "";			
		//childValues[0]['gender'][id] = gender;
		childGenderID++;
	}
		
	function HoldChildDateOfBirth(data,type,id,childDropDownID)
	{
		var month = childDropDownID;
		var date = childDropDownID+1;
		var year = childDropDownID+2;
		var value = '';
		
		if(data != '--')				
			value = data;
		
		if(type == "date")
		{
			childValues[0]['birthDate']['date'][id] = value;	// Add Date
			$("#drop_box_"+(date)).html(data);
		}
		if(type == "month")
		{
						
			childValues[0]['birthDate']['month'][id] = value;	// Add Month
			
			$("#drop_box_"+(month)).html(data);
		}
		if(type == "year")
		{
			childValues[0]['birthDate']['year'][id] = value;	// Add Year
			$("#drop_box_"+(year)).html(data);
		}
		$("#drop_list_"+(month)).css("display","none");
		$("#drop_list_"+(date)).css("display","none");
		$("#drop_list_"+(year)).css("display","none");
	}
	
	function HoldChildTobaccoUsers(childID)
	{
		if(childValues[0]['tobacco'][childID])
		{
			childValues[0]['tobacco'][childID] = 0;
		}
		else
		{
			childValues[0]['tobacco'][childID] = 1;
		}
	}
/* [/ CHILD VALUES BLOCK ] */

/* [/ HEALTH STAUS VALUES BLOCK ] */
healthHiddenField = "";
/* [/ HEALTH STAUS VALUES BLOCK ] */
insuranceAmountHiddenField = "";

/* [/ MOTH VALUES BLOCK ] */

var arrMonth = new Array();
arrMonth[0] = 'January';
arrMonth[1] = 'Feburary';
arrMonth[2] = 'March';
arrMonth[3] = 'April';
arrMonth[4] = 'May';
arrMonth[5] = 'June';
arrMonth[6] = 'July';
arrMonth[7] = 'August';
arrMonth[8] = 'September';
arrMonth[9] = 'October';
arrMonth[10] = 'November';
arrMonth[11] = 'December';
function converage(ele,month)
{
	var todateDate = new Date();	
	var todayDate = todateDate.getDate();	
	var todayYear = todateDate.getFullYear();	
	var coverage1MonthAlert = "";

/*
	if($(ele).attr("id") == "coverage1")
	{
		var coverage1MonthAlert = $("#coverageMonth1").html();
		var coverage2MonthAlert = $("#coverageMonth2").html();
		//alert("Warning: Some insurance companies may not be accepting new business for \""+coverage1MonthAlert+"\".\n  We recommend selecting \""+coverage2MonthAlert+"\"");
		alert("Warning: Some insurance companies may not be accepting new business for "+coverage1MonthAlert+". We recommend selecting "+coverage2MonthAlert+".");
	}
*/

	if($(ele).attr("id") == "coverage1")	
		coverage1MonthAlert = $("#coverageMonth1").html();
	else if($(ele).attr("id") == "coverage2")
		coverage1MonthAlert = $("#coverageMonth2").html();
	else
		coverage1MonthAlert = $("#coverageMonth3").html();
		
	for(var i=0; i<arrMonth.length; i++) {
			var value = arrMonth[i];
			if(arrMonth[i] == coverage1MonthAlert ){
				todayMonth = i +1;
				break;
			}
			//alert(i =") "+value);
	}

	$(".checked_radio").removeClass("unchecked_radio");
	$(ele).addClass("unchecked_radio");
//	coverageFrom = arrMonth[month-1];
	todayMonth = (todayMonth  < 10) ? '0' + todayMonth :todayMonth;
	todayDate = (todayDate < 10) ? '0' + todayDate :todayDate;	
	coverageFrom  = todayMonth +'/'+todayDate+ '/'+todayYear;		

}
function InitCoverageMonth()
{
	var todateDate = new Date();
	var todayMonth = todateDate.getMonth();
	var todayDay = todateDate.getDay();
	var todayDate = todateDate.getDate();	
	var todayYear = todateDate.getFullYear();
		
	$("#coverage1").attr("alt",arrMonth[todayMonth]);
	var addedMonthForCoverage2 = 1;
	var addedMonthForCoverage3 = 2;
	if(todayMonth==10)
	{
		addedMonthForCoverage3 = -10;
	}
	if(todayMonth==11)
	{
		addedMonthForCoverage2 = -11;
		addedMonthForCoverage3 = -10;
	}
	$("#coverage2").attr("alt",arrMonth[todayMonth+addedMonthForCoverage2]);
	$("#coverage3").attr("alt",arrMonth[todayMonth+addedMonthForCoverage3]);
	$("#coverageMonth1").html(arrMonth[todayMonth]);
	$("#coverageMonth2").html(arrMonth[todayMonth+addedMonthForCoverage2]);
	$("#coverageMonth3").html(arrMonth[todayMonth+addedMonthForCoverage3]);
	$(".checked_radio").removeClass("unchecked_radio");
	$("#coverage2").addClass("unchecked_radio");	
	
	//coverageFrom = $("#coverageMonth2").html();	
	todayMonth = todayMonth+addedMonthForCoverage3; //next month
	//alert(coverageFrom);	
	todayMonth = (todayMonth  < 10) ? '0' + todayMonth :todayMonth;
	todayDate = (todayDate < 10) ? '0' + todayDate :todayDate;		
	coverageFrom  = todayMonth +'/'+todayDate+ '/'+todayYear;
	
}
$(document).ready
(
	function()
	{
		InitCoverageMonth();
	}
);
