var pu=true;
var spouse = 0;
var children = 0;
var d = new Date();

/**
 * mboxNVX
 *
 **/

function mboxNVX()
{
	this.deleteContent = function(elemID)
	{
		var mboxNVXRemover = new mboxNVXRemove(elemID);
		mboxNVXRemover.removeElem();
	}
	this.replaceContent = function(targetID, newContentID) {
		var mboxNVXReplacer = new mboxNVXReplace(targetID, newContentID);
		mboxNVXReplacer.replaceElem();
	}
	this.info = function() {
		alert("Norvax Mbox JavaScript Helper\n (c) 2009 Norvax, Inc.");
	}
}
function mboxNVXReplace(targetID, newContentID) {
	var targetElem = targetID;
	var targetElemStyle = addCSSRule('#'+targetElem);
	targetElemStyle.style.display='none';
	var newContentElem = newContentID;
	var replaceElemTimer;
	function replaceElems() {
		if(document.getElementById(targetElem)&&document.getElementById(newContentElem)){
			document.getElementById(targetElem).innerHTML = document.getElementById(newContentElem).innerHTML;
			document.getElementById(targetElem).style.display="block";
			clearInterval(replaceElemTimer);
		}
	}
	this.replaceElem = function() {
		replaceElemTimer = setInterval(replaceElems, 20);
	}
}

function getCSSRule(ruleName, deleteFlag) {               // Return requested style obejct
   ruleName=ruleName.toLowerCase();                       // Convert test string to lower case.
   if (document.styleSheets) {                            // If browser can play with stylesheets
      for (var i=0; i<document.styleSheets.length; i++) { // For each stylesheet
         var styleSheet=document.styleSheets[i];          // Get the current Stylesheet
         var ii=0;                                        // Initialize subCounter.
         var cssRule=false;                               // Initialize cssRule. 
         do {                                             // For each rule in stylesheet
            if (styleSheet.cssRules) {                    // Browser uses cssRules?
               cssRule = styleSheet.cssRules[ii];         // Yes --Mozilla Style
            } else {                                      // Browser usses rules?
               cssRule = styleSheet.rules[ii];            // Yes IE style. 
            }                                             // End IE check.
            if (cssRule)  {                               // If we found a rule...
               if (cssRule.selectorText.toLowerCase()==ruleName) { //  match ruleName?
                  if (deleteFlag=='delete') {             // Yes.  Are we deleteing?
                     if (styleSheet.cssRules) {           // Yes, deleting...
                        styleSheet.deleteRule(ii);        // Delete rule, Moz Style
                     } else {                             // Still deleting.
                        styleSheet.removeRule(ii);        // Delete rule IE style.
                     }                                    // End IE check.
                     return true;                         // return true, class deleted.
                  } else {                                // found and not deleting.
                     return cssRule;                      // return the style object.
                  }                                       // End delete Check
               }                                          // End found rule name
            }                                             // end found cssRule
            ii++;                                         // Increment sub-counter
         } while (cssRule)                                // end While loop
      }                                                   // end For loop
   }                                                      // end styleSheet ability check
   return false;                                          // we found NOTHING!
}                                                         // end getCSSRule 

function killCSSRule(ruleName) {                          // Delete a CSS rule   
   return getCSSRule(ruleName,'delete');                  // just call getCSSRule w/delete flag.
}                                                         // end killCSSRule

function addCSSRule(ruleName) {                           // Create a new css rule
   if (document.styleSheets) {                            // Can browser do styleSheets?
      if (!getCSSRule(ruleName)) {                        // if rule doesn't exist...
         if (document.styleSheets[0].addRule) {           // Browser is IE?
            document.styleSheets[0].addRule(ruleName, null,0);      // Yes, add IE style
         } else {                                         // Browser is IE?
            document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style.
         }                                                // End browser check
      }                                                   // End already exist check.
   }                                                      // End browser ability check.
   return getCSSRule(ruleName);                           // return rule we just created.
} 
function mboxNVXRemove(elemID) {
	var deleteElem = elemID;
	var removeElemTimer;
	function deleteElems() {
		if(document.getElementById(deleteElem)) {
			document.getElementById(deleteElem).style.display = "none";
			clearInterval(removeElemTimer);
		}
	}
	this.removeElem = function() {
		removeElemTimer = setInterval(deleteElems, 20);
	}
}
var mboxNVXOffer = new mboxNVX();





/**
 * BROWSER CHECK
 * 
 * Used to determine if the page should use browser specific hacks
 * @returns MSIE browser version 
 **/

var Browser = {
	Version: function() {
		var version = 999;
		if (navigator.appVersion.indexOf("MSIE") != -1) {
			version = parseFloat(navigator.appVersion.split("MSIE")[1]);
		}
		return version;
	}
}
/**
 * HIDE SELECT ELEMENTS
 *
 * Used to hide the select elements to prevent SELECT element bleedthrough in Internet Explorer 6 and lower
 **/
function hideSelectElement() {	
	var selectIframe = document.createElement("iframe");
	selectIframe.id = "select-iframe";
	selectIframe.style.position = "absolute";
	selectIframe.style.width = document.getElementById("address_1_state").offsetWidth + "px";
	selectIframe.style.height = document.getElementById("address_1_state").offsetHeight +  "px";
	selectIframe.filter = "alpha(opacity=0)";
	selectIframe.style.zIndex = "4";
	selectIframe.style.display = "none";
	document.body.appendChild(selectIframe);
}
if(Browser.Version()<7) {
	window.attachEvent('onload', hideSelectElement);
}
var posx = 0;
var posy = 0;


// Create popups
function popup(s, event) {
	closeOthers(s);
	var e = event || window.event;
	var pos = getRelativeCoordinates(event, document.getElementById(s));
	document.getElementById(s).style.left=(posx*1+10)+"px";
	document.getElementById(s).style.top=(posy*1+10)+"px";
	document.getElementById(s).style.display='';
	if((Browser.Version()<7)&&(s == 'contact-info')){
		document.getElementById("select-iframe").style.left = getAbsolutePosition(document.getElementById("address_1_state")).x + "px";
		document.getElementById("select-iframe").style.top = getAbsolutePosition(document.getElementById("address_1_state")).y + "px";
		document.getElementById("select-iframe").style.display = 'block';
	}
}

// Hide Divs or popups
var hideDiv;
function hide(s) {
	hideDiv = s;
	window.setTimeout('hidePopup()',1300);
}
// hide popUps
function hidePopup() {
	document.getElementById(hideDiv).style.display='none';
}
// close other 
function closeOthers(s) {
	if(s!="health-info") document.getElementById('health-info').style.display='none';
	if(s!="health-conditions") document.getElementById('health-conditions').style.display='none';
	if(s!="contact-info") { document.getElementById('contact-info').style.display='none'; if(document.getElementById('select-iframe')) state(); }
	if(s!="security-info") document.getElementById('security-info').style.display='none';
}

/**
 * Retrieve the absolute coordinates of an element.
 *
 * @param element
 *   A DOM element.
 * @return
 *   A hash containing keys 'x' and 'y'.
 */
function getAbsolutePosition(element) {
  var r = { x: element.offsetLeft, y: element.offsetTop };
  if (element.offsetParent) {
    var tmp = getAbsolutePosition(element.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};

/**
 * Retrieve the coordinates of the given event relative to the center
 * of the widget.
 *
 * @param event
 *   A mouse-related DOM event.
 * @param reference
 *   A DOM element whose position we want to transform the mouse coordinates to.
 * @return
 *    A hash containing keys 'x' and 'y'.
 */
function getRelativeCoordinates(event, reference) {
  var x, y;
  event = event || window.event;
  var el = event.target || event.srcElement;

  if (!window.opera && typeof event.offsetX != 'undefined') {
    // Use offset coordinates and find common offsetParent
    var pos = { x: event.offsetX, y: event.offsetY };

    // Send the coordinates upwards through the offsetParent chain.
    var e = el;
    while (e) {
      e.mouseX = pos.x;
      e.mouseY = pos.y;
      pos.x += e.offsetLeft;
      pos.y += e.offsetTop;
      e = e.offsetParent;
    }

    // Look for the coordinates starting from the reference element.
    var e = reference;
    var offset = { x: 0, y: 0 }
    while (e) {
      if (typeof e.mouseX != 'undefined') {
        x = e.mouseX - offset.x;
        y = e.mouseY - offset.y;
        break;
      }
      offset.x += e.offsetLeft;
      offset.y += e.offsetTop;
      e = e.offsetParent;
    }

    // Reset stored coordinates
    e = el;
    while (e) {
      e.mouseX = undefined;
      e.mouseY = undefined;
      e = e.offsetParent;
    }
  }
  else {
    // Use absolute coordinates
    var pos = getAbsolutePosition(reference);
    x = event.pageX  - pos.x;
    y = event.pageY - pos.y;
  }
  // Subtract distance to middle
  return { x: x, y: y };
}

//hide state
function hideSelect() {
	
}
//show state
function showSelect() {
	window.setTimeout('state()', 1300);
}
//display states
function state() {
	if(document.getElementById("select-iframe")) {
		document.getElementById("select-iframe").style.display = 'none';
	}
}




// Health Profile Begin
function HealthProfile(form){

		//Gender must be selected for insured 1
	if(!form.insured_1_gender[0].checked && !form.insured_1_gender[1].checked){
		alert("Please select your gender.");
		form.insured_1_gender[0].focus();
		pu=true;
		return false;
	}
	
	//Date of birth month must be a valid month
	if(form.insured_1_dobMM.value=="" || !isIntegerHealthProfiles(form.insured_1_dobMM.value) || isNaN(form.insured_1_dobMM.value) || parseInt((form.insured_1_dobMM.value*1))<1 || parseInt((form.insured_1_dobMM.value*1))>12 || hasSpaceHealthprofile(form.insured_1_dobMM.value)) {
		alert('Your date of birth appears to have been entered incorrectly. Please re-enter your date of birth, using the format "Month, Day, Year."\nExample: 8/20/1970');
		form.insured_1_dobMM.value="";
		form.insured_1_dobMM.focus();
		pu=true;
		return false;
	}

	//Date of birth day must be a valid day
	if(form.insured_1_dobDD.value=="" || !isIntegerHealthProfiles(form.insured_1_dobDD.value)  || isNaN(form.insured_1_dobDD.value) || parseInt(form.insured_1_dobDD.value*1)<1 || parseInt(form.insured_1_dobDD.value*1)>31 || hasSpaceHealthprofile(form.insured_1_dobDD.value)) {
		alert('Your date of birth appears to have been entered incorrectly. Please re-enter your date of birth, using the format "Month, Day, Year."\nExample: 8/20/1970');
		form.insured_1_dobDD.value="";
		form.insured_1_dobDD.focus();
		pu=true;
		return false;
	}

	//Date of birth year must be a valid year
	if(form.insured_1_dobYYYY.value==""|| !isIntegerHealthProfiles(form.insured_1_dobYYYY.value)  || isNaN(form.insured_1_dobYYYY.value) || parseInt(form.insured_1_dobYYYY.value)<1886 || parseInt(form.insured_1_dobYYYY.value)>d.getFullYear() || hasSpaceHealthprofile(form.insured_1_dobYYYY.value)) {
		alert('Your date of birth appears to have been entered incorrectly. Please re-enter your date of birth, using the format "Month, Day, Year."\nExample: 8/20/1970');
		form.insured_1_dobYYYY.value="";
		form.insured_1_dobYYYY.focus();
		pu=true;
		return false;
	}

	//Insured 1 weight has to be a number greated than 1	
	if(form.insured_1_heightFT.value=="" || !isIntegerHealthProfiles(form.insured_1_heightFT.value) || isNaN(form.insured_1_heightFT.value)) {
		alert("Please select your height in feet and inches.");
		form.insured_1_heightFT.value="";
		form.insured_1_heightFT.focus();
		pu=true;
		return false;
	}

	//Insured 1 height in inches must be selected
	if(form.insured_1_heightIN.value=="" || isNaN(form.insured_1_heightIN.value) || !isIntegerHealthProfiles(form.insured_1_heightIN.value) || parseInt(form.insured_1_heightIN.value)>11) {		
			alert("Please select your height in feet and inches.");	
			form.insured_1_heightIN.value="";
			form.insured_1_heightIN.focus();
			pu=true;
			return false;		
	}
		
	//Insured 1 weight has to be a number greated than 1
	if(form.insured_1_weight.value=="" || isNaN(form.insured_1_weight.value) || parseInt(form.insured_1_weight.value)<1) {
			alert("Please enter your weight in pounds.\nExample: 200");
			form.insured_1_weight.value="";
			form.insured_1_weight.focus();
			pu=true;
			return false;
		}
		

	//Insured 1 BMI must be between 10 and 100
	if(bmiHealthProfile(form.insured_1_weight.value,form.insured_1_heightFT.value,form.insured_1_heightIN.value)) {
		alert("Your height and weight appears to have been entered incorrectly. Please re-enter your height and weight.");
		form.insured_1_weight.value="";
		form.insured_1_weight.focus();
		pu=true;
		return false;
	}
	
// Check if have conditions was selected
	if(form.insured_1_health_conditions[0].checked)	{
		var conditionDetail=form.insured_1_health_conditions_detail.value;
		
		//If have conditions was selected and no conditions were selected
		if(trimHealthProfiles(conditionDetail).length<3 || conditionDetail == "None listed") {
			alert("Please specify  pre-existing health conditions. If you have no pre-existing conditions, please select \"No\".");
			form.insured_1_health_conditions[0].focus();
			pu=true;
			return false;
		}


	}
	else
		form.insured_1_health_conditions_detail.value="None listed";
		
	return true;
}

//Checks if BMI is valid, returns true if BMI is not valid
function bmiHealthProfile(w,hFT,hIN){
	//calculate height in inches
	var h = ((hFT * 12) + (hIN * 1));
	//calculate BMI
	var bmi = 703 * (w/(h*h));
	//Pass if BMI is not valid
	if(bmi > 100 || bmi < 10)
		return true;
	return false;
}
function hasSpaceHealthprofile(s) {
	for(var i=0;i<s.length;i++)
		if(s.charAt(i)==" ")
			return true;
	return false;
}

function isIntegerHealthProfiles(s){
	return (s.toString().search(/^[0-9]+$/)==0);
}

function noNum(s){
	for(var i = 0; i < s.length; i++)
		if(!isNaN(s.charAt(i)) && s.charAt(i)!=" ")
			return false;
	return true;
}
function showHidden(id, value) {
	if(value=="yes")
		document.getElementById(id).style.display='';
	else
		document.getElementById(id).style.display='none';
}
function displayCommentBox(commentId, val) {
	if(val == "yes") {
		eval(getDocObj(commentId)).style.display="";
	}
	
	if(val == "no") {
		eval(getDocObj(commentId)).style.display="none";
	}
}
function setConditions() {
	document.getElementById("insured_1_health_conditions_detail").value=(((document.getElementById("aids").checked)?"HIV/AIDS / ":"")+""+((document.getElementById("diabetes").checked)?"Diabetes / ":"")+""+((document.getElementById("cancer").checked)?"Cancer / ":"")+""+((document.getElementById("heart-attack").checked)?"Heart Attack / ":"")+""+((document.getElementById("high-blood-pressure").checked)?"High Blood Pressure / ":"")+""+((document.getElementById("pregnant").checked)?"Pregnant / ":"")+""+((document.getElementById("stroke").checked)?"Stroke / ":"")+""+((document.getElementById("depression").checked)?"Depression / ":"")+""+((document.getElementById("other-illness").checked)?"Other major illness not listed. / ":""));
}

function unSetConditions() {
	document.getElementById("aids").checked=false;
	document.getElementById("diabetes").checked=false;
	document.getElementById("cancer").checked=false;
	document.getElementById("heart-attack").checked=false;
	document.getElementById("high-blood-pressure").checked=false;
	document.getElementById("pregnant").checked=false;
	document.getElementById("stroke").checked=false;
	document.getElementById("depression").checked=false;
	document.getElementById("other-illness").checked=false;
}
//trim left and right spaces
function ltrimHealthProfiles(s){return s.replace(/^\s*/,"");}
function rtrimHealthProfiles(s){return s.replace(/\s*$/,"");}
function trimHealthProfiles(s){return rtrimHealthProfiles(ltrimHealthProfiles(s));}
// End Health profile



// Spouse Profile Begin 
add_spouse = new Image();
add_spouse.src = "/images/add-spouse.jpg";
add_spouse_gray = new Image();
add_spouse_gray.src = "/images/add-spouse-gray.jpg";

//add Spouse function
function Spouse(form){
	//If Spouse Selected
	if(spouse==1){

		//spouse gender
		if(!form.insured_2_gender[0].checked && !form.insured_2_gender[1].checked){
			alert("Please enter your spouse's gender.");
			form.insured_2_gender[0].focus();
			pu=true;
			return false;
		}
				
		//insured 2 date of birth month must be a valid month
		if(form.insured_2_dobMM.value=="" || !isIntegerSpouse(form.insured_2_dobMM.value) || isNaN(form.insured_2_dobMM.value) || parseInt(form.insured_2_dobMM.value*1)<1 || parseInt(form.insured_2_dobMM.value*1)>12 || hasSpaceSpouse(form.insured_2_dobMM.value)) {
			alert("Your spouse's date of birth appears to have been entered incorrectly. Please re-enter your spouse's date of birth, using the format \"Month, Day, Year.\"\nExample: 8/21/1970");
			form.insured_2_dobMM.value="";
			form.insured_2_dobMM.focus();
			pu=true;
			return false;
		}
		
		//insured 2 date of birth day must be a valid day
		if(form.insured_2_dobDD.value=="" || !isIntegerSpouse(form.insured_2_dobDD.value) || isNaN(form.insured_2_dobDD.value) || parseInt(form.insured_2_dobDD.value*1)<1 || parseInt(form.insured_2_dobDD.value*1)>31 || hasSpaceSpouse(form.insured_2_dobDD.value)) {
			alert("Your spouse's date of birth appears to have been entered incorrectly. Please re-enter your spouse\'s date of birth, using the format \"Month, Day, Year.\"\nExample: 8/21/1970");
			form.insured_2_dobDD.value="";			
			form.insured_2_dobDD.focus();
			pu=true;
			return false;
		}
		
		//insured 2 date of birth day must be a valid year
		if(form.insured_2_dobYYYY.value=="" || !isIntegerSpouse(form.insured_2_dobYYYY.value) || isNaN(form.insured_2_dobYYYY.value) || parseInt(form.insured_2_dobYYYY.value)<1886 || parseInt(form.insured_2_dobYYYY.value)>d.getFullYear() ||  hasSpaceSpouse(form.insured_2_dobYYYY.value)) {
			alert("Your spouse's date of birth appears to have been entered incorrectly. Please re-enter your spouse's date of birth, using the format \"Month, Day, Year.\"\nExample: 8/21/1970");
			form.insured_2_dobYYYY.value="";			
			form.insured_2_dobYYYY.focus();
			pu=true;
			return false;
		}
		
		//insured 2 height in feet must be selected
		if(form.insured_2_heightFT.value=="" || !isIntegerSpouse(form.insured_2_heightFT.value) || isNaN(form.insured_2_heightFT.value)) {
			alert("Please select your spouse's height in feet and inches.");
			form.insured_2_heightFT.value="";			
			form.insured_2_heightFT.focus();
			pu=true;
			return false;
		}
		
		//insured 2 height in inches must be selected
		if(form.insured_2_heightIN.value=="" || !isIntegerSpouse(form.insured_2_heightIN.value) || isNaN(form.insured_2_heightIN.value) || parseInt(form.insured_2_heightIN.value)>11) {
			alert("Please select your spouse's height in feet and inches.");
			form.insured_2_heightIN.value="";			
			form.insured_2_heightIN.focus();
			pu=true;
			return false;
		}
		
		//insured 2 weight must be a number greater then 1
		if(form.insured_2_weight.value=="" || !isIntegerSpouse(form.insured_2_weight.value) || isNaN(form.insured_2_weight.value) || parseInt(form.insured_2_weight.value)<1) {
			alert("Please enter your spouse's weight in pounds.");
			form.insured_2_weight.value="";			
			form.insured_2_weight.focus();
			pu=true;
			return false;
		}
		
		//insured 2 BMI must be between 10 and 100
		if(bmiSpouse(form.insured_2_weight.value,form.insured_2_heightFT.value,form.insured_2_heightIN.value)) {
			alert("Your spouse's height and weight appears to have been entered incorrectly. Please re-enter your spouse's height and weight.");
			form.insured_2_weight.value="";
			form.insured_2_weight.focus();
			pu=true;
			return false;
		}
	}
	return true;
}
//Checks if BMI is valid, returns true if BMI is not valid
function bmiSpouse(w,hFT,hIN){
	//calculate height in inches
	var h = ((hFT * 12) + (hIN * 1));
	//calculate BMI
	var bmi = 703 * (w/(h*h));
	//Pass if BMI is not valid
	if(bmi > 100 || bmi < 10)
		return true;
	return false;
}
//check for Space 
function hasSpaceSpouse(s) {
	for(var i=0;i<s.length;i++)
		if(s.charAt(i)==" ")
			return true;
	return false;
}

// Check for Integer Numbers
function isIntegerSpouse(s){
	return (s.toString().search(/^[0-9]+$/)==0);
}
// Add Spouse
function addSpouse() {
	if(spouse==0) {
		document.getElementById('spouse').style.display='block';
		spouse = 1;
		document.images['add-spouse'].src=add_spouse_gray.src;
	}
}

// Delete Spouse
function deleteSpouse() {
	document.getElementById('spouse').style.display='none';
	spouse = 0;
	document.images['add-spouse'].src=add_spouse.src;
	
	//Reset Spouse Values
	document.getElementById('insured_2_gender_male').checked=false;
	document.getElementById('insured_2_gender_female').checked=false;
	document.getElementById('insured_2_dobMM').value='';
	document.getElementById('insured_2_dobDD').value='';
	document.getElementById('insured_2_dobYYYY').value='';
	document.getElementById('insured_2_heightFT').value='';
	document.getElementById('insured_2_heightIN').value='';
	document.getElementById('insured_2_weight').value='';
	document.getElementById('insured_2_smoker_yes').checked=false;
	document.getElementById('insured_2_smoker_no').checked=false;
}

// Spouse Profile End


// Child Profile Begin
add_child = new Image();
add_child.src = "/images/add-child.jpg";
add_child_gray = new Image();
add_child_gray.src = "/images/add-child-gray.jpg";

// add children
function Children(form){
	
	for(i=3;i<=(children*1+2);i++) {
		//gender must be selected
		if(eval(getDocObj("insured_"+i+"_gender_male")).checked==false && eval(getDocObj("insured_"+i+"_gender_female")).checked==false) {
			alert("Please select your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child\'s gender.");
			;
			eval(getDocObj("insured_"+i+"_gender_male")).focus();
			pu=true;
			return false;
		}
		//date of birth month must be a valid month
		if(eval(getDocObj("insured_"+i+"_dobMM")).value==""|| !isIntegerChild(eval(getDocObj("insured_"+i+"_dobMM")).value) ||isNaN(eval(getDocObj("insured_"+i+"_dobMM")).value*1) || parseInt(eval(getDocObj("insured_"+i+"_dobMM")).value*1)<1 || parseInt(eval(getDocObj("insured_"+i+"_dobMM")).value*1)>12 || hasSpaceChild(eval(getDocObj("insured_"+i+"_dobMM")).value)) {
			alert("Your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child\'s date of birth appears to have been entered incorrectly. Please enter the date numerically, using the format \"Month, Day, Year.\"\nExample: 8/20/06");
			eval(getDocObj("insured_"+i+"_dobMM")).value="";
			eval(getDocObj("insured_"+i+"_dobMM")).focus();
			pu=true;
			return false;
		}
		//date of birth day must be a valid day
		if(eval(getDocObj("insured_"+i+"_dobDD")).value=="" || !isIntegerChild(eval(getDocObj("insured_"+i+"_dobDD")).value) ||isNaN(eval(getDocObj("insured_"+i+"_dobDD")).value) || parseInt(eval(getDocObj("insured_"+i+"_dobDD")).value*1)<1 || parseInt(eval(getDocObj("insured_"+i+"_dobDD")).value*1)>31 || hasSpaceChild(eval(getDocObj("insured_"+i+"_dobDD")).value)) {
			alert("Your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child\'s date of birth appears to have been entered incorrectly. Please enter the date numerically, using the format \"Month, Day, Year.\"\nExample: 8/20/06");
			eval(getDocObj("insured_"+i+"_dobDD")).value="";			
			eval(getDocObj("insured_"+i+"_dobDD")).focus();
			pu=true;
			return false;
		}
		//date of birth year must be a valid year
		if(eval(getDocObj("insured_"+i+"_dobYYYY")).value=="" || !isIntegerChild(eval(getDocObj("insured_"+i+"_dobYYYY")).value) ||isNaN(eval(getDocObj("insured_"+i+"_dobYYYY")).value) || parseInt(eval(getDocObj("insured_"+i+"_dobYYYY")).value)>d.getFullYear() || parseInt(eval(getDocObj("insured_"+i+"_dobYYYY")).value)<1886 || hasSpaceChild(eval(getDocObj("insured_"+i+"_dobYYYY")).value)) {
			alert("Your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's date of birth appears to have been entered incorrectly. Please enter the date numerically, using the format \"Month, Day, Year.\"\nExample: 8/20/06");
			eval(getDocObj("insured_"+i+"_dobYYYY")).value="";			
			eval(getDocObj("insured_"+i+"_dobYYYY")).focus();
			pu=true;
			return false;
		}
		//height in feet must be selected
		if(eval(getDocObj("insured_"+i+"_heightFT")).value=="" || !isIntegerChild(eval(getDocObj("insured_"+i+"_heightFT")).value)|| isNaN(eval(getDocObj("insured_"+i+"_heightFT")).value)) {
			alert("Please select your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's height in feet and inches.\nIf your child is an infant, please select '11' in the inches field and leave feet at 0.");
			eval(getDocObj("insured_"+i+"_heightFT")).value="";			
			eval(getDocObj("insured_"+i+"_heightFT")).focus();
			pu=true;
			return false;
		}
		//height in inches must be selected
		if(eval(getDocObj("insured_"+i+"_heightIN")).value=="" || !isIntegerChild(eval(getDocObj("insured_"+i+"_heightIN")).value) || isNaN(eval(getDocObj("insured_"+i+"_heightIN")).value) || parseInt(eval(getDocObj("insured_"+i+"_heightIN")).value)>11) {
			alert("Please select your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's height in feet and inches.\nIf your child is an infant, please select '11' in the inches field and leave feet at 0.");
			eval(getDocObj("insured_"+i+"_heightIN")).value="";			
			eval(getDocObj("insured_"+i+"_heightIN")).focus();
			pu=true;
			return false;
		}
		//weight must be a number greater than 1
		if(eval(getDocObj("insured_"+i+"_weight")).value=="" || !isIntegerChild(eval(getDocObj("insured_"+i+"_weight")).value) ||isNaN(eval(getDocObj("insured_"+i+"_weight")).value) || parseInt(eval(getDocObj("insured_"+i+"_weight")).value)<1) {
			alert("Please enter your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's weight in pounds.");
			eval(getDocObj("insured_"+i+"_weight")).value="";			
			eval(getDocObj("insured_"+i+"_weight")).focus();
			pu=true;
			return false;
		}
		//BMI must be between 10 and 100
		if(bmi(eval(getDocObj("insured_"+i+"_weight")).value,eval(getDocObj("insured_"+i+"_heightFT")).value,eval(getDocObj("insured_"+i+"_heightIN")).value)) {
			alert("Your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's height and weight appears to have been entered incorrectly. Please re-enter your "+(i-2)+((i==3)?"st":(i==4)?"nd":(i==5)?"rd":(i==6||i==7)?"th":"th")+" child's height and weight.");
			eval(getDocObj("insured_"+i+"_weight")).value="";			
			eval(getDocObj("insured_"+i+"_weight")).focus();
			pu=true;
			return false;
		}
	}
	return true;
}
// Get the input Name or Id
function getDocObj(elem,parent) {
	if(document.layers) {
		if(parent) {
			return "document."+parent+".document."+elem;
		} else {
			return "document."+elem;
		}
	} else if(document.all) {
		return "document.all."+ elem;
	} else if(document.getElementById) {
		return "document.getElementById('"+elem+"')";
	}
}


// Fill DropDown
function fillDropdown(id, val) {
	for(var i=0; i<parseInt(eval(getDocObj(id)).options.length)-1; i++) {
		if(eval(getDocObj(id)).options[i].value==val) {
			eval(getDocObj(id)).options[i].selected=true;
			break;
		}
	}
}
// Add Child
function addChild() {
	if(children<6) {
		children++;
		document.getElementById('child'+children).style.display='block';
		if(children==6)
			document.images['add-child'].src=add_child_gray.src;
	}
}

// Delete Child
function deleteChild(x) {
	for(i=(x+2);i<(children+2);i++) {
		document.getElementById('insured_'+i+'_gender_male').checked=document.getElementById('insured_'+(i*1+1)+'_gender_male').checked;
		document.getElementById('insured_'+i+'_gender_female').checked=document.getElementById('insured_'+(i*1+1)+'_gender_female').checked;
		document.getElementById('insured_'+i+'_dobMM').value=document.getElementById('insured_'+(i*1+1)+'_dobMM').value;
		document.getElementById('insured_'+i+'_dobDD').value=document.getElementById('insured_'+(i*1+1)+'_dobDD').value;
		document.getElementById('insured_'+i+'_dobYYYY').value=document.getElementById('insured_'+(i*1+1)+'_dobYYYY').value;
		document.getElementById('insured_'+i+'_heightFT').value=document.getElementById('insured_'+(i*1+1)+'_heightFT').value;
		document.getElementById('insured_'+i+'_heightIN').value=document.getElementById('insured_'+(i*1+1)+'_heightIN').value;
		document.getElementById('insured_'+i+'_weight').value=document.getElementById('insured_'+(i*1+1)+'_weight').value;
	}
	
	document.getElementById('child'+children).style.display='none';
	
	document.getElementById('insured_'+(children*1+2)+'_gender_male').checked=false;
	document.getElementById('insured_'+(children*1+2)+'_gender_female').checked=false;
	document.getElementById('insured_'+(children*1+2)+'_dobMM').value='';
	document.getElementById('insured_'+(children*1+2)+'_dobDD').value='';
	document.getElementById('insured_'+(children*1+2)+'_dobYYYY').value='';
	document.getElementById('insured_'+(children*1+2)+'_heightFT').value='';
	document.getElementById('insured_'+(children*1+2)+'_heightIN').value='';
	document.getElementById('insured_'+(children*1+2)+'_weight').value='';
	
	if(children==6)
		document.images['add-child'].src=add_child.src;
	
	children--;
	
	document.getElementById('body').style.height="0px";
}

//Change Child
function changeChildren(value,form) {
	for(var i=8;i>parseInt(value)+2;i--) {
		fillDropdown("insured_"+i+"_gender","");
		fillDropdown("insured_"+i+"_heightFT","");
		fillDropdown("insured_"+i+"_heightIN","");
		eval(getDocObj("insured_"+i+"_dobMM")).value="";
		eval(getDocObj("insured_"+i+"_dobDD")).value="";
		eval(getDocObj("insured_"+i+"_dobYYYY")).value="";
		eval(getDocObj("insured_"+i+"_weight")).value="";
		eval(getDocObj("insured_"+i+"_smoker")).checked=false;
	}

	if(value==1) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="none";
		eval(getDocObj("child_option2")).style.display="none";
		eval(getDocObj("child_option3")).style.display="none";
		eval(getDocObj("child_option4")).style.display="none";
		eval(getDocObj("child_option5")).style.display="none";
	} else if(value==2) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="";
		eval(getDocObj("child_option2")).style.display="none";
		eval(getDocObj("child_option3")).style.display="none";
		eval(getDocObj("child_option4")).style.display="none";
		eval(getDocObj("child_option5")).style.display="none";
	} else if(value==3) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="";
		eval(getDocObj("child_option2")).style.display="";
		eval(getDocObj("child_option3")).style.display="none";
		eval(getDocObj("child_option4")).style.display="none";
		eval(getDocObj("child_option5")).style.display="none";
	} else if(value==4) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="";
		eval(getDocObj("child_option2")).style.display="";
		eval(getDocObj("child_option3")).style.display="";
		eval(getDocObj("child_option4")).style.display="none";
		eval(getDocObj("child_option5")).style.display="none";
	} else if(value==5) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="";
		eval(getDocObj("child_option2")).style.display="";
		eval(getDocObj("child_option3")).style.display="";
		eval(getDocObj("child_option4")).style.display="";
		eval(getDocObj("child_option5")).style.display="none";
	} else if(value==6) {
		eval(getDocObj("child_option")).style.display="";
		eval(getDocObj("child_option1")).style.display="";
		eval(getDocObj("child_option2")).style.display="";
		eval(getDocObj("child_option3")).style.display="";
		eval(getDocObj("child_option4")).style.display="";
		eval(getDocObj("child_option5")).style.display="";
	} else {
		eval(getDocObj("child_option")).style.display="none";
		eval(getDocObj("child_option1")).style.display="none";
		eval(getDocObj("child_option2")).style.display="none";
		eval(getDocObj("child_option3")).style.display="none";
		eval(getDocObj("child_option4")).style.display="none";
		eval(getDocObj("child_option5")).style.display="none";
	}
}
// Checking for No Numbers
function noNumChild(s){
	for(var i = 0; i < s.length; i++)
		if(!isNaN(s.charAt(i)) && s.charAt(i)!=" ")
			return false;
	return true;
}

// Checking for Integer Numbers
function isIntegerChild(s){
	return (s.toString().search(/^[0-9]+$/)==0);
}

//Checks if BMI is valid, returns true if BMI is not valid
function bmiChild(w,hFT,hIN){
	//calculate height in inches
	var h = ((hFT * 12) + (hIN * 1));
	//calculate BMI
	var bmi = 703 * (w/(h*h));
	//Pass if BMI is not valid
	if(bmi > 100 || bmi < 10)
		return true;
	return false;
}

//check for Space 
function hasSpaceChild(s) {
	for(var i=0;i<s.length;i++)
		if(s.charAt(i)==" ")
			return true;
	return false;
}

// End Child Profile

// About You Profile Form Begin
function AboutYou(form){
	
	//First name cannot be blank
	if(form.first_name.value=="") {
		alert("Please enter your first name.");
		form.first_name.focus();
		pu=true;
		return false;
	}
	//First name cannot contain a number
	if(!noNum(form.first_name.value) || isInteger(form.first_name.value) || !badChars(form.first_name.value)) {
		alert("Your first name appears to have been entered incorrectly. Please re-enter your first name.");
		form.first_name.focus();
		return false;
	}
	//First name cannot be blank
	if(form.last_name.value.length < 2 || form.last_name.value=="") {
		alert("Please enter your last name.");
		form.last_name.focus();
		pu=true;
		return false;
	}
	//First name cannot contain a number
	if(!noNum(form.last_name.value) || !badChars(form.last_name.value) || isInteger(form.last_name.value)) {
		alert("Your last name appears to have been entered incorrectly. Please re-enter your last name.");
		form.last_name.focus();
		pu=true;
		return false;
	}	
	//Street address must contain at least 1 letter and 1 number
	if(form.address_1_street1.value=="" || !validAddress(form.address_1_street1.value)  || !badChars(form.address_1_street1.value)) {
		alert("Your address appears to have been entered incorrectly. Please re-enter your address, including your street name and number.");
		form.address_1_street1.focus();
		pu=true;
		return false;
	}
	//City cannot be blank
	if(form.address_1_city.value=="") {
		alert("Please enter the name of your city or town.");
		form.address_1_city.focus();
		pu=true;
		return false;
	}
	//City cannot contain a number
	if(!noNum(form.address_1_city.value) || isInteger(form.address_1_city.value) || !badChars(form.address_1_city.value)) {
		alert("The name of your city appears to have been entered incorrectly. Please re-enter the name of your city or town.");
		form.address_1_city.focus();
		pu=true;
		return false;
	}		
	//State must be selected
	if(form.address_1_state.value=="") {
		alert("Please select the state you live in.");
		form.address_1_state.focus();
		pu=true;
		return false;
	}
	//Zip must be 5 numbers
	if(form.address_1_zip.value=="" || !isInteger(form.address_1_zip.value) || isNaN(form.address_1_zip.value) || form.address_1_zip.value.length != 5) {
		alert("Your Zip code appears to have been entered incorrectly. Please re-enter your Zip code.");
		form.address_1_zip.focus();
		pu=true;
		return false;
	}
	
	// Check Phone number -- 1st text box --
	if(form.phone1_1.value.length<3 || isNaN(form.phone1_1.value) || !isInteger(form.phone1_1.value)){
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");
		document.getElementById('phone1_1').focus();
		pu=true;
		return false;	
	}
	
	// Check phone number -- 2nd textbox --
	if(form.phone1_2.value.length<3 || isNaN(form.phone1_2.value) || !isInteger(form.phone1_2.value)){
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");				
		document.getElementById('phone1_2').focus();
		pu=true;
		return false;	
	}
	
	//check phone number --3rd text box--
	if(form.phone1_3.value.length<4 || isNaN(form.phone1_3.value) || !isInteger(form.phone1_3.value)){
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");
		document.getElementById('phone1_3').focus();
		pu=true;
		return false;	
	}
	
	document.getElementById('phone').value=form.phone1_1.value+form.phone1_2.value+form.phone1_3.value;
	
	var stripped=form.phone.value.replace(/[\(\)\.\-\ ]/g,'');

	//Phone number must be all numbers
	if(isNaN(stripped) || stripped.length!=10) {
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");
		document.getElementById('phone1_1').focus();
		pu=true;
		return false;
	}
	
	/********** Phone2 its not currently used on individualhealthquotes forms **************//*
	if(form.phone2_1.value.length<3 || isNaN(form.phone2_1.value) || form.phone2_2.value.length<3 ||  isNaN(form.phone2_2.value) || form.phone2_3.value.length<4 || isNaN(form.phone2_3.value)){
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");
		document.getElementById('phone2_1').focus();
		return false;	
	}
	
	document.getElementById('phone2').value=form.phone2_1.value+form.phone2_2.value+form.phone2_3.value;
	
	stripped=form.phone2.value.replace(/[\(\)\.\-\ ]/g,'');

	//Phone number must be all numbers
	if(isNaN(stripped) || stripped.length!=10) {
		alert("Your phone number appears to have been entered incorrectly. Please re-enter your phone number.");
		document.getElementById('phone2_1').focus();
		return false;
	}
*//*******************************************************************************/		
	
	
	//Email cannot be left blank
	if(form.email.value == "") {
		alert("Please enter your email address.");
		form.email.focus();
		pu=true;
		return false;
	}

	//Email must be in a proper format
	if (!emailCheck(form.email.value)) {
		alert ("Your email address appears to have been entered incorrectly. Please re-enter your email address, using the format \"name@domain.com\"");
		form.email.focus();
		pu=true;
		return false;
	}
	
	//Email must be in a proper format
	if(!validDomain(form.email.value)) {
		alert("Your email address appears to have been entered incorrectly. Please re-enter your email address, using the format \"name@domain.com\"");
		form.email.focus();
		pu=true;
		return false;
	}	
return true;	
}
function validDomain(email){
	//Divide email by @
	var split_email = email.split("@");
	
	var domain=split_email[1];
	
	while(domain.indexOf(".")!=-1){
		//Find extension by splitting domain by .
		domain = domain.slice(domain.indexOf(".")+1);
	}

	var valid=false;
	
	//Array of possible domain extensions
	var valid_domains = new Array("aero","asia","biz","cat","com","coop","edu","gov","info","int","jobs","mil","mobi","museum","name","net","org","pro","tel","travel","ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bm","bn","bo","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kr","kw","ky","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md", "mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","st","su","sv","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","tt","tv","tw","tz","ua","ug","uk","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","yu","za","zm","zw","AERO","ASIA","BIZ","CAT","COM","COOP","EDU","GOV","INFO","INT","JOBS","MIL","MOBI","MUSEUM","NAME","NET","ORG","PRO","TEL","TRAVEL","AC","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","ER","ES","ET","EU","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD", "MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","ST","SU","SV","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TP","TR","TT","TV","TW","TZ","UA","UG","UK","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","YU","ZA","ZM","ZW");
	
	//Check if domain extension is valid
	for(var i = 0; i < valid_domains.length; i++) {
		if(domain==valid_domains[i])
			valid=true;
	}
	
	return valid;
}
function emailCheck(emailStr){
   var emailPat=/^(.+)@(.+)$/
   var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
   var validChars="\[^\\s" + specialChars + "\]"
   var quotedUser="(\"[^\"]*\")"
   var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
   var atom=validChars + '+';
   var word="(" + atom + "|" + quotedUser + ")";
   var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
   var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
   var matchArray=emailStr.match(emailPat)
   if(matchArray==null){return false;}
   var user=matchArray[1];
   var domain=matchArray[2];
   if(user.match(userPat)==null){return false;}
   var IPArray=domain.match(ipDomainPat);
   if(IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){return false;}}return true;}
   var domainArray=domain.match(domainPat);
   if(domainArray==null){return false;}
   var atomPat=new RegExp(atom,"g");
   var domArr=domain.match(atomPat);
   var len=domArr.length;
   if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3){return false;}
   if(len<2){return false;}
   return true;
}

// makes a popup
function makePopUp(whereTo,winWidth,winHeight) {
	remote=window.open("","remotewin","width="+winWidth+",height="+winHeight+",menubar=0,toolbar=no,scrollbars=yes");
	remote.location.href=whereTo;remote.focus();
}



// trim left and right spaces.
function ltrim(s){return s.replace(/^\s*/,"");}
function rtrim(s){return s.replace(/\s*$/,"");}
function trim(s){return rtrim(ltrim(s));}

//check for numbers
function noNum(s){
	for(var i = 0; i < s.length; i++)
		if(!isNaN(s.charAt(i)) && s.charAt(i)!=" ")
			return false;
	return true;
}
//check for integer numbers
function isInteger(s){
	return (s.toString().search(/^[0-9]+$/)==0);
}

function validAddress(s) {
	var numbers = false;
	var letters = false;
	for(var i = 0; i < s.length; i++) {
		if(!isNaN(s.charAt(i)) && s.charAt(i)!=" ")
			numbers = true;
		else
			letters = true;
		if(numbers && letters)
			return true;
	}
	return false;	
}
//Checks if BMI is valid, returns true if BMI is not valid
function bmi(w,hFT,hIN){
	//calculate height in inches
	var h = ((hFT * 12) + (hIN * 1));
	//calculate BMI
	var bmi = 703 * (w/(h*h));
	//Pass if BMI is not valid
	if(bmi > 100 || bmi < 10)
		return true;
	return false;
}
//check for bad characters on fields.
function badChars(s){
	for(var i=0;i<s.length;i++){		
		if(s.charAt(i)=="!" || s.charAt(i)=="#"  || s.charAt(i)=="$" || s.charAt(i)=="%" || s.charAt(i)=="%" || s.charAt(i)=="^" || s.charAt(i)=="*" || s.charAt(i)=="+" || s.charAt(i)=="=" || s.charAt(i)=="{" || s.charAt(i)=="}" || s.charAt(i)=="|" || s.charAt(i)=="<" || s.charAt(i)==">" || s.charAt(i)=="`" || s.charAt(i)=="~" || s.charAt(i)=="&" || s.charAt(i)=="(" || s.charAt(i)==")" || s.charAt(i)=="{" || s.charAt(i)=="}" || s.charAt(i)=="[" || s.charAt(i)=="]" || s.charAt(i)=="\\" || s.charAt(i)=="|" || s.charAt(i)=="\"" || s.charAt(i)=="'" || s.charAt(i)==":" || s.charAt(i)==";" || s.charAt(i)=="/" || s.charAt(i)=="-"  || s.charAt(i)=="_" || s.charAt(i)==",")
			return false;
	}
	return true;
}
//check for space
function hasSpace(s) {
	for(var i=0;i<s.length;i++)
		if(s.charAt(i)==" ")
			return true;
	return false;
}
// Show/hide comments
function showHidden(id,value) {
	if(value=="yes")
		document.getElementById(id).style.display='block';
	else
		document.getElementById(id).style.display='none';
}
// Show/hide comments
function displayCommentBox(id,value) {
	if(value)
		document.getElementById(id).style.display='block';
	else
		document.getElementById(id).style.display='none';
}
// hides Popups 
function noPopUp() {
	pu=false;
}
// Shows Popup
function sh_popup() {
	if(pu) {
		var windowReference = window.open('opener.html','survey','width=1,height=1');		
		windowReference.focus();
	}
}
// About You End

// Submit button function
// Checked Form Validation on submit button
function checkSubmitUF(form){
	
	return (HealthProfile(form) && Spouse(form) && Children(form) && AboutYou(form));
}
