﻿// JScript File
document.domain = "ef.com";
function setBirthdayDay(selectBox) {
    //alert(selectBox);
    day = selectBox.options[selectBox.selectedIndex].value;
    birthdayString = document.personaldetails.birthDate.value;
    bsArray = birthdayString.split("/");
    bsDay = bsArray[0];
    if (bsDay != day)
        bsArray[0] = day;
    birthdayString = bsArray.join("/");
    document.personaldetails.birthDate.value = birthdayString;
}

function setBirthdayMonth(selectBox) {
    month = selectBox.options[selectBox.selectedIndex].value;
    birthdayString = document.personaldetails.birthDate.value;
    bsArray = birthdayString.split("/");
    bsDay = bsArray[1];
    if (bsDay != month)
        bsArray[1] = month;
    birthdayString = bsArray.join("/");
    document.personaldetails.birthDate.value = birthdayString;

}

function setBirthdayYear(selectBox) {
    year = selectBox.options[selectBox.selectedIndex].value;
    birthdayString = document.personaldetails.birthDate.value;
    bsArray = birthdayString.split("/");
    bsDay = bsArray[2];
    if (bsDay != year)
        bsArray[2] = year;
    birthdayString = bsArray.join("/");
    document.personaldetails.birthDate.value = birthdayString;
}

function setRelationship(selectBox, hiddenfield) {
    relationship = selectBox.options[selectBox.selectedIndex].value;
    document.forms['familydetails'].elements[hiddenfield.name].value = relationship;
}


function setEngStudied(selectBox) {
    engStud = selectBox.options[selectBox.selectedIndex].value;
    document.forms['interest'].elements['englishStudied'].value = engStud;
}

function setImgDetails(pic1Url, pic2Url, pic2Desc) {
    document.forms["photograph"].elements["picture1Url"].value = pic1Url;
    document.forms["photograph"].elements["picture2Url"].value = pic2Url;
    document.forms["photograph"].elements["picture2Desc"].value = pic2Desc;
}
function setDesc(pic2Desc) {
    document.forms["photograph"].elements["picture2Desc"].value = pic2Desc;
}

function setDDSelected(formName, theVar, theDropDown) {    
    var vTheVar = document.forms[formName].elements[theVar].value.toUpperCase();
    if (vTheVar && vTheVar != "undefined") {
        var dTheDropDown = document.forms[formName].elements[theDropDown];
        var ddLength = dTheDropDown.options.length - 1;
        var curOption = "";
        dTheDropDown.selectedIndex = 0;
        for (i = 0; i <= ddLength; i++) {
            curOption = dTheDropDown.options[i].text.toUpperCase();
            if (curOption == vTheVar) {
                dTheDropDown.selectedIndex = i;
                document.forms[formName].elements[theVar].value=i;
                break;
            }
        }
    }
}

