function isBlankValue(elem){
    if (!elem.value) return true; 
    else {var str = elem.value;
    for (var i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        if ((ch != ' ') && (ch != '\n') && (ch != '\t')) return false;}
        return true;}
}

function checkEmailAddress(field){
    if (field.value != ''){
        var value = String(field.value);
        var passed = false;

        for (index = 0; index < value.length; index++){
            if (value.charAt(index) == '@')
                passed = true;
        }

        if (passed == false){
            alert('Please use {ie. username@domain.com} format for all email entries.');
            field.value = '';
            field.focus();
        }
    }
}

/******************************* functions to check radio and checkbox values */


function getFormGroup(name) {
    return document.getElementsByName(name);
}

function isChecked(name) {      /* return whether or not any value is checked */
elements = getFormGroup(name);
if (elements)                   
for (i = 0; i < elements.length; i++)
if (elements[i].checked)
return true;
return false;                   
}


/******************************* function to check form */

function checkFormData(frm){
    
    var sError = '';
    frm.SubmitButton.disabled=true;
    
    //var num5 = isChecked('question_12')? true : false;
    if (frm.person_first_name.value == "") sError += " - Please enter your first name\n";
    if (frm.person_last_name.value == "") sError += " - Please enter your last name\n";
    if (frm.person_address1.value == "") sError += " - Please enter your address\n";
    if (frm.person_city.value == "") sError += " - Please enter your city\n";
    if (frm.person_state.value == "") sError += " - Please enter your state\n";
    if (frm.person_zip.value == "") sError += " - Please enter your zip code\n";
    if (frm.person_phone.value == "") sError += " - Please enter your phone number\n";
    if (frm.person_email.value == "") sError += " - Please enter your email address\n";
    if (frm.question_7_OTHERTEXT.value == "" || frm.question_7_OTHERTEXT.value == "--Select one--") sError += " - Please enter the name of your college or office\n";
    if (frm.question_8.value == "" || frm.question_8.value == 0) sError += " - Please enter the name of your campus\n";
    if (frm.question_9_OTHERTEXT.value == "") sError += " - Please enter the name of your department\n";
    if (frm.question_10.value == "" || frm.question_10.value == "null") sError += " - Please enter the type of conference\n";
    //if (num5 == false) sError += " - Please check whether you want one or more numbers\n";
    if (sError.length > 0){alert('Please correct the following errors:\n\n' + sError); 
    frm.SubmitButton.disabled=false; 
    return false; }
return true;
}

function checkFormData2(frm){
    
    var sError = '';
    frm.SubmitButton.disabled=true;
    
    //var num5 = isChecked('question_12')? true : false;
    if (frm.person_first_name.value == "") sError += " - Please enter your first name\n";
    if (frm.person_last_name.value == "") sError += " - Please enter your last name\n";
    if (frm.person_phone.value == "") sError += " - Please enter your phone number\n";
    if (frm.person_email.value == "") sError += " - Please enter your email address\n";
    if (frm.question_7_OTHERTEXT.value == "" || frm.question_7_OTHERTEXT.value == "--Select one--") sError += " - Please enter the name of your college or office\n";
    if (frm.question_8.value == "" || frm.question_8.value == 0) sError += " - Please enter the name of your campus\n";
    if (frm.question_9_OTHERTEXT.value == "") sError += " - Please enter the audio number\n";
    if (sError.length > 0){alert('Please correct the following errors:\n\n' + sError); 
    frm.SubmitButton.disabled=false; 
    return false; }
return true;
}


/******************************* Function to redirect to the single/multi-user pages 
Currently not in use.
*/


function valbutton(thisform) {

myOption = -1;
for (i=thisform.question12.length-1; i > -1; i--) {
if (thisform.question12[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("Please select an option.");
return false;
}

if (myOption == 0) {
parent.location.href="http://www.yahoo.com/";
}

if (myOption == 1) {
parent.location.href = "http://web5.e2c.com/event/alaska/contact.asp"
}

}


/******************************* Populate college/office select box */


function populateit() {

    o=document.getElementById('question_8');
    d=document.getElementById('question_7_OTHERTEXT');
    if(!d){return;}         
    var mitems=new Array();
    mitems[0]=['--Select one--'];
    mitems[1]=['--Select one--','Academic Affairs','Academic Center for Excellence','Academic Technology Services','ACCFT','Accounting Services','Advising & Counseling Center','AHAINA','Alaska Native & Rural Development Department','Alaska Rural Development Council','American Russian Center','Athletics','Bookstore','Budget & Finance','Business Services','Cafe','Campus Diversity & Compliance','Campus Life','Career Services Center','Center for Community Engagement & Learning','Chancellor','Chugiak-Eagle River Campus','College of Arts and Sciences','College of Business & Public Policy','College of Education','College of Health and Social Welfare','Community & Technical College','Community Engagement & Learning','Consortium Library','Cooperative Extension Service','Copper Basin Extension Center','Cordova Extension Center','Disability Support Services','Educational Opportunity Center','Enrollment Services','Facilities & Campus Services','Faculty Fellow','Faculty Services','Family & Youth Services Training Academy','Financial Systems','General Support Services','Governance','Graduate & Research Studies','Health Sciences','Honors Program','Human Resources','Information Technology Services','Institute of Planning, Research & Assessment','Institute of Social & Economic Research','Journalism and Public Communications','Judicial Affairs & Student Leadershop Center for Economic Education','Justice Center','Labor Relations (Statewide)','Marine Advisory Program','Mining & Petroleum Training Service','Native Student Services','Office of Chancellor','Office of Provost','Office of Vice Provost','Parking Services','Pre-College Programs','Procurement Services','Residence Life','School of Engineering','School of Nursing','School of Social Work','Small Business Development Center','Student Affairs','Student Financial Aid','Student Health Center','Student Success','Support Services for Facilities & Campus Services','UAA Board of Advisors','Undergraduate Research & Scholarship','United Academics','University Advancement','University Housing, Dining & Conference Services','University of Alaska Corporate Programs','University Police','VC, Administrative Services'];
    mitems[2]=['Kenai Business Office'];
    mitems[3]=['Kodiak Business Office'];
    mitems[4]=['Matsu Business Office'];
    mitems[5]=['Prince William Sound Business Office'];
    mitems[6]=['--Select one--','Chancellor','Provost','Vice Chancellor for Administrative Services','Arctic Biology, Institute of','Arctic Region Supercomputing Center','Campus Diversity and Compliance Director','Cooperative Extension Service','Development','School of Education','Engineering and Mines, College of','Enrollment Management','Facilities, Associate Vice Chancellor for','Fisheries and Ocean Sciences, School of','Geophysical Institute','Graduate School','International Arctic Research Center','Liberal Arts, College of','Library, Rasmuson','Management, School of','Marine Science, Institute of','Mineral Engineering, School of','Museum, University of Alaska','Natural Resources and Agricultural Sciences, School of','Northern Engineering, Institute of','Research, Vice Provost for','Rural Alaska, College of','Student Affairs','University Relations','Center for Distance','IAC'];
    mitems[7]=['Juneau Business Office'];
    mitems[8]=['Ketchikan Business Office'];
    mitems[9]=['Sitka Business Office'];
    mitems[10]=['--Select one--','Academic Affairs','Board of Regents Office','Budget and Institutional Research','Chancellor','Controller','Corporate Programs','Development','EPSCoR','Finance','Foundation','General Counsel','Health','Human Resources','ITS','Land Management','Presidents Office','Research','Risk Management','Student and Enrollment Services','System Governance','University Relations'];
    d.options.length=0;
    cur=mitems[o.options[o.selectedIndex].value];
    if(!cur){return;}
    d.options.length=cur.length;
    for(var i=0;i<cur.length;i++)
    {
        d.options[i].text=cur[i];
        d.options[i].value=cur[i];
    }

}
