
function setFormVals() 
{
    patient.style.display = 'inline';
    patient.style.display = 'none';
  
    /*
    if (subscribe.h_patient_type.value != "")
    {        
        for (i = 0; i < subscribe.patient_type.length; i++)
		{
			if (subscribe.h_patient_type.value.indexOf(subscribe.patient_type[i].value) > -1) 
			    subscribe.patient_type[i].checked = true;
			    
		}
		
		for (i = 0; i < subscribe.patient_therapy_location.length; i++)
		{
			if (subscribe.h_patient_therapy_location.value.indexOf(subscribe.patient_therapy_location[i].value) > -1) 
			    subscribe.patient_therapy_location[i].checked = true;
			    
		}
		
        subscribe.subscriber[0].checked = true;
        patient.style.display = 'inline';
    }
    
   if (subscribe.h_patient_family_friend_type.value != "")
    {        
        for (i = 0; i < subscribe.patient_family_friend_type.length; i++)
		{
			if (subscribe.h_patient_family_friend_type.value.indexOf(subscribe.patient_family_friend_type[i].value) > -1) 
			    subscribe.patient_family_friend_type[i].checked = true;			    
		}
 		for (i = 0; i < subscribe.patient_therapy_location.length; i++)
		{
			if (subscribe.h_patient_therapy_location.value.indexOf(subscribe.patient_family_friend_therapy_location[i].value) > -1) 
			    subscribe.patient_family_friend_therapy_location[i].checked = true;
			    
		}
 
        subscribe.subscriber[1].checked = true;
        patient_family_member.style.display = 'inline';
    }
    */        
}

function setText(textCheck, textItem)
{
	textItem.value = textCheck.checked ? textItem.value : '';
}

function setCheck(textItem, checkboxCheck)
{
	if (textItem.value != '')
	{
		checkboxCheck.checked = true;
	}
}

function setVisibleAdmin()
{
    
	if (subscribe.subscriber[0].checked)
	{
		patient.style.display = 'inline';
		{
			if (subscribe.patient_type[0].checked)	
			{
				patient_pid.style.display = 'inline'; 
			}
			else
			{	
				for (i = 0; i < subscribe.patient_pid_type.length; i++) 
				{
					subscribe.patient_pid_type[i].checked = false; 
				}
				subscribe.patient_pid_other_type.value = '';
				patient_pid.style.display = 'none';
			}
		}	
	
	}
	else
	{
		for (i = 0; i < subscribe.patient_type.length; i++)
		{
			subscribe.patient_type[i].checked = false;
		}
		subscribe.patient_other_neuropathy_type.value = '';
		subscribe.patient_myositis_type.value = '';
		subscribe.patient_other_type.value = '';
		patient.style.display = 'none';
	}

	if (subscribe.subscriber[1].checked)
	{
		patient_family_member.style.display = 'inline';
		{
			if (subscribe.patient_family_friend_type[0].checked)
			{
				family_friend_pid.style.display = 'inline';
			}
			else
			{
				for (i = 0; i < subscribe.family_friend_pid_type.length; i++) 
				{
					subscribe.family_friend_pid_type[i].checked = false; 
				}
				subscribe.family_friend_pid_other_type.value = '';
				family_friend_pid.style.display = 'none';
			}
		}
	}
	else
	{
		for (i = 0; i < subscribe.patient_family_friend_type.length; i++)
		{
			subscribe.patient_family_friend_type[i].checked = false;
		}
		subscribe.patient_family_friend_other_neuropathy_type.value = '';
		subscribe.patient_family_friend_myositis_type.value = '';
		subscribe.patient_family_friend_other_type.value = '';
		patient_family_member.style.display = 'none';
	}

	if (subscribe.subscriber[2].checked)
	{
		pat_organization.style.display = 'inline';
		subscribe.patient_organization_name.focus();
	}	
	else
	{
		subscribe.patient_organization_name.value = '';
		//subscribe.txtPatOrgQuantity.value = ''; //CY - removed quantity from this checkbox level
		pat_organization.style.display = 'none';
	}

	if (subscribe.subscriber[3].checked)
	{
		healthcare_professional.style.display = 'inline';
	}
	else
	{
		for (i = 0; i < subscribe.healthcare_professional_type.length; i++)
		{
			subscribe.healthcare_professional_type[i].checked = false;
		}
		subscribe.healthcare_professional_other_type.value = '';
		subscribe.txtQuantity.value = '';
		healthcare_professional.style.display = 'none';
	}
}

function setVisible()
{
    if (subscribe.ezine != null) 
    {
        if (subscribe.ezine.checked)
        {
            user_registration.style.display = 'inline';
            subscribe.txtUsername.focus();
        } 
        else 
        {
            user_registration.style.display = 'none';
            subscribe.txtUsername.value = "";
            subscribe.txtPassword.value = "";
            subscribe.txtPassword2.value = "";
        }
    }
    
	if (subscribe.subscriber[0].checked) 
	{
		patient.style.display = 'inline'; 
		{	
			if (subscribe.patient_type[0].checked)	
			{
				patient_pid.style.display = 'inline'; 
			}
			else
			{	
				for (i = 0; i < subscribe.patient_pid_type.length; i++) 
				{
					subscribe.patient_pid_type[i].checked = false; 
				}
				subscribe.patient_pid_other_type.value = '';
				patient_pid.style.display = 'none';	
			}
		}
	}
	else
	{	
		for (i = 0; i < subscribe.patient_type.length; i++)
		{
			subscribe.patient_type[i].checked = false;
		}
		subscribe.patient_other_neuropathy_type.value = '';
		subscribe.patient_myositis_type.value = '';
		subscribe.patient_other_type.value = '';
		patient.style.display = 'none';
	}
		
	if (subscribe.subscriber[1].checked)
	{
		patient_family_member.style.display = 'inline';
		{
			if (subscribe.patient_family_friend_type[0].checked)
			{
				family_friend_pid.style.display = 'inline';
			}
			else
			{
				for (i = 0; i < subscribe.family_friend_pid_type.length; i++) 
				{
					subscribe.family_friend_pid_type[i].checked = false; 
				}
				subscribe.family_friend_pid_other_type.value = '';
				family_friend_pid.style.display = 'none';
			}
		}
	}
	else
	{
		for (i = 0; i < subscribe.patient_family_friend_type.length; i++)
		{
			subscribe.patient_family_friend_type[i].checked = false;
		}
		subscribe.patient_family_friend_other_neuropathy_type.value = '';
		subscribe.patient_family_friend_myositis_type.value = '';
		subscribe.patient_family_friend_other_type.value = '';
		patient_family_member.style.display = 'none';
	}

	if (subscribe.subscriber[2].checked)
	{	
		pat_organization.style.display = 'inline';
		subscribe.patient_organization_name.focus();
		if  (subscribe.txtPatOrgQuantity.value == "0" || subscribe.txtPatOrgQuantity.value == '')
				{
					subscribe.txtPatOrgQuantity.value = '1';
				}
	}	
	else
	{
		/*for (i = 0; i < subscribe.patient_organization_type.length; i++)
		{
			subscribe.healthcare_professional_type[i].checked = false;
		}*/
		subscribe.patient_organization_name.value = '';
		subscribe.txtPatOrgQuantity.value = '0';
		pat_organization.style.display = 'none';
	}

	
	if (subscribe.subscriber[3].checked)
	{
		healthcare_professional.style.display = 'inline';
		if  (subscribe.txtQuantity.value == "0" || subscribe.txtQuantity.value == '')
				{
					subscribe.txtQuantity.value = '1';
				}
	}
	else
	{
		for (i = 0; i < subscribe.healthcare_professional_type.length; i++)
		{
			subscribe.healthcare_professional_type[i].checked = false;
		}
		subscribe.healthcare_professional_other_type.value = '';
		subscribe.txtQuantity.value = '0';
		healthcare_professional.style.display = 'none';
	}
	
	if (subscribe.txtQuantity.value == '0' && subscribe.txtPatOrgQuantity.value == '0')
	{
		subscribe.txtPatOrgQuantity.value = '0';
		subscribe.txtQuantity.value = '1';
	}

}

// CY - changed setVisible to setEditVisible in subscription_edit.aspx page.
function setEditVisible()
{
    if (subscribe.ezine != null) 
    {
        if (subscribe.ezine.checked)
        {
            user_registration.style.display = 'inline';
            subscribe.txtUsername.focus();
        } 
        else 
        {
            user_registration.style.display = 'none';
            subscribe.txtUsername.value = "";
            subscribe.txtPassword.value = "";
            subscribe.txtPassword2.value = "";
        }
    }
    
	if (subscribe.subscriber[0].checked) 
	{
		patient.style.display = 'inline'; 
		{	
			if (subscribe.patient_type[0].checked)	
			{
				patient_pid.style.display = 'inline'; 
			}
			else
			{	
				for (i = 0; i < subscribe.patient_pid_type.length; i++) 
				{
					subscribe.patient_pid_type[i].checked = false; 
				}
				subscribe.patient_pid_other_type.value = '';
				patient_pid.style.display = 'none';	
			}
		}
	}
	else
	{	
		for (i = 0; i < subscribe.patient_type.length; i++)
		{
			subscribe.patient_type[i].checked = false;
		}
		subscribe.patient_other_neuropathy_type.value = '';
		subscribe.patient_myositis_type.value = '';
		subscribe.patient_other_type.value = '';
		patient.style.display = 'none';
	}
		
	if (subscribe.subscriber[1].checked)
	{
		patient_family_member.style.display = 'inline';
		{
			if (subscribe.patient_family_friend_type[0].checked)
			{
				family_friend_pid.style.display = 'inline';
			}
			else
			{
				for (i = 0; i < subscribe.family_friend_pid_type.length; i++) 
				{
					subscribe.family_friend_pid_type[i].checked = false; 
				}
				subscribe.family_friend_pid_other_type.value = '';
				family_friend_pid.style.display = 'none';
			}
		}
	}
	else
	{
		for (i = 0; i < subscribe.patient_family_friend_type.length; i++)
		{
			subscribe.patient_family_friend_type[i].checked = false;
		}
		subscribe.patient_family_friend_other_neuropathy_type.value = '';
		subscribe.patient_family_friend_myositis_type.value = '';
		subscribe.patient_family_friend_other_type.value = '';
		patient_family_member.style.display = 'none';
	}

	if (subscribe.subscriber[2].checked)
	{	
		pat_organization.style.display = 'inline';
		subscribe.patient_organization_name.focus();
		/*if  (subscribe.txtPatOrgQuantity.value == "0" || subscribe.txtPatOrgQuantity.value == '')
				{
					subscribe.txtPatOrgQuantity.value = '1';
				} */
	}	
	else
	{
		/*for (i = 0; i < subscribe.patient_organization_type.length; i++)
		{
			subscribe.healthcare_professional_type[i].checked = false;
		}*/
		subscribe.patient_organization_name.value = '';
		//subscribe.txtPatOrgQuantity.value = '0';
		pat_organization.style.display = 'none';
	}

	
	if (subscribe.subscriber[3].checked)
	{
		healthcare_professional.style.display = 'inline';
		/*if  (subscribe.txtQuantity.value == "0" || subscribe.txtQuantity.value == '')
				{
					subscribe.txtQuantity.value = '1';
				}*/
	}
	else
	{
		for (i = 0; i < subscribe.healthcare_professional_type.length; i++)
		{
			subscribe.healthcare_professional_type[i].checked = false;
		}
		subscribe.healthcare_professional_other_type.value = '';
		//subscribe.txtQuantity.value = '0';
		healthcare_professional.style.display = 'none';
	}
	
	/*if (subscribe.txtQuantity.value == '0' && subscribe.txtPatOrgQuantity.value == '0')
	{
		subscribe.txtPatOrgQuantity.value = '0';
		subscribe.txtQuantity.value = '1';
	}*/

}



function onFocus_clear(fieldname,linetext)
{
	if (fieldname.value==linetext)
		fieldname.value="";
	return true;
}

function onBlur_reset(fieldname,linetext)
{
	if (fieldname.value=="")
		fieldname.value=linetext;
	return true;
}

function echeck(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid Email address")
		return false
	}

	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid Email address")
		return false
	}

	return true;
}


function ValidateForm()
{
    if (subscribe.txtFirstName.value == "First Name" || subscribe.txtFirstName.value == "")
	{
		alert("Please enter your first name.");
		subscribe.txtFirstName.focus();
		return (false);
	}

	if (subscribe.txtLastName.value == "Last Name" || subscribe.txtLastName.value == "")
	{
		alert("Please enter your last name.");
		subscribe.txtLastName.focus();
		return (false);
	}

	if (subscribe.txtAddress1.value == "Address" ||  subscribe.txtAddress1.value == "")
	{
		alert("Please enter your address.");
		subscribe.txtAddress1.focus();
		return (false);
	}

	if (subscribe.txtCity.value == "City" || subscribe.txtCity.value == "")
	{
		alert("Please enter your city.");
		subscribe.txtCity.focus();
		return (false);
	}
	
	
	// additional state, zip and phone error checking if selected country is USA
	if (subscribe.lstCountry.value == "USA") 
	{
	    if (subscribe.lstState.selectedIndex == 0)
	    {
		    alert("Please select a state.");
		    subscribe.lstState.focus();
		    return (false);
	    }
	
	    if (subscribe.txtZip.value == "" && subscribe.lstCountry.value == "USA")
	    {
		    alert("Please enter your zip code.");
		    subscribe.txtZip.focus();
		    return (false);
	    }

	    var strippedzip = subscribe.txtZip.value.replace(/^[\s]+/g, '').replace(/[\-\ ]/g, '');

	    if (isNaN(parseInt(strippedzip)))
	    {
		    if (!((strippedzip.length == 6 && strippedzip.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) || (strippedzip.length == 7 && strippedzip.search(/^[a-zA-Z]\d[a-zA-Z]-\d[a-zA-Z]\d$/) != -1)))
		    {
			    alert("The zip code is invalid.\nPlease correct it.\n");
			    subscribe.txtZip.focus();
			    return false;
		    }
	    }
	    else
	    {
		    if ((strippedzip.length != 5) && (strippedzip.length != 9))
		    {
			    alert("The zip code is invalid.\nPlease correct it.\n");
			    subscribe.txtZip.focus();
			    return false;
		    }
	    }
    
        /*
        if (subscribe.txtPhone.value == "")
	    {
		    alert("Please enter your phone number.");
		    subscribe.txtPhone.focus();
		    return (false);
	    }

	    var strippedphone = subscribe.txtPhone.value.replace(/[\(\)\.\-\ ]/g, '');

	    if (isNaN(parseInt(strippedphone)))
	    {
		    alert("The phone number contains illegal characters.");
		    subscribe.txtPhone.focus();
		    return false;
	    }

	    if (strippedphone.length < 10)
	    {
		    alert("The phone ne number is invalid.\nMake sure you included an area code.\n");
		    subscribe.txtPhone.focus();
		    return false;
	    }
	    
	    subscribe.txtPhone.value=(strippedphone.substring(0,strippedphone.length-10) + "(" + strippedphone.substring(strippedphone.length-10,strippedphone.length-7) + ") " + strippedphone.substring(strippedphone.length-7,strippedphone.length-4) + "-" + strippedphone.substring(strippedphone.length-4,strippedphone.length))
        */
    } 
    else 
    {
        subscribe.lstState.value = "";
        // subscribe.txtZip.value = "";
    }
    
    if (subscribe.txtEmail.value == "")
	{
		alert("Please enter your email address.");
		subscribe.txtEmail.focus();
		return (false);
	}

	if (echeck(subscribe.txtEmail.value) == false)
	{
		subscribe.txtEmail.focus();
		return (false);
	}
	
    
	if (subscribe.subscriber[0].checked)
	{
		patient_type = false;
		for (i = 0; i < subscribe.patient_type.length; i++)
			{
				patient_type = patient_type || subscribe.patient_type[i].checked;
			}
		if (patient_type == false)
			{
				alert("Please select a patient condition.")
				return (false);
			}
		if (subscribe.patient_type[0].checked)  //validate if they chose a primary immune deficiency type. do not force them to choose per Cheryl, except for OTHER.
			{
				patient_pid_type = false;
				for (c = 0; c < subscribe.patient_pid_type.length; c++)
					{
						patient_pid_type = patient_pid_type || subscribe.patient_pid_type[c].checked;

					}
				/*if (patient_pid_type == false)	
					{		
						alert("Please enter a primary immune deficiency type.");
						return (false);
					}*/
				if (subscribe.patient_pid_type[4].checked)
					{
						if (subscribe.patient_pid_other_type.value == "")
							{
								alert("Please enter a type for other PIDD.");
								subscribe.patient_pid_other_type.focus();
								return (false);
							}
					}
			}
		
			
		if (subscribe.patient_type[7].checked)
			{
				if (subscribe.patient_other_neuropathy_type.value == "")
					{
						alert("Please enter an other neuropathy type.");
						subscribe.patient_other_neuropathy_type.focus();
						return (false);
					}
			}
			
		if (subscribe.patient_type[9].checked)
			{
				if (subscribe.patient_myositis_type.value == "")
					{
						alert("Please enter a myositis type.");
						subscribe.patient_myositis_type.focus();
						return (false);
					}
			}
			
		if (subscribe.patient_type[10].checked)
			{
				if (subscribe.patient_other_type.value == "")
					{
						alert("Please enter other type of condition.");
						subscribe.patient_other_type.focus();
						return (false);
					}
			}
			
	
	    var patient_therapy_location_checked = false;
	    		
	   	for (counter = 0; counter < subscribe.patient_therapy_location.length; counter++)
	    {
	        if (subscribe.patient_therapy_location[counter].checked)
	            patient_therapy_location_checked = true;
	    }	
	   
	   if (subscribe.patient_therapy_location[5].checked)
			{
				if (subscribe.patient_therapy_location_other.value == "")
					{
						alert("Please enter other therapy location.");
						subscribe.patient_therapy_location_other.focus();
						return (false);
					}
			}   
			
	    if (!patient_therapy_location_checked)
	    {
            alert("Please select patient therapy location.");
            return (false);
		}
			

	}

	if (subscribe.subscriber[1].checked)
	{
		patient_family_friend_type = false;

		for (i = 0; i < subscribe.patient_family_friend_type.length; i++)
			{
				patient_family_friend_type = patient_family_friend_type || subscribe.patient_family_friend_type[i].checked;
			}
		if (patient_family_friend_type == false)
			{
				alert("Please select a patient family member / friend condition.")
				return (false);
			}
		if (subscribe.patient_family_friend_type[0].checked)
			{
				family_friend_pid_type = false;
				for (d = 0; d < subscribe.family_friend_pid_type.length; d++)
					{
						family_friend_pid_type = family_friend_pid_type || subscribe.family_friend_pid_type[d].checked;
					}
				if (subscribe.family_friend_pid_type[4].checked)
					{
						if (subscribe.family_friend_pid_other_type.value == "")
							{
								alert("Please enter a type for other PIDD.");
								subscribe.family_friend_pid_other_type.focus();
								return (false);
							}
					}
				}	
		if (subscribe.patient_family_friend_type[7].checked)
			{
				if (subscribe.patient_family_friend_other_neuropathy_type.value == "")
					{
						alert("Please enter an other neuropathy type.");
						subscribe.patient_family_friend_other_neuropathy_type.focus();
						return (false);
					}
			}
			
		if (subscribe.patient_family_friend_type[9].checked)
			{
				if (subscribe.patient_family_friend_myositis_type.value == "")
					{
						alert("Please enter a myositis type.");
						subscribe.patient_family_friend_myositis_type.focus();
						return (false);
					}
			}
			
		if (subscribe.patient_family_friend_type[10].checked)
			{
				if (subscribe.patient_family_friend_other_type.value == "")
					{
						alert("Please enter other type of condition.");
						subscribe.patient_family_friend_other_type.focus();
						return (false);
					}
			}
			
	    var therapy_location_checked = false;
	    		
	   	for (counter = 0; counter < subscribe.patient_family_friend_therapy_location.length; counter++)
	    {
	        if (subscribe.patient_family_friend_therapy_location[counter].checked)
	            therapy_location_checked = true;
	    }	
	    
        if (subscribe.patient_family_friend_therapy_location[5].checked)
		{
			if (subscribe.patient_family_friend_therapy_location_other.value == "")
		    {
				alert("Please enter other therapy location.");
				subscribe.patient_family_friend_therapy_location_other.focus();
				return (false);
			}
		}
			
	    if (!therapy_location_checked)
	    {
            alert("Please select patient family member / friend therapy location.");
            return (false);
		}			
	}
	
	if (subscribe.subscriber[2].checked)
	{
		if (subscribe.patient_organization_name.value == "")
			{
			alert("Please enter a patient organization name.");
			subscribe.patient_organization_name.focus();
			return (false);
			}
	}

	if (subscribe.subscriber[3].checked)
	{
		healthcare_professional_type = false;
		for (i = 0; i < subscribe.healthcare_professional_type.length; i++)
			{
				healthcare_professional_type = healthcare_professional_type || subscribe.healthcare_professional_type[i].checked;
			}
		if (healthcare_professional_type == false)
			{
				alert("Please select a healthcare speciality.")
				return (false);
			}

		if (subscribe.healthcare_professional_type[12].checked)
			{
				if (subscribe.healthcare_professional_other_type.value == "")
					{
						alert("Please enter other healthcare professional speciality.");
						subscribe.healthcare_professional_other_type.focus();
						return (false);
					}
			}
	}

	if (subscribe.subscriber[5].checked)
	{
		if (subscribe.other.value == "")
		{
			alert("Please enter a subscription type.");
			subscribe.other.focus();
			return (false);
		}
	}
	
	if (subscribe.txtPatOrgQuantity.value == '' && subscribe.txtQuantity.value == '')
	{ 
		subscribe.txtPatOrgQuantity.value = '0';
		subscribe.txtQuantity.value = '1';
	}

	
	// CY - check if a checkbox has been selected in the Subscription Option area
	if (subscribe.printversion.checked == false && subscribe.ezine.checked == false)
	{
		alert("Please select at least one subscription option.");
		return(false);
	} 
	

    if (subscribe.ezine != null && subscribe.ezine.checked)
    {
        if (subscribe.txtUsername.value == "" || 
        subscribe.txtPassword.value == "") 
        {
        	alert("Please enter a username and password.");
		    subscribe.txtUsername.focus();
			return (false);
        }
        if (subscribe.txtPassword.value != subscribe.txtPassword2.value) 
        {
        	alert("Passwords don't match!");
		    subscribe.txtPassword.focus();
			return (false);
        }			        
    } 
    	
	for (counter = 0; counter < subscribe.subscriber.length; counter++)
	{	
		if (subscribe.subscriber[counter].checked)
		{
			if (!subscribe.subscriber[0].checked)
			{
				for (counter = 1; counter < subscribe.patient_type.length; counter++)
				{
					subscribe.patient_type[counter].checked = false;
				}
				subscribe.patient_other_neuropathy_type.value = "";
				subscribe.patient_myositis_type.value = "";
				subscribe.patient_other_type.value = "";
			}
			if (!subscribe.subscriber[1].checked)
			{
				for (counter = 1; counter < subscribe.patient_family_friend_type.length; counter++)
				{
					subscribe.patient_family_friend_type[counter].checked = false;
				}
				subscribe.patient_family_friend_other_neuropathy_type.value = "";
				subscribe.patient_family_friend_myositis_type.value = "";
				subscribe.patient_family_friend_other_type.value = "";
			}
			if (!subscribe.subscriber[3].checked)
			{
				for (counter = 1; counter < subscribe.healthcare_professional_type.length; counter++)
				{
					subscribe.healthcare_professional_type[counter].checked = false;
				}
				subscribe.healthcare_professional_other_type.value = "";
			}
			return (true);
		}
		
    }
alert("Please select a subscription type.");
return (false);
}

function ValidateAdminEditForm()
{
    if (subscribe.txtFirstName.value == "First Name" || subscribe.txtFirstName.value == "")
	{
		alert("Please enter a first name.");
		subscribe.txtFirstName.focus();
		return (false);
	}

	if (subscribe.txtLastName.value == "Last Name" || subscribe.txtLastName.value == "")
	{
		alert("Please enter a last name.");
		subscribe.txtLastName.focus();
		return (false);
	}

	if (subscribe.txtAddress1.value == "Address" ||  subscribe.txtAddress1.value == "")
	{
		alert("Please enter address.");
		subscribe.txtAddress1.focus();
		return (false);
	}

	if (subscribe.txtCity.value == "City" || subscribe.txtCity.value == "")
	{
		alert("Please enter city.");
		subscribe.txtCity.focus();
		return (false);
	}
	
	
	// additional state, zip and phone error checking if selected country is USA
	if (subscribe.lstCountry.value == "USA") 
	{
	    if (subscribe.lstState.selectedIndex == 0)
	    {
		    alert("Please select a state.");
		    subscribe.lstState.focus();
		    return (false);
	    }
	
	    if (subscribe.txtZip.value == "" && subscribe.lstCountry.value == "USA")
	    {
		    alert("Please enter zip code.");
		    subscribe.txtZip.focus();
		    return (false);
	    }

	    var strippedzip = subscribe.txtZip.value.replace(/^[\s]+/g, '').replace(/[\-\ ]/g, '');

	    if (isNaN(parseInt(strippedzip)))
	    {
		    if (!((strippedzip.length == 6 && strippedzip.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) || (strippedzip.length == 7 && strippedzip.search(/^[a-zA-Z]\d[a-zA-Z]-\d[a-zA-Z]\d$/) != -1)))
		    {
			    alert("The zip code is invalid.\nPlease correct it.\n");
			    subscribe.txtZip.focus();
			    return false;
		    }
	    }
	    else
	    {
		    if ((strippedzip.length != 5) && (strippedzip.length != 9))
		    {
			    alert("The zip code is invalid.\nPlease correct it.\n");
			    subscribe.txtZip.focus();
			    return false;
		    }
	    }
    
    } 
    else 
    {
        subscribe.lstState.value = "";
        // subscribe.txtZip.value = "";
    }
    
    if (subscribe.txtEmail.value == "")
	{
		alert("Please enter an email address.");
		subscribe.txtEmail.focus();
		return (false);
	}

	if (echeck(subscribe.txtEmail.value) == false)
	{
		subscribe.txtEmail.focus();
		return (false);
	}   
    	
	for (counter = 0; counter < subscribe.subscriber.length; counter++)
	{	
		if (subscribe.subscriber[counter].checked)
		{
			if (!subscribe.subscriber[0].checked)
			{
				for (counter = 1; counter < subscribe.patient_type.length; counter++)
				{
					subscribe.patient_type[counter].checked = false;
				}
				subscribe.patient_other_neuropathy_type.value = "";
				subscribe.patient_myositis_type.value = "";
				subscribe.patient_other_type.value = "";
			}
			if (!subscribe.subscriber[1].checked)
			{
				for (counter = 1; counter < subscribe.patient_family_friend_type.length; counter++)
				{
					subscribe.patient_family_friend_type[counter].checked = false;
				}
				subscribe.patient_family_friend_other_neuropathy_type.value = "";
				subscribe.patient_family_friend_myositis_type.value = "";
				subscribe.patient_family_friend_other_type.value = "";
			}
			if (!subscribe.subscriber[3].checked)
			{
				for (counter = 1; counter < subscribe.healthcare_professional_type.length; counter++)
				{
					subscribe.healthcare_professional_type[counter].checked = false;
				}
				subscribe.healthcare_professional_other_type.value = "";
			}
			return (true);
		}
		
    }
    
alert("Please select a subscription type.");
return (false);
}


function SetEditFormVals() 
{  
	var pnl = document.getElementById("pnlForm");
   if (pnl == null)
        return;
    // Handle Patient Subscriber type values
    if (subscribe.h_stype_patient.value != "") 
    {	
		patient.style.display = 'inline';      
      subscribe.subscriber[0].checked = true;
        
        for (counter = 0; counter < subscribe.patient_type.length; counter++)
        {
	        if (subscribe.h_stype_patient.value.indexOf(subscribe.patient_type[counter].value) != -1)
					subscribe.patient_type[counter].checked = true;
					if (counter == 0)
					{
							patient_pid.style.display = 'inline';
							for (i = 0; i < subscribe.patient_pid_type.length; i++)
								{	
									if (subscribe.h_pidtype_patient.value.indexOf(subscribe.patient_pid_type[i].value) != -1)
										{	
											subscribe.patient_pid_type[i].checked = true;
										}
								 }
							if (subscribe.h_pidtype_patient.value.indexOf("PidOtherType") != -1)
								{	
									newval = subscribe.h_pidtype_patient.value.substring(subscribe.h_pidtype_patient.value.indexOf("PidOtherType|") + 13, subscribe.h_pidtype_patient.value.length);
									if (newval.indexOf(",") == -1)	         
										subscribe.patient_pid_other_type.value = newval.substring(0,newval.length);
									else
										subscribe.patient_pid_other_type.value = newval.substring(0,newval.indexOf(","));	
								}
					}
		}

	    if (subscribe.h_stype_patient.value.indexOf("Neuropathy") != -1) 
	    {
	        newval = subscribe.h_stype_patient.value.substring(subscribe.h_stype_patient.value.indexOf("Neuropathy|") + 11, subscribe.h_stype_patient.value.length);          
	        if (newval.indexOf(",") == -1)	         
	            subscribe.patient_other_neuropathy_type.value = newval.substring(0,newval.length);
	        else
	            subscribe.patient_other_neuropathy_type.value = newval.substring(0,newval.indexOf(","));
	    }
    
        if (subscribe.h_stype_patient.value.indexOf("Myositis") != -1) 
	    {
	        newval = subscribe.h_stype_patient.value.substring(subscribe.h_stype_patient.value.indexOf("Myositis|") + 9, subscribe.h_stype_patient.value.length);          
            if (newval.indexOf(",") == -1)	   
                subscribe.patient_myositis_type.value = newval.substring(0,newval.length);
            else
                subscribe.patient_myositis_type.value = newval.substring(0,newval.indexOf(","));
	    }
         
        if (subscribe.h_stype_patient.value.indexOf("PatientOtherType") != -1) 
	    {	                  
            subscribe.patient_other_type.value = subscribe.h_stype_patient.value.substring(subscribe.h_stype_patient.value.indexOf("PatientOtherType|") + 17, subscribe.h_stype_patient.value.length);
	    }	   	
	    
	    if (subscribe.h_patient_therapy_location.value != "") 
	    {
            
		    for (i = 0; i < subscribe.patient_therapy_location.length; i++)
		    {
			    if (subscribe.h_patient_therapy_location.value.indexOf(subscribe.patient_therapy_location[i].value) != -1) 
			        subscribe.patient_therapy_location[i].checked = true;			    
		    }
		    
		    if (subscribe.h_patient_therapy_location.value.indexOf("Other") != -1) 
		    {
		        newval = subscribe.h_patient_therapy_location.value.substring(subscribe.h_patient_therapy_location.value.indexOf("|") + 1, subscribe.h_patient_therapy_location.value.length);		        
	            subscribe.patient_therapy_location_other.value = newval; 	  
		    }
	    }    
    }

    // Handle Patient Friend/Family Member Subscriber type values
   if (subscribe.h_stype_patient_family_friend.value != "") 
    {
        patient_family_member.style.display = 'inline';      
        subscribe.subscriber[1].checked = true;
        // alert(subscribe.h_stype_patient.value);
        for (counter = 0; counter < subscribe.patient_family_friend_type.length; counter++)
        {
	        if (subscribe.h_stype_patient_family_friend.value.indexOf(subscribe.patient_family_friend_type[counter].value) != -1)
	            subscribe.patient_family_friend_type[counter].checked = true;
           	   if (counter == 0)
						{
							family_friend_pid.style.display = 'inline';
							for (c = 0; c < subscribe.family_friend_pid_type.length; c++)
								{	
 									if (subscribe.h_pidtype_family_friend_pid_type.value.indexOf(subscribe.family_friend_pid_type[c].value) != -1)
										{	
											subscribe.family_friend_pid_type[c].checked = true;
										}
								 }
							if (subscribe.h_pidtype_family_friend_pid_type.value.indexOf("FamilyPidOtherType") != -1)
								{	
									newval = subscribe.h_pidtype_family_friend_pid_type.value.substring(subscribe.h_pidtype_family_friend_pid_type.value.indexOf("FamilyPidOtherType|") + 19, subscribe.h_pidtype_family_friend_pid_type.value.length);
									if (newval.indexOf(",") == -1)	         
										subscribe.family_friend_pid_other_type.value = newval.substring(0,newval.length);
									else
										subscribe.family_friend_pid_other_type.value = newval.substring(0,newval.indexOf(","));	
								}
						}    
	            	    
			}
	    
	    if (subscribe.h_stype_patient_family_friend.value.indexOf("Neuropathy") != -1) 
	    {
	        newval = subscribe.h_stype_patient_family_friend.value.substring(subscribe.h_stype_patient_family_friend.value.indexOf("Neuropathy|") + 11, subscribe.h_stype_patient_family_friend.value.length);          
	        if (newval.indexOf(",") == -1)
	            subscribe.patient_family_friend_other_neuropathy_type.value = newval.substring(0,newval.length);
	        else
	            subscribe.patient_family_friend_other_neuropathy_type.value = newval.substring(0,newval.indexOf(","));
	    }
    
        if (subscribe.h_stype_patient_family_friend.value.indexOf("Myositis") != -1) 
	    {
	        newval = subscribe.h_stype_patient_family_friend.value.substring(subscribe.h_stype_patient_family_friend.value.indexOf("Myositis|") + 9, subscribe.h_stype_patient_family_friend.value.length);          
            
            if (newval.indexOf(",") == -1)
                subscribe.patient_family_friend_myositis_type.value = newval.substring(0,newval.length);
            else
                subscribe.patient_family_friend_myositis_type.value = newval.substring(0,newval.indexOf(","));
					
	    }
         
        if (subscribe.h_stype_patient_family_friend.value.indexOf("PatientFamilyFriendOtherType") != -1) 
	    {	 
	        // The "other" type fields always come at the end so we know this value will always be the last one        
         subscribe.patient_family_friend_other_type.value = subscribe.h_stype_patient_family_friend.value.substring(subscribe.h_stype_patient_family_friend.value.indexOf("PatientFamilyFriendOtherType|") + 29, subscribe.h_stype_patient_family_friend.value.length);
	    }	   	
	    
	    if (subscribe.h_patient_family_friend_therapy_location.value != "") 
	    {
            
		    for (i = 0; i < subscribe.patient_family_friend_therapy_location.length; i++)
		    {
			    if (subscribe.h_patient_family_friend_therapy_location.value.indexOf(subscribe.patient_family_friend_therapy_location[i].value) != -1) 
			        subscribe.patient_family_friend_therapy_location[i].checked = true;			    
		    }
		    
		    if (subscribe.h_patient_family_friend_therapy_location.value.indexOf("Other") != -1) 
		    {
		        // parse and display the actual "other" value
		        newval = subscribe.h_patient_family_friend_therapy_location.value.substring(subscribe.h_patient_family_friend_therapy_location.value.indexOf("|") + 1, subscribe.h_patient_family_friend_therapy_location.value.length);		        
	            subscribe.patient_family_friend_therapy_location_other.value = newval; 	  
		    }
	    }    
    }
    
         // Handle Patient Organization Subscriber type values                                   
    if (subscribe.h_stype_patient_organization.value != "") 
    { 
			pat_organization.style.display = 'inline';
         subscribe.subscriber[2].checked = true;
         subscribe.patient_organization_name.value = subscribe.h_patient_organization_name.value; 
    }

    // Handle Healthcare Professional Subscriber type values                                   
    if (subscribe.h_stype_healthcare_professional.value != "") 
    {
        healthcare_professional.style.display = 'inline';      
        subscribe.subscriber[3].checked = true;
        
        for (counter = 0; counter < subscribe.healthcare_professional_type.length; counter++)
        {
	        if (subscribe.h_stype_healthcare_professional.value.indexOf(subscribe.healthcare_professional_type[counter].value) != -1)
	            subscribe.healthcare_professional_type[counter].checked = true;	    
	    }
	    
	    if (subscribe.h_stype_healthcare_professional.value.indexOf("Other") != -1) 
	    {
	        subscribe.healthcare_professional_type[subscribe.healthcare_professional_type.length - 1].checked
	        subscribe.healthcare_professional_other_type.value = subscribe.h_stype_healthcare_professional.value.substring(subscribe.h_stype_healthcare_professional.value.indexOf("|") + 1, subscribe.h_stype_healthcare_professional.value.length);
	    }
	    
	    /*
	   	if (subscribe.h_quantity.value != "") 
	    {
	        subscribe.txtQuantity.value = h_quantity.value;
	    } 
	    */
	    
    }
            
    // Handle Manufacturer Subscriber type values                                   
    if (subscribe.h_stype_manufacturer.value != "") 
    {           
        subscribe.subscriber[4].checked = true;        
    }
    
    // Handle Other Subscriber type values                                   
    if (subscribe.h_stype_other.value != "") 
    {           
        subscribe.subscriber[5].checked = true; 
        subscribe.other.value = subscribe.h_stype_other.value;     
    }    
    
}