function insRow()
{
    document.getElementById('addChildrenLink').style.display ="none";
    document.getElementById('abExtras0').style.display ='';
    document.getElementById('error0').style.display ='';
    document.getElementById('abExtras1').style.display ='';
    document.getElementById('error1').style.display ='';
    document.getElementById('abExtras2').style.display ='';
    document.getElementById('error2').style.display ='';
    document.getElementById('abExtras3').style.display ='';
    document.getElementById('error3').style.display ='';


}

function populatePrsnlizeDropDown(form)
{
    var ttc = false;
   if(form.name != "registration1") {
    var name1 = form.dueChild0Name.value;
    if(name1.length == 0){
        if((form.dueChild0birthMonth.options[form.dueChild0birthMonth.selectedIndex].value != "") &&
          (form.dueChild0birthDay.options[form.dueChild0birthDay.selectedIndex].value.length!= 0) &&
          (form.dueChild0birthYear.options[form.dueChild0birthYear.selectedIndex].value.length!= 0)) {
            name1="Pregnancy"  ;
        }
    }
    var name2 = form.child0Name.value;
	var name3 = form.child1Name.value;
    var name4="";
    var name5="";
    var name6="";
    var name7="";
    var moreName1=""; var moreName2=""; var moreName3=""; var moreName4="";
    var count=2;

    if(form.name=="editProfile") {
     ttc = form.checkedTryToCncve.checked;
     if(form.child2Name) {
        name4=form.child2Name.value;
        count=count+1;
      }
     if(form.child3Name){
        name5=form.child3Name.value;
         count=count+1;
      }
     if(form.child4Name){
        name6=form.child4Name.value;
         count=count+1;
      }
     if(form.child5Name){
        name7=form.child5Name.value;
         count=count+1;
     }
     if(form.addMorechild0Name)  {
        moreName1=form.addMorechild0Name.value;
     }
     if(form.addMorechild1Name){
        moreName2=form.addMorechild1Name.value;
      }
     if(form.addMorechild2Name)
        {
            moreName3 = form.addMorechild2Name.value;
        }
     if(form.addMorechild3Name)
        {
            moreName4 = form.addMorechild3Name.value;
        }

    }else{
     moreName1 = form.addMorechild0Name.value;
	 moreName2 = form.addMorechild1Name.value;
	 moreName3 = form.addMorechild2Name.value;
	 moreName4 = form.addMorechild3Name.value;
    }



	var prsnlizeField=form.prsnlize;
    var curLength = prsnlizeField.options.length;
    var selectedValue=prsnlizeField.options[prsnlizeField.selectedIndex].value ;
    var selectedText=prsnlizeField.options[prsnlizeField.selectedIndex].text;

    for(var count = prsnlizeField.options.length - 1; count >= 0; count--){
        prsnlizeField[count]=null;
    }
   curLength = prsnlizeField.options.length;

   prsnlizeField.length = 1;    
   prsnlizeField[curLength].value = "-1";
   prsnlizeField[curLength].text = "Please Select one";

   curLength++;

    if (ttc) {
        curLength = curLength + 1;

        prsnlizeField.length = curLength;
        prsnlizeField[curLength-1].value = "ttc";
        prsnlizeField[curLength-1].text = "Trying to conceive";
    } 
    if (name1.length!=0) {
		curLength = curLength+1;

		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 0;
		prsnlizeField[curLength-1].text = name1;
	}
	if (name2.length!=0) {
		curLength = curLength+1;

		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 1;

		prsnlizeField[curLength-1].text = name2;
	}
	if (name3.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 2;
		prsnlizeField[curLength-1].text = name3;
	}
    if(form.name=="editProfile") {

      if (name4.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 3;
		prsnlizeField[curLength-1].text = name4;
	  }
	  if (name5.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 4;
		prsnlizeField[curLength-1].text = name5;
	  }
	  if (name6.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 5;
		prsnlizeField[curLength-1].text = name6;
	  }
	  if (name7.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = 6;
		prsnlizeField[curLength-1].text = name7;
	  }
    }
      if (moreName1.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = count+1;
		prsnlizeField[curLength-1].text = moreName1;
	  }
      if (moreName2.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = count+1;
		prsnlizeField[curLength-1].text = moreName2;
	  }
      if (moreName3.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = count+1;
		prsnlizeField[curLength-1].text = moreName3;
	 }
     if (moreName4.length!=0) {
		curLength = curLength+1;
		prsnlizeField.length=curLength;
		prsnlizeField[curLength-1].value = count+1;
		prsnlizeField[curLength-1].text = moreName4;
	 }

    
    for(i=0;i<prsnlizeField.options.length;i++) {
         if(prsnlizeField.options[i].value==selectedValue)
            {
                prsnlizeField.options[i].selected = "true";
            }
    }
  }
}

function checkDropDownOptions(form,formField){
  if(formField.options.length <= 1) {
  } else{
      if(form.dueChild0Name.value.length ==0){
          if((form.dueChild0birthMonth.options[form.dueChild0birthMonth.selectedIndex].value != "") &&
          (form.dueChild0birthDay.options[form.dueChild0birthDay.selectedIndex].value.length!= 0) &&
          (form.dueChild0birthYear.options[form.dueChild0birthYear.selectedIndex].value.length!= 0)) {      
            populatePrsnlizeDropDown(form) ;
        }
      }
  }
}

 function checkDisp(dispName) {
                RegistrationService.checkDisplayName(dispName,dispCallback);
               }

             function dispCallback(resu) {
                 if(resu[0].toString() == "false"){
                     DWRUtil.setValue("displayName-error", "&#149;&nbsp;Display Name already exists. Suggested display name is "+resu[1]);
                   $("displayName").style.color = "red";
                 }else{
                     DWRUtil.setValue("displayName-error", "");
                    $("displayName").style.color = "black";
               }
            }

           function emailCallback(resu) {
                 if(resu[0].toString() == "true"){
                     DWRUtil.setValue("email-error", "&#149;&nbsp;Email already exists");
                   $("email").style.color = "red";
                    var remote = null;
                     text = "<p><a target='main' href='/common/profile/login1.jsp' onClick='setTimeout("+'"'+"window.close()"+'"'+",100)'>Click here to Login!</a></p>";
                     remote = window.open("","LoginWindow","width=300,height=300,screenX=100,screenY=200,top=50,left=80,resizable=yes,scrollbars=yes");
                      with (remote.document) {
                             open();
                             write(text);
                             close();
                       }
                 }else{
                     DWRUtil.setValue("email-error", "");
                    $("email").style.color = "black";
               }
            }


function populateChildMonth(form,formField,month)
  {
   if(form.name=="registration") {
    if(formField.name=="birthMonth")  {
            document.registration.child0birthMonth.options[month].selected= "true";

     } else if(formField.name=="dueMonth")  {
            document.registration.dueChild0birthMonth.options[month].selected= "true";

     }
    }
  }

  function populateChildDay(form,formField,day)
  {
   if(form.name=="registration") {
     if(formField.name=="birthDay")  {
            document.registration.child0birthDay.options[day].selected= "true";

     }else if(formField.name=="dueDay")  {
            document.registration.dueChild0birthDay.options[day].selected= "true";

     }
   }
  }


  function populateChildYear(form,formField,year)
  {
    if(form.name=="registration") {
      if(formField.name=="birthYear")  {

         document.registration.child0birthYear.selectedIndex= formField.selectedIndex;

     }else if(formField.name=="dueYear")  {

         document.registration.dueChild0birthYear.selectedIndex= formField.selectedIndex;

     }
    }
  }

      function requiredChildInfo(form,formField)
  {
   if(form.name=="registration") {
    if(formField.checked)  {
        document.getElementById('reqText').style.display ='';
        document.getElementById('reqNameText').style.display ='';
        document.getElementById('reqBirthText').style.display ='';
        document.getElementById('reqSexText').style.display ='';

     }
    }
  }