window.onload = handleCountry;
var hold_USWorkPhone = new Array(); // eval on lprPost is,if no usPhone then store international. this means need to remove from fields while int is selected. when going back to us provid us value again

// Handle dynamic change of fields to handle foreign information
// 03/23/2009 smt 14970 ajm, add better error handling if a contact field isn't chosen for edit
//05/20/2011 EK SMT 16380 JS when included in lp.asp was overriding the required display(the asterick and bold text) of the state and zip fields.
function handleCountry() {
    
    // State/Province
    var stateLabel = document.getElementById('state-label');
    var zipLabel = document.getElementById('zip-label');
    var zip = document.getElementById('zip');
    var fzip = document.getElementById('fzip');
    var stateDrop = document.getElementById('state');
    var province = document.getElementById('province');
    var workphone = document.getElementById('workphone');
    var workphone1 = document.getElementById('WorkPhone1');
    var workphone2 = document.getElementById('WorkPhone2');
    var workphone3 = document.getElementById('WorkPhone3');

    var Requirezip = document.getElementById('Requirezip');
    var Requirestate = document.getElementById('Requirestate');
    
    if ((hold_USWorkPhone.length == 0) && (workphone1 != null) && (workphone2 != null) && (workphone3 != null)) {
        hold_USWorkPhone = new Array(workphone1.value, workphone2.value, workphone3.value)
    }

    if(document.getElementById('country').value != '0') {
        
        if (workphone1 != null) {  // workphone1 is displayed, then all workPhoneX are displayed
            workphone1.style.display = 'none';
            workphone2.style.display = 'none';
            workphone3.style.display = 'none';
            workphone1.value = '';
            workphone2.value = '';
            workphone3.value = '';
        }

        if (stateDrop != null)
            stateDrop.style.display = 'none';
        if (zip != null)
            zip.style.display = 'none';
        if (province != null)
            province.style.display = 'inline';
        if (workphone != null)
            workphone.style.display = 'inline';
        if (fzip != null)
            fzip.style.display = 'inline';

        if (zipLabel != null)
            zipLabel.innerHTML = 'Postal Code:';
        if (stateLabel != null)
            stateLabel.innerHTML = 'Province:';
    }
    else {


        if (workphone1 != null) {  // workphone1 is displayed, then all workPhoneX are displayed
            if (hold_USWorkPhone.length != 0) {
                workphone1.value = hold_USWorkPhone[0];
                workphone2.value = hold_USWorkPhone[1];
                workphone3.value = hold_USWorkPhone[2];
            }
            if (workphone1.value == '' && workphone2.value == '' && workphone3.value == '') // swapping from International to US ... dumb dumb user
                workphone1.value = workphone.value.substring(0, 3);

            workphone1.style.display = 'inline';  // resetting size attribute with 
            workphone2.style.display = 'inline';
            workphone3.style.display = 'inline';
        }
        
        if (stateDrop != null)
            stateDrop.style.display = 'inline';
        if (zip != null)
            zip.style.display = 'inline';
        if (province != null)
            province.style.display = 'none';
        if (workphone != null)
            workphone.style.display = 'none';
        if (fzip != null)
            fzip.style.display = 'none';

        if (zipLabel != null)
            
            if (Requirezip.value == 0) { zipLabel.innerHTML = 'Zip Code:';  }
            if (Requirezip.value == 1) { zipLabel.innerHTML = '<font color=black>*</font><b>Zip Code:</b>'; }
           
        if (stateLabel != null)
            //stateLabel.innerHTML = 'State:';
            if (Requirestate.value == 0) { stateLabel.innerHTML = 'State:'; }
            if (Requirestate.value == 1) { stateLabel.innerHTML = '<font color=black>*</font><b>State:</b>'; }
        
    }

}
