/*
ver 1.20041111
make sure this file is sync'd up with the master
or use this as the master EXCEPT for custom jobs
*/
	var newWin;
	var submitting = 0;
	var thisDate = new Date();

// validates any selections, close this layer
	function mc_tu()  {
		ret = check_fp_tu();
		if (document.wq_form.type.value == "joint")
			ret = check_sp_tu();
		return ret;
	}

	function check_fp_tu()	{

		if (document.wq_form["First Client Tobacco Use"][0].checked)	{
			if (document.wq_form.fp_smoker_cigarette.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_cigar.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_cigarello.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_pipe.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_chew.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_marijuana.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_snuff.selectedIndex == 0 &&
		      document.wq_form.fp_smoker_prescribe.selectedIndex == 0)	
		      {
// sep 14 2006				s = "First Client Tobacco Use:\n\nYou have answered Yes to using Tobacco Products. But you have not selected any products.\n\nPlease press 'Ok' to process this survey without Tobacco Use.\n Press Cancel to return and choose some Tobacco Products.";
				if (document.wq_form.lang_code.value == "fr")
					s = "Premier client Usage du tabac:\n\nVous avez repondu que Oui a l'utilisation des produits de tabac, mais vous n'aviez pas selectionner aucun produits.\n\n S'il vous plait, appuyer 'OK' pour proceder avec le sondage sans usage de tabac.\n Appuyer 'Annuler' (Cancel) pour retourner et choisir l'usage des produits de tabac.";
				else if (document.wq_form.lang_code.value == "es")
					s = "Primer cliente Uso del tabaco:\n\nRespondieron que sí tiene la utilización de los productos de tabaco, pero no tenían selectio ningunos productos.\n\n Si él plait, apoyarles 'OK' para proceder con el sondeo sin uso de tabaco.\n Apoyar 'Cancelar' (Cancel) para devolver y elegir el uso de los productos de tabaco.";
				else if (document.wq_form.lang_code.value == "it")
					s = "Primo cliente impiego del tabacco:\n\nAvete risposto che sì ha l'utilizzo dei prodotti di tabacco, ma non avevate selectionner nessun prodotti.\n\n S'il.vous.plaît, sostenere 'OK' per procedere con il sondaggio senza impiego di tabacco.\n Sostenere 'annullare' (Cancel) per tornare e scegliere l'impiego dei prodotti di tabacco.";
				else
					s = "First Client Tobacco Use:\n\nYou have answered Yes to using Tobacco Products. But you have not selected any products.\n\nPlease press 'Ok' to process this survey without Tobacco Use.\n Press 'Cancel' to return and choose some Tobacco Products.";
				if (confirm(s) )	{
					document.wq_form["First Client Tobacco Use"][1].checked = true;
					tufilterClear();
					hide_layer("tuLayer");
					return true;
				}
			}
			else
				return true;
		}	
		else if (! document.wq_form["First Client Tobacco Use"][1].checked)	
		{
// sep 14 2006				s = "First Client Tobacco Use:\n\nYou have not indicated whether you have ever used or consumed tobacco.\n\nClick 'OK' to continue with the assumption of no such use, ever.\nClick 'Cancel' to return to indicate the tobacco type and last occasion of use.";
			if (document.wq_form.lang_code.value == "fr")
				s = "Premier client Usage du tabac:\n\nVous n'aviez pas indiquer si vous aviez jamais utiliser ou consommer le tabac.\n\n Cliquer 'OK' pour continuer avec les suppositions de non-usage, jamais.\n Appuyer 'Annuler' (Cancel) pour retourner et indiquer le type de tabac et l'occurance de l'usage.";
			else if (document.wq_form.lang_code.value == "es")
				s = "Primer cliente Uso del tabaco:\n\nNo tenían indicar si tuvieran nunca utilizar o consumir el tabaco.\n\n Pulsar 'OK' para seguir con las suposiciones de dejar de usar, nunca.\n Apoyar 'Cancelar' (Cancel) para devolver e indicar el tipo de tabaco y del occurance del uso.";
			else if (document.wq_form.lang_code.value == "it")
				s = "Primo cliente impiego del tabacco:\n\nNon avevate segnalare se aveste mai utilizzare o consumare il tabacco.\n\n Premere 'OK' per continuare con le ipotesi di mancato uso, mai.\n Sostenere 'Annullare' (Cancel) per tornare ed indicare il tipo di tabacco ed occurance dell'impiego.";				
			else
				s = "First Client Tobacco Use:\n\nYou have not indicated whether you have ever used or consumed tobacco.\n\nClick 'OK' to continue with the assumption of no such use, ever.\n Click 'Cancel' to return to indicate the tobacco type and last occasion of use.";
			if (confirm(s) )	{
				document.wq_form["First Client Tobacco Use"][1].checked = true;
				tufilterClear();
				hide_layer("tuLayer");
				return true;
			}
		}
		else
			return true;

		document.wq_form["First Client Tobacco Use"][0].checked = true;
		show_layer("tuLayer");
		return false;

	}

	function check_sp_tu()	{
		if (document.wq_form["Second Client Tobacco Use"][0].checked)	{
			if (document.wq_form.sp_smoker_cigarette.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_cigar.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_cigarello.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_pipe.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_chew.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_marijuana.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_snuff.selectedIndex == 0 &&
		      document.wq_form.sp_smoker_prescribe.selectedIndex == 0)	{
// sep 14 2006				s = "Second Client Tobacco Use:\n\nYou have answered Yes to using Tobacco Products. But you have not selected any products.\n\nPlease press 'Ok' to process this survey without Tobacco Use.\n Press Cancel to return and choose some Tobacco Products.";
				if (document.wq_form.lang_code.value == "fr")
					s = "Deuxieme client Usage du tabac:\n\nVous avez repondu que Oui a l'utilisation des produits de tabac, mais vous n'aviez pas selectionner aucun produits.\n\n S'il vous plait, appuyer 'OK' pour proceder avec le sondage sans usage de tabac.\n Appuyer 'Annuler' (Cancel) pour retourner et choisir l'usage des produits de tabac.";
				else if (document.wq_form.lang_code.value == "es")
					s = "Segundo cliente Uso del tabaco:\n\nRespondieron que sí tiene la utilización de los productos de tabaco, pero no tenían selectio ningunos productos.\n\n Si él plait, apoyarles 'OK' para proceder con el sondeo sin uso de tabaco.\n Apoyar 'Cancelar' (Cancel) para devolver y elegir el uso de los productos de tabaco.";
				else if (document.wq_form.lang_code.value == "it")
					s = "Secondo cliente impiego del tabacco:\n\nAvete risposto che sì ha l'utilizzo dei prodotti di tabacco, ma non avevate selectionner nessun prodotti.\n\n S'il.vous.plaît, sostenere 'OK' per procedere con il sondaggio senza impiego di tabacco.\n Sostenere 'annullare' (Cancel) per tornare e scegliere l'impiego dei prodotti di tabacco.";
				else
					s = "Second Client Tobacco Use:\n\nYou have answered Yes to using Tobacco Products. But you have not selected any products.\n\nPlease press 'Ok' to process this survey without Tobacco Use.\n Press 'Cancel' to return and choose some Tobacco Products.";
				if (confirm(s) )	{
					document.wq_form["Second Client Tobacco Use"][1].checked = true;
					tufilterClear2();
					hide_layer("tuLayer2");
					return true;
				}
			}
			else
				return true;
		}	else if (! document.wq_form["Second Client Tobacco Use"][1].checked)	{
// sep 14 2006				s = "Second Client Tobacco Use:\n\nYou have not indicated whether you have ever used or consumed tobacco.\n\nClick 'OK' to continue with the assumption of no such use, ever.\nClick 'Cancel' to return to indicate the tobacco type and last occasion of use.";
			if (document.wq_form.lang_code.value == "fr")
				s = "Deuxieme client Usage du tabac:\n\nVous n'aviez pas indiquer si vous aviez jamais utiliser ou consommer le tabac.\n\n Cliquer 'OK' pour continuer avec les suppositions de non-usage, jamais.\n Appuyer 'Annuler' (Cancel) pour retourner et indiquer le type de tabac et l'occurance de l'usage.";
			else if (document.wq_form.lang_code.value == "es")
				s = "Segundo cliente Uso del tabaco:\n\nNo tenían indicar si tuvieran nunca utilizar o consumir el tabaco.\n\n Pulsar 'OK' para seguir con las suposiciones de dejar de usar, nunca.\n Apoyar 'Cancelar' (Cancel) para devolver e indicar el tipo de tabaco y del occurance del uso.";
			else if (document.wq_form.lang_code.value == "it")
				s = "Secondo cliente impiego del tabacco:\n\nNon avevate segnalare se aveste mai utilizzare o consumare il tabacco.\n\n Premere 'OK' per continuare con le ipotesi di mancato uso, mai.\n Sostenere 'Annullare' (Cancel) per tornare ed indicare il tipo di tabacco ed occurance dell'impiego.";				
			else
				s = "First Client Tobacco Use:\n\nYou have not indicated whether you have ever used or consumed tobacco.\n\nClick 'OK' to continue with the assumption of no such use, ever.\n Click 'Cancel' to return to indicate the tobacco type and last occasion of use.";
			if (confirm(s) )	{
				document.wq_form["Second Client Tobacco Use"][1].checked = true;
				tufilterClear2();
				hide_layer("tuLayer2");
				return true;
			}
		}
		else
			return true;

		document.wq_form["Second Client Tobacco Use"][0].checked = true;
		show_layer("tuLayer2");
		return false;

	}

/*
resets values for tobacco use fields if client checks 'No'
*/
	function tufilterClear()  {
		document.wq_form.fp_smoker_cigarette.selectedIndex = 0;
		document.wq_form.fp_smoker_cigar.selectedIndex = 0;
		document.wq_form.fp_smoker_cigarello.selectedIndex = 0;
		document.wq_form.fp_smoker_pipe.selectedIndex = 0;
		document.wq_form.fp_smoker_chew.selectedIndex = 0;
		document.wq_form.fp_smoker_marijuana.selectedIndex = 0;
		document.wq_form.fp_smoker_snuff.selectedIndex = 0;
		document.wq_form.fp_smoker_prescribe.selectedIndex = 0;
	}

	function tufilterClear2()  {
		document.wq_form.sp_smoker_cigarette.selectedIndex = 0;
		document.wq_form.sp_smoker_cigar.selectedIndex = 0;
		document.wq_form.sp_smoker_cigarello.selectedIndex = 0;
		document.wq_form.sp_smoker_pipe.selectedIndex = 0;
		document.wq_form.sp_smoker_chew.selectedIndex = 0;
		document.wq_form.sp_smoker_marijuana.selectedIndex = 0;
		document.wq_form.sp_smoker_snuff.selectedIndex = 0;
		document.wq_form.sp_smoker_prescribe.selectedIndex = 0;
	}

	function mc_qafd(obj, layer, mode)  {
		return true;
	}
	function qafilterClear(obj)  {
	}
	function fmhfilterClear(obj)  {
	}
	function dhfilterClear(obj)  {
	}
	function pageSetup(obj)	{
		tufilterClear();
		if (DHTML)
			hide_layer("tuLayer");
		if (document.wq_form.type.value == "joint")	{
			tufilterClear2();
			if (DHTML)
				hide_layer("tuLayer2");
		}
	}
	function pageSetdown(obj)	{
		if (mc_tu())	{
			if (DHTML)
				displaySubmitLayer("proceedLine");
			return true;
		}
		return false;
	}
	function riskCheck(obj)	{
	}
	function displaySubmitLayer(lyr)	{
		window.location="#top";
/*
		myBody = document.getElementById( ""+ lyr +"" );
		removeChildren(myBody);
		myDiv = document.createElement("DIV");
		myDiv.className = "optionButtonOver";
		myDiv.style.position = "relative";
		myDiv.style.height = 60 +"px";
		myDiv.style.border = "2px black solid";
// sep 14 2006		myDivText = document.createTextNode( "Surveying the market. Please Wait..." );
		if (document.wq_form.lang_code.value == "fr")
			myDivText = document.createTextNode( "en trein de faire le sondage du Marche.  S'il vous plait attend..." );
		else if (document.wq_form.lang_code.value == "es")
			myDivText = document.createTextNode( "en trein de hacer el sondeo de la Marcha. Si plait les espera..." );
		else if (document.wq_form.lang_code.value == "it")
			myDivText = document.createTextNode( "in trein di fare il sondaggio del mercato. S'il.vous.plaît aspetta..." );			
		else
			myDivText = document.createTextNode( "Surveying the market. Please Wait..." );
		myDiv.appendChild(myDivText);
		myBody.appendChild(myDiv);
*/

	}
	function removeChildren  (myObj)  {
		objChild = myObj.firstChild;
		do  {
			if (objChild)
				myObj.removeChild(objChild);
			objChild = myObj.firstChild;
		} while (objChild)
	}

	function check_layer(obj_id)  {
		if (DHTML)	{
			layer_id = document.getElementById(obj_id);
			if (layer_id.style.display == "none")
				show_layer(obj_id);
			else
				hide_layer(obj_id);
		}
	}
	function show_layer(show_id)  {
		if (DHTML)	{
			s_id = document.getElementById(show_id);
			s_id.style.display = "";
		}
	}
	function hide_layer(hide_id)  {
		if (DHTML)	{
			h_id = document.getElementById(hide_id);
			h_id.style.display = "none";
		}
	}
	function check_radio(selectOBJ, radioOBJ)	{
		if (selectOBJ.selectedIndex > 0)
			radioOBJ[0].checked = true;
		else
			radioOBJ[1].checked = true;
	}
	function check_radioEX(selectOBJ1, selectOBJ2, selectOBJ3, selectOBJ4, radioOBJ)	{
		if (selectOBJ1.selectedIndex > 0 || selectOBJ2.selectedIndex > 0  ||
			selectOBJ3.selectedIndex > 0 || selectOBJ4.selectedIndex > 0)
			radioOBJ[0].checked = true;
		else
			radioOBJ[1].checked = true;
	}
	function check_select(selectOBJ, radioOBJ)	{
		if (radioOBJ[1].checked)	{
			selectOBJ.selectedIndex = 0;
		}
	}
	function check_selectEX(selectOBJ1, selectOBJ2, selectOBJ3, selectOBJ4, radioOBJ)	{
		if (radioOBJ[1].checked)	{
			selectOBJ1.selectedIndex = 0;
			selectOBJ2.selectedIndex = 0;
			selectOBJ3.selectedIndex = 0;
			selectOBJ4.selectedIndex = 0;
		}
	}

	function enableTU(obj)	{
	}
	function disableTU(obj)	{
	}
	function enableQA(obj)	{
	}
	function disableQA(obj)	{
	}
	function enableFMH(obj)  {
	}
	function disableFMH(obj)  {
	}
	function enableDH(obj)  {
	}
	function disableDH(obj)  {
	}

// jun 19 2009
// mobile apps use this for now, could be used in the future for all
    function manageRadioButton(obj)  {
        obj.className="optionButtonOver";
       
        if (obj.value == "Female")
        {
            document.wq_form["First Client Gender"].value = 2;
            document.wq_form.genderButtonMale.className="optionButton";      
        }
        else if (obj.value == "Male")
        {
            document.wq_form["First Client Gender"].value = 1;
            document.wq_form.genderButtonFemale.className="optionButton";
        }

        else if (obj.value == "Yes")
        {
            document.wq_form["First Client Tobacco Use"].value = "Y";
            document.wq_form.tobaccoUseButtonNo.className="optionButton";
            show_layer("tuLayer");
        }
        
        else if (obj.value == "No")
        {
            document.wq_form["First Client Tobacco Use"].value = "N";
            document.wq_form.tobaccoUseButtonYes.className="optionButton";
            hide_layer("tuLayer");
        }                        
    }

//

