
var male_age = 18;
var male_smoker = false;
var female_age = 18;
var female_smoker = false;
var numChildren = 0;
var county;
var chosenplan;
var pageloaded = false;

var plan1, plan2, plan3, plan4, plan5, plan6, plan7, plan8;

// arrays of combo values
var cnames = ['Select WA County','Adams County', 'Asotin County', 'Benton County', 'Chelan County', 'Clallam County', 'Clark County', 'Columbia County', 'Cowlitz County', 'Douglas County', 'Ferry County', 'Franklin County', 'Garfield County', 'Grant County', 'Grays Harbor County', 'Island County', 'Jefferson County', 'King County', 'Kitsap County', 'Kittitas County', 'Klickitat County', 'Lewis County', 'Lincoln County', 'Mason County', 'Okanogan County', 'Pacific County', 'Pend Oreille County', 'Pierce County', 'San Juan County', 'Skagit County', 'Skamania County', 'Snohomish County', 'Spokane County', 'Stevens County', 'Thurston County', 'Wahkiakum County', 'Walla Walla County', 'Whatcom County', 'Whitman County', 'Yakima County'];

var ages = ['none','under 18','18-24','25-29','30-34','35-39','40-44','45-49','50-54','55-59','60-64','65+'];
var agevalues = [0,17,18,25,30,35,40,45,50,55,60,65];

// 	1 - Asuris		2 - Regence		3 - Group Health 		4 - Lifewise

var c = [];
c['Select WA County1'] = false;
c['Select WA County2'] = true; 
c['Select WA County3'] = true; // Group Health 
c['Select WA County4'] = true; // Lifewise
c['Adams County1'] = true;
c['Adams County2'] = false;
c['Adams County3'] = false;
c['Adams County4'] = true;
c['Asotin County1'] = true;
c['Asotin County2'] = false;
c['Asotin County3'] = false;
c['Asotin County4'] = true;
c['Benton County1'] = true;
c['Benton County2'] = false;
c['Benton County3'] = true;
c['Benton County4'] = true;
c['Chelan County1'] = true;
c['Chelan County2'] = false;
c['Chelan County3'] = false;
c['Chelan County4'] = true;
c['Clallam County1'] = false;
c['Clallam County2'] = true;
c['Clallam County3'] = false;
c['Clallam County4'] = true;
c['Clark County1'] = false;
c['Clark County2'] = false;
c['Clark County3'] = false;
c['Clark County4'] = true;
c['Columbia County1'] = false;
c['Columbia County2'] = true;
c['Columbia County3'] = true;
c['Columbia County4'] = true;
c['Cowlitz County1'] = false;
c['Cowlitz County2'] = true;
c['Cowlitz County3'] = false;
c['Cowlitz County4'] = true;
c['Douglas County1'] = true;
c['Douglas County2'] = false;
c['Douglas County3'] = false;
c['Douglas County4'] = true;
c['Ferry County1'] = true;
c['Ferry County2'] = false;
c['Ferry County3'] = false;
c['Ferry County4'] = true;
c['Franklin County1'] = true;
c['Franklin County2'] = false;
c['Franklin County3'] = true;
c['Franklin County4'] = true;
c['Garfield County1'] = true;
c['Garfield County2'] = false;
c['Garfield County3'] = false;
c['Garfield County4'] = true;
c['Grant County1'] = true;
c['Grant County2'] = false;
c['Grant County3'] = false;
c['Grant County4'] = true;
c['Grays Harbor County1'] = false;
c['Grays Harbor County2'] = true;
c['Grays Harbor County3'] = true;
c['Grays Harbor County4'] = true;
c['Island County1'] = false;
c['Island County2'] = true;
c['Island County3'] = true;
c['Island County4'] = true;
c['Jefferson County1'] = false;
c['Jefferson County2'] = true;
c['Jefferson County3'] = false;
c['Jefferson County4'] = true;
c['King County1'] = false;
c['King County2'] = true;
c['King County3'] = true;
c['King County4'] = true;
c['Kitsap County1'] = false;
c['Kitsap County2'] = true;
c['Kitsap County3'] = true;
c['Kitsap County4'] = true;
c['Kittitas County1'] = true;
c['Kittitas County2'] = false;
c['Kittitas County3'] = true;
c['Kittitas County4'] = true;
c['Klickitat County1'] = false;
c['Klickitat County2'] = true;
c['Klickitat County3'] = false;
c['Klickitat County4'] = true;
c['Lewis County1'] = false;
c['Lewis County2'] = true;
c['Lewis County3'] = true;
c['Lewis County4'] = true;
c['Lincoln County1'] = true;
c['Lincoln County2'] = false;
c['Lincoln County3'] = false;
c['Lincoln County4'] = true;
c['Mason County1'] = false;
c['Mason County2'] = true;
c['Mason County3'] = true;
c['Mason County4'] = true;
c['Okanogan County1'] = true;
c['Okanogan County2'] = false;
c['Okanogan County3'] = false;
c['Okanogan County4'] = true;
c['Pacific County1'] = false;
c['Pacific County2'] = true;
c['Pacific County3'] = false;
c['Pacific County4'] = true;
c['Pend Oreille County1'] = true;
c['Pend Oreille County2'] = false;
c['Pend Oreille County3'] = false;
c['Pend Oreille County4'] = true;
c['Pierce County1'] = false;
c['Pierce County2'] = true;
c['Pierce County3'] = true;
c['Pierce County4'] = true;
c['San Juan County1'] = false;
c['San Juan County2'] = true;
c['San Juan County3'] = true;
c['San Juan County4'] = true;
c['Skagit County1'] = false;
c['Skagit County2'] = true;
c['Skagit County3'] = true;
c['Skagit County4'] = true;
c['Skamania County1'] = true;
c['Skamania County2'] = false;
c['Skamania County3'] = false;
c['Skamania County4'] = true;
c['Snohomish County1'] = false;
c['Snohomish County2'] = true;
c['Snohomish County3'] = true;
c['Snohomish County4'] = true;
c['Spokane County1'] = true;
c['Spokane County2'] = false;
c['Spokane County3'] = true;
c['Spokane County4'] = true;
c['Stevens County1'] = true;
c['Stevens County2'] = false;
c['Stevens County3'] = false;
c['Stevens County4'] = true;
c['Thurston County1'] = false;
c['Thurston County2'] = true;
c['Thurston County3'] = true;
c['Thurston County4'] = true;
c['Wahkiakum County1'] = false;
c['Wahkiakum County2'] = true;
c['Wahkiakum County3'] = false;
c['Wahkiakum County4'] = true;
c['Walla Walla County1'] = false;
c['Walla Walla County2'] = true;
c['Walla Walla County3'] = true;
c['Walla Walla County4'] = true;
c['Whatcom County1'] = false;
c['Whatcom County2'] = true;
c['Whatcom County3'] = true;
c['Whatcom County4'] = true;
c['Whitman County1'] = true;
c['Whitman County2'] = false;
c['Whitman County3'] = true;
c['Whitman County4'] = true;
c['Yakima County1'] = false;
c['Yakima County2'] = true;
c['Yakima County3'] = true;
c['Yakima County4'] = true;

function showinstructions(agent) {

    closeagents();
    // open instructions window
    document.getElementById('instructions').style.display = 'block';
    // hide all instruction pdf's
    for (x = 1; x < 10; x++) {
        document.getElementById('i-plan-' + x).style.display = 'none';
    }
    //show instruction pdfs for current plan
    if (chosenplan == 3 || chosenplan == 6) {
        
        if (chosenplan == 3) {
            if (c[county + '1'] == false && c[county + '2'] == true) {
                // Regence
                document.getElementById('i-plan-' + chosenplan).style.display = 'block';
            } else if (c[county + '1'] == true && c[county + '2'] == false) {
                // asuris
                // 2 - Asuris HSA 4 - Core 6 - Clarity
                document.getElementById('i-plan-8').style.display = 'block';
            }
        }
        if (chosenplan == 6) {
            if (c[county + '1'] == false && c[county + '2'] == true) {
                // Regence
                document.getElementById('i-plan-' + chosenplan).style.display = 'block';
            } else if (c[county + '1'] == true && c[county + '2'] == false) {
                // asuris
                // 2 - Asuris HSA 4 - Core 6 - Clarity
                document.getElementById('i-plan-9').style.display = 'block';
            }
        }
    } else {
        document.getElementById('i-plan-' + chosenplan).style.display = 'block';
    }

    //	document.getElementById('i-plan-' + chosenplan).style.display = 'block';

    document.cookie = "agent=" + escape(agent) + ";";
    
	// change links 
	switch (chosenplan) {
		case 1: 
			//Regence and Asuris
			if(c[county + '1'] == false && c[county + '2'] == true) { 
				switch (agent) {
    			    case 'RyanHart':
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0003';
        			    return;
        			case 'BeckyHart':
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
        				return;
        			case 'KyleHart':
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0004';
        			    return;
					case 'PeterLaney':
						document.getElementById("planlink").href = 'http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0005';
					 	return;
        		    }
			} else if (c[county + '1'] == true && c[county + '2'] == false) { 
				switch (agent) {
    			    case 'RyanHart':
    			        document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
    			        return;
    			    case 'BeckyHart':
        				document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
						return;
                    case 'KyleHart':
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
       				    return;
					case 'PeterLaney':
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
					 	return;
       				}
			}
			
	 	case 2: 
			// Lifewise
			switch (agent) {
    			 case 'RyanHart':
    			    document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101314';
    			    return;
    			 case 'BeckyHart':
        			document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101299';
        			return;
        		 case 'KyleHart':
	        		document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101318';
	        	       return;
				 case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=149726';
					 return;
	        	}
    	case 3: 
			//Regence and Asuris
			if(c[county + '1'] == false && c[county + '2'] == true) { 
				switch (agent) {
    			 case 'RyanHart':
    			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
    			    return;
	    		 case 'BeckyHart':
    				//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-06&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
        			return;
	    		 case 'KyleHart':	
	    			//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-03&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
	    		    return;
 				case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
					 return;
				}
			} else if (c[county + '1'] == true && c[county + '2'] == false) { 
				switch (agent) {    
				    case 'RyanHart':
    			        //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
    			        return;
    			    case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
        				return;
                    case 'KyleHart':
       				    //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
       				    return;
					case 'PeterLaney':
						 document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
						 return;
       				}
			}		
		case 4: 
			// Lifewise
			switch (agent) {
    			 case 'RyanHart':
    			    document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101314';
    			    return;
    			 case 'BeckyHart':
        			document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101299';
        			return;
        		 case 'KyleHart':
	        		document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101318';
	        	       return;
     		   case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=149726';
					 return;
	        	}
			
		case 5: 
			// Group Health
			switch (agent) {
    			    case 'RyanHart':
    			        document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117319';
    			        return;
    			    case 'BeckyHart':    
            			document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117296';
            			return;
            		case 'KyleHart':
            			document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117266';
            			return;
						case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=149688';
					 return;
            		}
			
		case 6: 
			//Regence and Asuris
			if(c[county + '1'] == false && c[county + '2'] == true) { 
				switch (agent) {
    			    case 'RyanHart':
        			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0003';
        			    return;
        			case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-06&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
        				return;
        			case 'KyleHart':
        			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-03&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0004';
        			    return;
						case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0005';
					 return;
        		    }
			} else if (c[county + '1'] == true && c[county + '2'] == false) { 
				switch (agent) {
    			    case 'RyanHart':
    			        //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
    			        return;
    			    case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
        				document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
						return;
                    case 'KyleHart':
       				    //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
       				    return;
					case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
					 return;
       				}
			}
        }
}

function apply(plannumber){

    if (pageloaded) {
        chosenplan = plannumber;

        //showinstructions(plannumber);

        if (get_cookie("agent")) {
            //window.alert(get_cookie("agent"))
            showinstructions(get_cookie("agent"));
        } else {
            if(newcookie == null) {
	            document.getElementById('agentselection').style.display = 'block';
			} else {
				showinstructions(newcookie);	
			}
        }
    }	
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function closesearch() {
    document.getElementById('search-pop').style.display = 'none';
}
function closeinstructions() {
	document.getElementById('instructions').style.display='none';	
}
function closeagents() {
	document.getElementById('agentselection').style.display='none';	
}

function pageload(opensearch){
	// link to output elements for readability.
	plan1 = document.getElementById('plan1-rate');
	plan2 = document.getElementById('plan2-rate');
	plan3 = document.getElementById('plan3-rate');
	plan4 = document.getElementById('plan4-rate');			
	plan5 = document.getElementById('plan5-rate');
	plan6 = document.getElementById('plan6-rate');
	plan7 = document.getElementById('plan7-rate');
	plan8 = document.getElementById('plan8-rate');
	plan9 = document.getElementById('plan9-rate');
	plan10 = document.getElementById('plan10-rate');
	plan11 = document.getElementById('plan11-rate');
	plan12 = document.getElementById('plan12-rate');
	var select1 = document.getElementById('select1');
	var select2 = document.getElementById('select2');
	var p_male_age = document.getElementById('p_male_age');
	var r_male_age = document.getElementById('r_male_age');
	var p_female_age = document.getElementById('p_female_age');
	var r_female_age = document.getElementById('r_female_age');
	var p_numChildren = document.getElementById('p_numChildren');
	var r_numChildren = document.getElementById('r_numChildren');
	
	// Populate Combo Boxes
	for(i=0; i<cnames.length; i++) {
		select1.options[i] = new Option(cnames[i], cnames[i]);
		select2.options[i] = new Option(cnames[i], cnames[i]);
	}	
	for(i=0; i<=ages.length - 1; i++) {
		r_male_age.options[i] = new Option(ages[i], agevalues[i]);
		p_male_age.options[i] = new Option(ages[i], agevalues[i]);
		r_female_age.options[i] = new Option(ages[i], agevalues[i]);
		p_female_age.options[i] = new Option(ages[i], agevalues[i]);
	}
	for(i=0; i<= 10; i++) {
		r_numChildren.options[i] = new Option(i, i);
		p_numChildren.options[i] = new Option(i, i);
	}	
	if(opensearch) 
	    {
	        document.getElementById('search-pop').style.display = 'block';
	    } else {
			 popchange();
		}
	    pageloaded = true;
}

function popchange()	{
	male_age = document.getElementById('p_male_age').value;
	if(document.getElementById('p_s_male').checked) {male_smoker = true; }else{ male_smoker = false;}
	female_age = document.getElementById('p_female_age').value;
	if(document.getElementById('p_s_female').checked) { female_smoker = true; } else { female_smoker = false; } 
	numChildren = document.getElementById('p_numChildren').value;
	county = document.getElementById('select1').value;
	
	document.getElementById('r_male_age').value = document.getElementById('p_male_age').value;
	document.getElementById('r_s_male').checked = document.getElementById('p_s_male').checked;
	document.getElementById('r_female_age').value = document.getElementById('p_female_age').value;
	document.getElementById('r_s_female').checked = document.getElementById('p_s_female').checked;
	document.getElementById('r_numChildren').value = document.getElementById('p_numChildren').value;
	document.getElementById('select2').value = document.getElementById('select1').value

	changestyles();
	
	calculate();
}
function recalculate()	{
	male_age = document.getElementById('r_male_age').value;
	if(document.getElementById('r_s_male').checked) {male_smoker = true; }else{ male_smoker = false;}
	female_age = document.getElementById('r_female_age').value;
	if(document.getElementById('r_s_female').checked) { female_smoker = true; } else { female_smoker = false; } 
	numChildren = document.getElementById('r_numChildren').value;
	county = document.getElementById('select2').value;
	
	document.getElementById('p_male_age').value = document.getElementById('r_male_age').value;
	document.getElementById('p_s_male').checked = document.getElementById('r_s_male').checked;
	document.getElementById('p_female_age').value = document.getElementById('r_female_age').value;
	document.getElementById('p_s_female').checked = document.getElementById('r_s_female').checked;
	document.getElementById('p_numChildren').value = document.getElementById('r_numChildren').value;
	document.getElementById('select1').value = document.getElementById('select2').value
	
	changestyles();
	
	calculate();
}

function changestyles () {
	
	var hidecolor = "#eeeeee";
	var hideindent = "-9999px"
    var normalindent = "0px"
	// Asuris
	if(c[county + '1'] == false && c[county + '2'] == true) { 
		
		document.getElementById('img1').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/plans_2.jpg";
		
		// set to Regence
		document.getElementById('img3').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/plans_2.jpg";
		document.getElementById('pn3').innerHTML = "Evolve Core";
		//document.getElementById('pdf3').href = "http://www.healthinsuranceconnection.com/docs/HSA/HSA_DetailedInfo.pdf";

		document.getElementById('img6').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/plans_2.jpg";
		document.getElementById('pn6').innerHTML = "Evolve Plus";
		//document.getElementById('pdf6').href = "http://www.healthinsuranceconnection.com/2010/Evolve%20Plus/DetailedInfo.pdf";
		
		document.getElementById('plan1-overlay').style.display = 'none';
		document.getElementById('plan3-overlay').style.display = 'none';
		document.getElementById('plan6-overlay').style.display = 'none';
		document.getElementById('plan1').style.color='black'; 
		document.getElementById('plan3').style.color='black'; 
		document.getElementById('plan6').style.color='black';  
		
		} 
	else if (c[county + '1'] == true && c[county + '2'] == false) { 
		
		document.getElementById('img1').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/asuris-logo.jpg";
		
		// set to Asuris
		document.getElementById('img3').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/asuris-logo.jpg";
		document.getElementById('pn3').innerHTML = "Asuris Core";
		//document.getElementById('pdf3').href = "http://www.healthinsuranceconnection.com/docs/HSA/HSA_DetailedInfo.pdf";
		
		document.getElementById('img6').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/asuris-logo.jpg";
		document.getElementById('pn6').innerHTML = "Asuris Plus";
		//document.getElementById('pdf2').href = "docs/HSA/HSA_DetailedInfo.pdf";
		
		document.getElementById('plan1-overlay').style.display = 'none';
		document.getElementById('plan3-overlay').style.display = 'none';
		document.getElementById('plan6-overlay').style.display = 'none';
		document.getElementById('plan1').style.color='black';
		document.getElementById('plan3').style.color='black';  
		document.getElementById('plan6').style.color='black';  
		
	} else {
		document.getElementById('plan1').style.color= hidecolor;  
		document.getElementById('plan1-overlay').style.display = 'block';
		document.getElementById('plan3').style.color= hidecolor;  
		document.getElementById('plan3-overlay').style.display = 'block';
		document.getElementById('plan6').style.color= hidecolor;   
		document.getElementById('plan6-overlay').style.display = 'block';
	}
	
	
	if(c[county + '3'] == false) { // Group Health
		//document.getElementById('plan1').style.color= hidecolor;    
		//document.getElementById('plan1-overlay').style.display = 'block';
		document.getElementById('plan5').style.color= hidecolor;    
		document.getElementById('plan5-overlay').style.display = 'block';
		} 
	else { 
		//document.getElementById('plan1').style.color='black';   
		//document.getElementById('plan1-overlay').style.display = 'none';
		document.getElementById('plan5').style.color='black';  
		document.getElementById('plan5-overlay').style.display = 'none';
		// Hide plan 1 and plan 5
		}
		
	if(c[county + '4'] == false) { // Lifewise
		document.getElementById('plan2').style.color= hidecolor;   
		document.getElementById('plan2-overlay').style.display = 'block';
		document.getElementById('plan4').style.color= hidecolor;   
		document.getElementById('plan4-overlay').style.display = 'block';
		}
	else { 
		document.getElementById('plan2').style.color='black';  
		document.getElementById('plan2-overlay').style.display = 'none';
 		document.getElementById('plan4').style.color='black';  
		document.getElementById('plan4-overlay').style.display = 'none';
	}
	
}

function closepop() {
	document.getElementById('search-pop').style.display = 'none';	
}


function calculate(){

	closepop();

	male = male_age;
	female = female_age;
	children = numChildren;

	if (!male_smoker && !female_smoker){
		plan1.innerHTML = "$" + eval(calc_p1(male)+calc_p1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_p2(male)+calc_p2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_p3(male)+calc_p3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_p4(male)+calc_p4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_p5(male)+calc_p5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_p6(male)+calc_p6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_p7(male)+calc_p7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_p8(male)+calc_p8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_p9(male)+calc_p9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_p10(male)+calc_p10(female)+calc_pc10(children));
	} else  if (!male_smoker && female_smoker){
		plan1.innerHTML = "$" + eval(calc_p1(male)+calc_ps1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_p2(male)+calc_ps2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_p3(male)+calc_ps3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_p4(male)+calc_ps4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_p5(male)+calc_ps5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_p6(male)+calc_ps6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_p7(male)+calc_ps7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_p8(male)+calc_ps8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_p9(male)+calc_ps9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_p10(male)+calc_ps10(female)+calc_pc10(children));
	} else  if (male_smoker && !female_smoker){
		plan1.innerHTML = "$" + eval(calc_ps1(male)+calc_p1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_ps2(male)+calc_p2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_ps3(male)+calc_p3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_ps4(male)+calc_p4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_ps5(male)+calc_p5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_ps6(male)+calc_p6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_ps7(male)+calc_p7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_ps8(male)+calc_p8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_ps9(male)+calc_p9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_ps10(male)+calc_p10(female)+calc_pc10(children));
		plan.innerHTML = "$" + eval(calc_ps(male)+calc_p(female)+calc_pc(children));
		plan.innerHTML = "$" + eval(calc_ps(male)+calc_p(female)+calc_pc(children));
	} else  if (male_smoker && female_smoker){
		plan1.innerHTML = "$" + eval(calc_ps1(male)+calc_ps1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_ps2(male)+calc_ps2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_ps3(male)+calc_ps3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_ps4(male)+calc_ps4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_ps5(male)+calc_ps5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_ps6(male)+calc_ps6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_ps7(male)+calc_ps7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_ps8(male)+calc_ps8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_ps9(male)+calc_ps9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_ps10(male)+calc_ps10(female)+calc_pc10(children));
	}
}

//code column - cut and paste to file
//Group Health HSA Healthpays
function calc_p1(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 75; }
if (age < 30) { return 86; }
if (age < 35) { return 100; }
if (age < 40) { return 118; }
if (age < 45) { return 139; }
if (age < 50) { return 168; }
if (age < 55) { return 200; }
if (age < 60) { return 235; }
if (age < 100) { return 276; }
return 0; 
}

// Smoker
function calc_ps1(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 86; }
if (age < 30) { return 99; }
if (age < 35) { return 115; }
if (age < 40) { return 136; }
if (age < 45) { return 160; }
if (age < 50) { return 194; }
if (age < 55) { return 231; }
if (age < 60) { return 271; }
if (age < 100) { return 317; }
return 0; 
}

// Children
function calc_pc1(num) {
if (num < 1) { return 0; }
if (num < 2) { return 75; }
if (num < 3) { return 150; }
if (num < 4) { return 225; }
if (num < 5) { return 300; }
if (num < 6) { return 375; }
if (num < 7) { return 450; }
if (num < 8) { return 525; }
if (num < 9) { return 600; }
if (num < 10) { return 675; }
return 0; 
}

// Group Health HSA Healthpays
function calc_p2(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 137; }
if (age < 30) { return 156; }
if (age < 35) { return 179; }
if (age < 40) { return 214; }
if (age < 45) { return 251; }
if (age < 50) { return 316; }
if (age < 55) { return 387; }
if (age < 60) { return 450; }
if (age < 100) { return 513; }
return 0; 
}

// Smoker
function calc_ps2(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 161; }
if (age < 30) { return 180; }
if (age < 35) { return 208; }
if (age < 40) { return 250; }
if (age < 45) { return 295; }
if (age < 50) { return 365; }
if (age < 55) { return 450; }
if (age < 60) { return 522; }
if (age < 100) { return 600; }
return 0; 
}

// Children
function calc_pc2(num) {
if (num < 1) { return 0; }
if (num < 2) { return 116; }
if (num < 3) { return 232; }
if (num < 4) { return 348; }
if (num < 5) { return 464; }
if (num < 6) { return 580; }
if (num < 7) { return 696; }
if (num < 8) { return 812; }
if (num < 9) { return 928; }
if (num < 10) { return 1044; }
return 0; 
}

// Lifewise HSA 
function calc_p3(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 118; }
if (age < 30) { return 133; }
if (age < 35) { return 153; }
if (age < 40) { return 184; }
if (age < 45) { return 215; }
if (age < 50) { return 271; }
if (age < 55) { return 332; }
if (age < 60) { return 387; }
if (age < 100) { return 440; }
return 0; 
}

// Smoker
function calc_ps3(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 138; }
if (age < 30) { return 155; }
if (age < 35) { return 177; }
if (age < 40) { return 214; }
if (age < 45) { return 252; }
if (age < 50) { return 314; }
if (age < 55) { return 387; }
if (age < 60) { return 448; }
if (age < 100) { return 514; }
return 0; 
}

// Children
function calc_pc3(num) {
if (num < 1) { return 0; }
if (num < 2) { return 98; }
if (num < 3) { return 196; }
if (num < 4) { return 294; }
if (num < 5) { return 392; }
if (num < 6) { return 490; }
if (num < 7) { return 588; }
if (num < 8) { return 686; }
if (num < 9) { return 784; }
if (num < 10) { return 882; }
return 0; 
}

// Lifewise HSA 
function calc_p4(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 110; }
if (age < 30) { return 127; }
if (age < 35) { return 147; }
if (age < 40) { return 174; }
if (age < 45) { return 205; }
if (age < 50) { return 248; }
if (age < 55) { return 295; }
if (age < 60) { return 346; }
if (age < 100) { return 405; }
return 0; 
}

// Smoker
function calc_ps4(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 127; }
if (age < 30) { return 146; }
if (age < 35) { return 169; }
if (age < 40) { return 200; }
if (age < 45) { return 235; }
if (age < 50) { return 285; }
if (age < 55) { return 339; }
if (age < 60) { return 398; }
if (age < 100) { return 466; }
return 0; 
}

// Children
function calc_pc4(num) {
if (num < 1) { return 0; }
if (num < 2) { return 110; }
if (num < 3) { return 220; }
if (num < 4) { return 330; }
if (num < 5) { return 440; }
if (num < 6) { return 550; }
if (num < 7) { return 660; }
if (num < 8) { return 770; }
if (num < 9) { return 880; }
if (num < 10) { return 990; }
return 0; 
}

// RBS Evolve Core
function calc_p5(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 205; }
if (age < 30) { return 233; }
if (age < 35) { return 268; }
if (age < 40) { return 321; }
if (age < 45) { return 376; }
if (age < 50) { return 473; }
if (age < 55) { return 579; }
if (age < 60) { return 674; }
if (age < 100) { return 767; }
return 0; 
}

// Smoker
function calc_ps5(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 240; }
if (age < 30) { return 270; }
if (age < 35) { return 311; }
if (age < 40) { return 374; }
if (age < 45) { return 440; }
if (age < 50) { return 547; }
if (age < 55) { return 674; }
if (age < 60) { return 782; }
if (age < 100) { return 897; }
return 0; 
}

// Children
function calc_pc5(num) {
if (num < 1) { return 0; }
if (num < 2) { return 173; }
if (num < 3) { return 346; }
if (num < 4) { return 519; }
if (num < 5) { return 692; }
if (num < 6) { return 865; }
if (num < 7) { return 1038; }
if (num < 8) { return 1211; }
if (num < 9) { return 1384; }
if (num < 10) { return 1557; }
return 0; 
}

// Lifewise Wisechoices Prime
function calc_p7(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 246; }
if (age < 30) { return 299; }
if (age < 35) { return 312; }
if (age < 40) { return 288; }
if (age < 45) { return 302; }
if (age < 50) { return 345; }
if (age < 55) { return 425; }
if (age < 60) { return 507; }
if (age < 100) { return 655; }
return 0; 
}

// Smoker
function calc_ps7(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 285; }
if (age < 30) { return 346; }
if (age < 35) { return 361; }
if (age < 40) { return 335; }
if (age < 45) { return 349; }
if (age < 50) { return 399; }
if (age < 55) { return 496; }
if (age < 60) { return 589; }
if (age < 100) { return 761; }
return 0; 
}

// Children
function calc_pc7(num) {
if (num < 1) { return 0; }
if (num < 2) { return 151; }
if (num < 100) { return 302; }
return 0; 
}

// Lifewise Wisechoices Prime
function calc_p8(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 256; }
if (age < 30) { return 311; }
if (age < 35) { return 325; }
if (age < 40) { return 300; }
if (age < 45) { return 314; }
if (age < 50) { return 359; }
if (age < 55) { return 442; }
if (age < 60) { return 528; }
if (age < 100) { return 682; }
return 0; 
}

// Smoker
function calc_ps8(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 307; }
if (age < 30) { return 373; }
if (age < 35) { return 387; }
if (age < 40) { return 360; }
if (age < 45) { return 376; }
if (age < 50) { return 429; }
if (age < 55) { return 531; }
if (age < 60) { return 635; }
if (age < 100) { return 818; }
return ; 
}

// Children
function calc_pc8(num) {
if (num < 1) { return 0; }
if (num < 2) { return 147; }
if (num < 3) { return 294; }
if (num < 4) { return 441; }
if (num < 5) { return 588; }
if (num < 6) { return 735; }
if (num < 7) { return 882; }
if (num < 8) { return 1029; }
if (num < 9) { return 1176; }
if (num < 10) { return 1323; }
return 0; 
}

// Group Health Balance
function calc_p9(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 238; }
if (age < 30) { return 273; }
if (age < 35) { return 317; }
if (age < 40) { return 375; }
if (age < 45) { return 441; }
if (age < 50) { return 533; }
if (age < 55) { return 635; }
if (age < 60) { return 745; }
if (age < 100) { return 873; }
return 0; 
}

// Smoker
function calc_ps9(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 274; }
if (age < 30) { return 314; }
if (age < 35) { return 365; }
if (age < 40) { return 431; }
if (age < 45) { return 507; }
if (age < 50) { return 613; }
if (age < 55) { return 730; }
if (age < 60) { return 857; }
if (age < 100) { return 1004; }
return 0; 
}

// Children
function calc_pc9(num) {
if (num < 1) { return 0; }
if (num < 2) { return 238; }
if (num < 3) { return 476; }
if (num < 4) { return 714; }
if (num < 5) { return 952; }
if (num < 6) { return 1190; }
if (num < 7) { return 1428; }
if (num < 8) { return 1666; }
if (num < 9) { return 1904; }
if (num < 10) { return 2142; }
return 0; 
}

// Group Health Balance
function calc_p10(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 180; }
if (age < 30) { return 207; }
if (age < 35) { return 240; }
if (age < 40) { return 284; }
if (age < 45) { return 334; }
if (age < 50) { return 404; }
if (age < 55) { return 480; }
if (age < 60) { return 564; }
if (age < 100) { return 660; }
return 0; 
}

// Smoker
function calc_ps10(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 207; }
if (age < 30) { return 238; }
if (age < 35) { return 276; }
if (age < 40) { return 326; }
if (age < 45) { return 384; }
if (age < 50) { return 464; }
if (age < 55) { return 552; }
if (age < 60) { return 648; }
if (age < 100) { return 759; }
return 0; 
}

// Children
function calc_pc10(num) {
if (num < 1) { return 0; }
if (num < 2) { return 180; }
if (num < 3) { return 360; }
if (num < 4) { return 540; }
if (num < 5) { return 720; }
if (num < 6) { return 900; }
if (num < 7) { return 1080; }
if (num < 8) { return 1260; }
if (num < 9) { return 1440; }
if (num < 10) { return 1620; }
return 0; 
}













































































