//hides a section
function hideSpan(name){
	if(document.getElementById(name) != null){
		document.getElementById(name).style.display = 'none';
	}
}
//displays a section
function showSpan(name){
	if(document.getElementById(name) != null){
		document.getElementById(name).style.display = 'block';
	}
}


function selectedSelf(){
	deselectOther();
	deselectSelf();
	deselectMeds();
	deselectMedsChild();
	deselectCrossSell();
	
	hideSpan('other');
	hideSpan('other_child_diagnosed');
	hideSpan('other_adult');
	hideSpan('medications');
	hideSpan('lamictal');
	hideSpan('medications_child');
	hideSpan('lamictal_child');
	hideSpan('cross_sell');
    hideSpan('trade_child');
    hideSpan('trade_adult');
	showSpan('self_when_diagnosed');

}

function selectedSomeoneElse() {
	//deselectOther();
	deselectSelf();
	deselectMeds();
	deselectCrossSell();
	
	//hideSpan('other_child_diagnosed');
	hideSpan('other_child_doctor');
	hideSpan('other_adult');	
	hideSpan('self_when_diagnosed');
	hideSpan('medications');
	hideSpan('lamictal');
	//hideSpan('change_meds');
	hideSpan('cross_sell');
	showSpan('other');
     hideSpan('trade_child');
    hideSpan('trade_adult');
}

function selectedChildAsOther() {
	//hideSpan('other_child_doctor');
	hideSpan('other_adult');
	hideSpan('medications');
	hideSpan('lamictal');
    hideSpan('lamictal_child');
	hideSpan('change_meds');
	hideSpan('cross_sell');

	deselectSub('QUES_When_Child_Diagnosed_With_Epilepsy');
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');
	deselectSelf();
	deselectMeds();
	deselectCrossSell();
    deselectMedsChild();
	
	showSpan('other_child_diagnosed');
}

function selectedAdultAsOther() {
	hideSpan('other_child_doctor');
	hideSpan('other_child_diagnosed');
	hideSpan('medications');
	hideSpan('medications_child');
	hideSpan('lamictal');
	hideSpan('lamictal_child');
	hideSpan('cross_sell');
    hideSpan('trade_child');
    hideSpan('trade_adult');
	
	deselectSub('QUES_When_You_Diagnosed_With_Epilepsy');
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');
    deselectSub('QUES_When_Child_Diagnosed_With_Epilepsy');
	deselectSelf();
	deselectMeds();
	deselectCrossSell();
	deselectMedsChild();
	showSpan('other_adult');
}

function selectedChildDiagnosed() {	
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');
	deselectSelf();
	deselectMeds();
	//deselectCrossSell();
	
	showSpan('other_child_doctor');
	showSpan('medications_child');
	showSpan('cross_sell');
    showSpan('trade_child');
    hideSpan('trade_adult');
	
}

function selectedChildNotDiagnosed() {
	hideSpan('other_child_doctor');
	hideSpan('medications_child');
	hideSpan('lamictal_child');
	hideSpan('cross_sell');
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');
	deselectSelf();
	deselectMeds();
	deselectMedsChild();
	deselectCrossSell();	
}

function selectedChildNotTold() {
	hideSpan('other_child_doctor');
	hideSpan('medications_child');
	hideSpan('lamictal_child');
	hideSpan('cross_sell');
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');
	deselectSelf();
	deselectMeds();
	deselectMedsChild();
	deselectCrossSell();	
}

function selectedChildDoctor() {
	hideSpan('medications');
}


function selectedWhenIWasDiagnosed() {
	deselectSub('QUES_What_Doctor_Epilepsy');
	showSpan('self_doctor');
	showSpan('medications');
	showSpan('cross_sell');
     showSpan('trade_adult');
    hideSpan('trade_child');

}

function selectedIWasNotDiagnosed() {
	hideSpan('self_doctor');	
	hideSpan('medications');
	hideSpan('lamictal');
	hideSpan('change_meds');
	hideSpan('cross_sell');
	deselectSub('QUES_What_Doctor_Epilepsy');
	deselectMeds();
	deselectCrossSell();
}

function selectedIHaveNotBeenTold() {
	hideSpan('self_doctor');	
	hideSpan('medications');
	hideSpan('lamictal');
	hideSpan('change_meds');
	hideSpan('cross_sell');
	deselectSub('QUES_What_Doctor_Epilepsy');
	deselectMeds();
	deselectCrossSell();
}

function selectedAMed(choice) {
	selCurOrNone(choice);
	//showSpan('change_meds');
	showSpan('cross_sell');
	if(choice == 'none') {
		hideSpan('lamictal');
        deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy');
	}
}

function selectedNoMed(choice) {
	selCurOrNone(choice);
	//hideSpan('change_meds');
	hideSpan('cross_sell');
	hideSpan('lamictal');
	deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy');
	deselectSub('QUES_Medications_Control_Epilepsy');
	//deselectSub('QUES_Willing_To_Change_Epilepsy_Meds');
	deselectCrossSell();
}

function selectedAMedChild(choice) {
	selCurOrNoneChild(choice);
	showSpan('cross_sell');
	if(choice == 'none') {
		hideSpan('lamictal_child');
        deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy');
        deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy_Child');
	}
}

function selectedNoMedChild(choice) {
	selCurOrNoneChild(choice);
	hideSpan('cross_sell');
	hideSpan('lamictal_child');
	deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy_Child');
	deselectSub('QUES_Medications_Control_Epilepsy_Child');
	deselectCrossSell();
}

function selectedLamictal() {
	var box = document.getElementById('QUES_Taking_LAMICTAL_Epilepsy');
	if (box.checked) {
		showSpan('lamictal');
	} else {
		hideSpan('lamictal');
		deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy');
		deselectSub('QUES_Medications_Control_Epilepsy');
	}
}

function selectedLamictalChild() {
	var box = document.getElementById('QUES_Taking_LAMICTAL_Epilepsy_Child');
	if (box.checked) {
		showSpan('lamictal_child');
	} else {
		hideSpan('lamictal_child');
		deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy_Child');
		deselectSub('QUES_Medications_Control_Epilepsy_Child');
	}
}




function clearOnNoneSel( id, Ids, noneField ) {
	if ( id == "none" ) {
		for ( var i=0; i < Ids.length; i++ ) {
			var q = window.document.savingsForm.elements[ Ids[i] ];
			q.checked = false;
		}
	} else {
		// id == "one" 
		window.document.savingsForm.elements[noneField].checked = false;
	}
}
	 
function selCurOrNone( id ) {
	var curIds = ["QUES_Taking_CARBATROL_Epilepsy","QUES_Taking_DEPAKENE_Epilepsy","QUES_Taking_DILANTIN_Epilepsy","QUES_Taking_GABITRIL_Epilepsy","QUES_Taking_KEPPRA_Epilepsy","QUES_Taking_KEPPRAXRTM_Epilepsy","QUES_Taking_LAMICTAL_Epilepsy","QUES_Taking_LAMICTALODTTM_Epilepsy","QUES_Taking_LAMICTALXRTM_Epilepsy","QUES_Taking_LYRICA_Epilepsy","QUES_Taking_MYSOLINE_Epilepsy","QUES_Taking_NEURONTIN_Epilepsy","QUES_Taking_PHENYTEK_Epilepsy","QUES_Taking_TEGRETOL_Epilepsy","QUES_Taking_TOPAMAX_Epilepsy","QUES_Taking_TRILEPTAL_Epilepsy","QUES_Taking_VIMPAT_Epilepsy","QUES_Taking_ZONEGRAN_Epilepsy"];
	clearOnNoneSel( id, curIds, "QUES_Taking_NOMEDS_Epilepsy" );
}


function selCurOrNoneChild( id ) {
	var curIds = ["QUES_Taking_CARBATROL_Epilepsy_Child","QUES_Taking_DEPAKENE_Epilepsy_Child","QUES_Taking_DILANTIN_Epilepsy_Child","QUES_Taking_GABITRIL_Epilepsy_Child","QUES_Taking_KEPPRA_Epilepsy_Child","QUES_Taking_KEPPRAXRTM_Epilepsy_Child","QUES_Taking_LAMICTAL_Epilepsy_Child","QUES_Taking_LAMICTALODTTM_Epilepsy_Child","QUES_Taking_LAMICTALXRTM_Epilepsy_Child","QUES_Taking_LYRICA_Epilepsy_Child","QUES_Taking_MYSOLINE_Epilepsy_Child","QUES_Taking_NEURONTIN_Epilepsy_Child","QUES_Taking_PHENYTEK_Epilepsy_Child","QUES_Taking_TEGRETOL_Epilepsy_Child","QUES_Taking_TOPAMAX_Epilepsy_Child","QUES_Taking_TRILEPTAL_Epilepsy_Child","QUES_Taking_VIMPAT_Epilepsy_Child","QUES_Taking_ZONEGRAN_Epilepsy_Child"];
	clearOnNoneSel( id, curIds, "QUES_Taking_NOMEDS_Epilepsy_Child" );
}


function selDisOrNone( id ) {
	var disIds = ["QUES_treatment_options_Anxiety","QUES_treatment_options_Asthma","QUES_treatment_options_COPD","QUES_treatment_options_ED","QUES_treatment_options_Heart_Disease","QUES_treatment_options_HBP","QUES_treatment_options_Migraine","QUES_treatment_options_NA","QUES_treatment_options_Prostrate_Cancer"];
	clearOnNoneSel( id, disIds, "Are_interested_receiving_info" );
}


function deselectOther(){
	deselectSub('QUES_Who_Is_Other_Person');
	deselectSub('QUES_When_Child_Diagnosed_With_Epilepsy');
	deselectSub('QUES_What_Doctor_Epilepsy_Child');
	deselectSub('QUES_Other_Currently_Taking_Lamictal');	
}

function deselectSelf(){
	deselectSub('QUES_When_You_Diagnosed_With_Epilepsy');
	deselectSub('QUES_What_Doctor_Epilepsy');
}

function deselectMeds(){
	document.savingsForm.QUES_Taking_CARBATROL_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_DEPAKENE_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_DILANTIN_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_GABITRIL_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_KEPPRA_Epilepsy.checked = false;
    document.savingsForm.QUES_Taking_KEPPRAXRTM_Epilepsy.checked=false;
	document.savingsForm.QUES_Taking_LAMICTAL_Epilepsy.checked = false;
    document.savingsForm.QUES_Taking_LAMICTALODTTM_Epilepsy.checked=false;
    document.savingsForm.QUES_Taking_LAMICTALXRTM_Epilepsy.checked=false;
	document.savingsForm.QUES_Taking_LYRICA_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_MYSOLINE_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_NEURONTIN_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_PHENYTEK_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_TEGRETOL_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_TOPAMAX_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_TRILEPTAL_Epilepsy.checked = false;
    document.savingsForm.QUES_Taking_VIMPAT_Epilepsy.checked=false;
	document.savingsForm.QUES_Taking_ZONEGRAN_Epilepsy.checked = false;
	document.savingsForm.QUES_Taking_NOMEDS_Epilepsy.checked = false;
	
	deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy');
	deselectSub('QUES_Medications_Control_Epilepsy');
}


function deselectMedsChild() {
	document.savingsForm.QUES_Taking_CARBATROL_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_DEPAKENE_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_DILANTIN_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_GABITRIL_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_KEPPRA_Epilepsy_Child.checked = false;
    document.savingsForm.QUES_Taking_KEPPRAXRTM_Epilepsy_Child.checked=false;
	document.savingsForm.QUES_Taking_LAMICTAL_Epilepsy_Child.checked = false;
    document.savingsForm.QUES_Taking_LAMICTALODTTM_Epilepsy_Child.checked=false;
    document.savingsForm.QUES_Taking_LAMICTALXRTM_Epilepsy_Child.checked=false;
	document.savingsForm.QUES_Taking_LYRICA_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_MYSOLINE_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_NEURONTIN_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_PHENYTEK_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_TEGRETOL_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_TOPAMAX_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_TRILEPTAL_Epilepsy_Child.checked = false;
    document.savingsForm.QUES_Taking_VIMPAT_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_ZONEGRAN_Epilepsy_Child.checked = false;
	document.savingsForm.QUES_Taking_NOMEDS_Epilepsy_Child.checked = false;	
	
	deselectSub('QUES_Taking_LAMICTAL_How_Long_Epilepsy_Child');
	deselectSub('QUES_Medications_Control_Epilepsy_Child');	
}



function deselectCrossSell(){
	document.savingsForm.QUES_treatment_options_Anxiety.checked = false;
	document.savingsForm.QUES_treatment_options_Asthma.checked = false;
	document.savingsForm.QUES_treatment_options_COPD.checked = false;
	document.savingsForm.QUES_treatment_options_ED.checked = false;
	document.savingsForm.QUES_treatment_options_Heart_Disease.checked = false;
	document.savingsForm.QUES_treatment_options_HBP.checked = false;
	document.savingsForm.QUES_treatment_options_Migraine.checked = false;
	document.savingsForm.QUES_treatment_options_NA.checked = false;
	document.savingsForm.QUES_treatment_options_Prostrate_Cancer.checked = false;
	document.savingsForm.Are_interested_receiving_info.checked = false;

}


function deselectSub(name){
	if(document.savingsForm != null){
		var f = document.savingsForm;
		if(f[name] != null){
			for(var x=0; x < f[name].length; x++){
				if(f[name][x].checked==true){
					f[name][x].checked=false;
				}
			}
		}
	}
}


