var selectedForm = '';

function getDecision()
{
	if (selectedForm == '')
	{
		selectedForm = 'contact';
	}
	
	return selectedForm;
}

function contactSubmit(formName)
{
    if (formName != "contact")
    {
        submit(formName);
        return;
    }
    
	var info = new Array();

	for(var i = 0; i < forms[0].length; i++)
	{
		if(forms[0][i] == formName)
		{
			info.push(forms[1][i]);
			info.push(forms[4][i]);
			info.push(forms[5][i]);
			info.push(forms[2][i]);
			info.push(forms[3][i]);
			break;
		}
	}

	if(info.length != 5)
		return;

	var xml = createXML(info, formName);
	self.frames["resultFrame"].document.forms["frm12345"].xml.value = xml;
	//self.frames["resultFrame"].document.forms["frm12345"].action = '../cgi-bin/contact_form.pl' +xml;
	//self.frames["resultFrame"].document.forms["frm12345"].submit();

	successInfo = info[3];
	setTimeout('contactSubmit2()', 1000);
}

function contactSubmit2()
{
    var formName = "contact2";

    var info = new Array();

	for(var i = 0; i < forms[0].length; i++)
	{
		if(forms[0][i] == formName)
		{
			info.push(forms[1][i]);
			info.push(forms[4][i]);
			info.push(forms[5][i]);
			info.push(forms[2][i]);
			info.push(forms[3][i]);
			break;
		}
	}

	if(info.length != 5)
		return;

	var xml = createXML(info, formName);
	self.frames["resultFrame2"].document.forms["frm12345"].xml.value = xml;
	//self.frames["resultFrame2"].document.forms["frm12345"].action = '../cgi-bin/contact_form.pl' +xml;
	//self.frames["resultFrame2"].document.forms["frm12345"].submit();

	setTimeout('contactSubmit3()', 1000);
}

function contactSubmit3()
{
    var formName = "contact3";

    var info = new Array();

	for(var i = 0; i < forms[0].length; i++)
	{
		if(forms[0][i] == formName)
		{
			info.push(forms[1][i]);
			info.push(forms[4][i]);
			info.push(forms[5][i]);
			info.push(forms[2][i]);
			info.push(forms[3][i]);
			break;
		}
	}

	if(info.length != 5)
		return;

	var xml = createXML(info, formName);
	self.frames["resultFrame3"].document.forms["frm12345"].xml.value = xml;
	self.frames["resultFrame3"].document.forms["frm12345"].action = '../cgi-bin/contact_form.pl' +xml;
	self.frames["resultFrame3"].document.forms["frm12345"].submit();

	setTimeout('success()', 3000);
}

function showDoNots2(value)
{
	if (value == 'nomail')
	{
		document.getElementById('mailDiv').style.display = '';
		document.getElementById('mailDiv').style.visibility = 'visible';
		document.getElementById('phoneDiv1').style.display = '';
		document.getElementById('phoneDiv1').style.visibility = 'visible';
		document.getElementById('phoneDiv2').style.display = 'none';
		document.getElementById('phoneDiv2').style.visibility = 'hidden';
		changeReturnRequirness('nocontact', 'address', true);
		changeReturnRequirness('nocontact', 'city', true);
		changeReturnRequirness('nocontact', 'state', true);
		changeReturnRequirness('nocontact', 'zip', true);
		changeReturnRequirness('nocontact', 'phone', false);
	}
	else if (value == 'noemail')
	{
		document.getElementById('mailDiv').style.display = 'none';
		document.getElementById('mailDiv').style.visibility = 'hidden';
		document.getElementById('phoneDiv1').style.display = '';
		document.getElementById('phoneDiv1').style.visibility = 'visible';
		document.getElementById('phoneDiv2').style.display = 'none';
		document.getElementById('phoneDiv2').style.visibility = 'hidden';
		changeReturnRequirness('nocontact', 'address', false);
		changeReturnRequirness('nocontact', 'city', false);
		changeReturnRequirness('nocontact', 'state', false);
		changeReturnRequirness('nocontact', 'zip', false);
		changeReturnRequirness('nocontact', 'phone', false);
	}
	else if (value == 'nophone')
	{
		document.getElementById('mailDiv').style.display = 'none';
		document.getElementById('mailDiv').style.visibility = 'hidden';
		document.getElementById('phoneDiv1').style.display = 'none';
		document.getElementById('phoneDiv1').style.visibility = 'hidden';
		document.getElementById('phoneDiv2').style.display = '';
		document.getElementById('phoneDiv2').style.visibility = 'visible';
		changeReturnRequirness('nocontact', 'address', false);
		changeReturnRequirness('nocontact', 'city', false);
		changeReturnRequirness('nocontact', 'state', false);
		changeReturnRequirness('nocontact', 'zip', false);
		changeReturnRequirness('nocontact', 'phone', true);
	}
	else
	{
		document.getElementById('mailDiv').style.display = '';
		document.getElementById('mailDiv').style.visibility = 'visible';
		document.getElementById('phoneDiv1').style.display = 'none';
		document.getElementById('phoneDiv1').style.visibility = 'hidden';
		document.getElementById('phoneDiv2').style.display = '';
		document.getElementById('phoneDiv2').style.visibility = 'visible';
		changeReturnRequirness('nocontact', 'address', true);
		changeReturnRequirness('nocontact', 'city', true);
		changeReturnRequirness('nocontact', 'state', true);
		changeReturnRequirness('nocontact', 'zip', true);
		changeReturnRequirness('nocontact', 'phone', true);
	}
}

function showDoNots(value)
{
	if (value == 'doNotContact')
	{
		document.getElementById('contact').style.display = 'none';
		document.getElementById('contact').style.visibility = 'hidden';
		document.getElementById('doNots').style.display = '';
		document.getElementById('doNots').style.visibility = 'visible';
		
		// begin fix SD Request#365128
		document.getElementById("emailTo").value = "larry.keeler\@healthmarkets.com";
		// end
		
		changeReturnRequirness('nocontact', 'address', true);
		changeReturnRequirness('nocontact', 'city', true);
		changeReturnRequirness('nocontact', 'state', true);
		changeReturnRequirness('nocontact', 'zip', true);
		selectedForm = 'nocontact';
	}
	else
	{
		document.getElementById('contact').style.display = '';
		document.getElementById('contact').style.visibility = 'visible';
		document.getElementById('doNots').style.display = 'none';
		document.getElementById('doNots').style.visibility = 'hidden';
         switch (value)
        {
            case "generalInqury":
                document.getElementById("emailTo").value = "customercare1\@healthmarkets.com";
                break;
            case "recruitingSales":
                document.getElementById("emailTo").value = "careers\@healthmarketssales.com";
                break;
            case "corporateCareers":
                document.getElementById("emailTo").value = "jobs\@healthmarkets.com";
                break;
            case "customerService":
                document.getElementById("emailTo").value = "customercare1\@healthmarkets.com ";
                break;
            case "mediaInquiry":
                document.getElementById("emailTo").value = "donna.ledbetter\@healthmarkets.com ";
                break;
        }
		selectedForm = 'contact';
	}
}