var ajax=new sack(); var activeObjectId=null; function cancel_new_phone() { document.getElementById('user_profiles_edit_phone_new').style.display="none"; document.getElementById('contactnums_').value=''; document.getElementById('contact_nums_service_type_').value=''; document.getElementById('contactnumstype_').selectedIndex=0; } function activate_new_phone() { document.getElementById('user_profiles_edit_phone_new').style.display="inline"; } var activeObject=null; var what = null; var newbrowser = true; var check = false; var first_name_stored; var middle_name_stored; var last_name_stored; var display_name_stored; var editing_email_stored; var editing_email_field; var vieweduser; function editnames(first_name, middle_name, last_name, display_name) { first_name_stored=first_name; middle_name_stored=middle_name; last_name_stored=last_name; display_name_stored=display_name; objFirstName=document.getElementById('fname'); objMiddleName=document.getElementById('mname'); objLastName=document.getElementById('lname'); objDisplayName=document.getElementById('display_name'); objFirstName.className=""; objMiddleName.className=""; objLastName.className=""; objDisplayName.className=""; objFirstName.readOnly=false; objMiddleName.readOnly=false; objLastName.readOnly=false; objDisplayName.readOnly=false; document.getElementById('saveButton_names').style.display='inline'; document.getElementById('editButton_names').style.display='none'; document.getElementById('cancelButton_names').style.display='inline'; } function cancelnames() { objFirstName=document.getElementById('fname'); objMiddleName=document.getElementById('mname'); objLastName=document.getElementById('lname'); objDisplayName=document.getElementById('display_name'); objFirstName.className="readonly"; objMiddleName.className="readonly"; objLastName.className="readonly"; objDisplayName.className="readonly"; objFirstName.value=first_name_stored; objMiddleName.value=middle_name_stored; objLastName.value=last_name_stored; objDisplayName.value=display_name_stored; objFirstName.readOnly=true; objMiddleName.readOnly=true; objLastName.readOnly=true; objDisplayName.readOnly=true; document.getElementById('saveButton_names').style.display='none'; document.getElementById('editButton_names').style.display='inline'; document.getElementById('cancelButton_names').style.display='none'; } function savenames(viewing_uid, viewed_uid) { vieweduser=viewed_uid; ajax.setVar("uid",viewing_uid); ajax.setVar("d-uid",viewed_uid); ajax.setVar("fname",escape(document.getElementById('fname').value)); ajax.setVar("mname",escape(document.getElementById('mname').value)); ajax.setVar("lname",escape(document.getElementById('lname').value)); ajax.setVar("dname",escape(document.getElementById('display_name').value)); ajax.setVar("mode","update_names"); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=savenames_complete; ajax.onError=ajaxError; ajax.runAJAX(); } function savenames_complete() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // if the message doesn't contain "error", then the operation was successful // change the stored name values and switch the fields back to display mode first_name_stored=document.getElementById('fname').value; middle_name_stored=document.getElementById('mname').value; last_name_stored=document.getElementById('lname').value; display_name_stored=document.getElementById('display_name').value; ajax.reset(); cancelnames(); } } function editemail(objEditButton) { var referenceData=objEditButton.id.split('_'); var emails_id=referenceData[2]; var emails_type_id=referenceData[3]; objAddButton=document.getElementById('addButton_email_'+emails_id+'_'+emails_type_id); objDeleteButton=document.getElementById('deleteButton_email_'+emails_id+'_'+emails_type_id); objSaveButton=document.getElementById('saveButton_email_'+emails_id+'_'+emails_type_id); objCancelButton=document.getElementById('cancelButton_email_'+emails_id+'_'+emails_type_id); objField=document.getElementById('emails_'+emails_id+'_'+emails_type_id); objField.className=""; editing_email_stored=objField.value; objField.readOnly=false; objEditButton.style.display='none'; objAddButton.style.display='none'; objDeleteButton.style.display='none'; objSaveButton.style.display='inline'; objCancelButton.style.display='inline'; } function cancelEmail(objCancelButton) { var referenceData=objCancelButton.id.split('_'); var emails_id=referenceData[2]; var emails_type_id=referenceData[3]; objEditButton=document.getElementById('editButton_email_'+emails_id+'_'+emails_type_id); objAddButton=document.getElementById('addButton_email_'+emails_id+'_'+emails_type_id); objDeleteButton=document.getElementById('deleteButton_email_'+emails_id+'_'+emails_type_id); objSaveButton=document.getElementById('saveButton_email_'+emails_id+'_'+emails_type_id); objField=document.getElementById('emails_'+emails_id+'_'+emails_type_id); objField.value=editing_email_stored; objField.className='readonly'; objField.readOnly=true; objSaveButton.style.display='none'; objCancelButton.style.display='none'; objEditButton.style.display='inline'; objAddButton.style.display='inline'; objDeleteButton.style.display='inline'; } function addemail() { objForm=document.getElementById('emails_new_form'); objAddress=document.getElementById('emails_new_address'); objType=document.getElementById('emails_new_type'); objSaveButton=document.getElementById('saveButton_new_email'); objCancelButton=document.getElementById('cancelButton_new_email'); objForm.style.display='inline'; objAddress.style.display='inline'; objAddress.value=""; objType.style.display='inline'; objType.selectedIndex=0; objSaveButton.style.display='inline'; objCancelButton.style.display='inline'; } function cancelNewEmail() { document.getElementById('emails_new_form').style.display='none'; document.getElementById('emails_new_address').style.display='none'; document.getElementById('emails_new_type').style.display='none'; document.getElementById('saveButton_new_email').style.display='none'; document.getElementById('cancelButton_new_email').style.display='none'; } function saveEmail(objSaveButton,uid,d_uid) { var referenceData=objSaveButton.id.split('_'); var emails_id=referenceData[2]; var emails_type_id=referenceData[3]; vieweduser=d_uid; editing_email_field=document.getElementById('emails_'+emails_id+'_'+emails_type_id); ajax.setVar("mode","updateEmail"); ajax.setVar("uid",uid); ajax.setVar("d-uid",d_uid); ajax.setVar("email_id",emails_id); ajax.setVar("type_id",emails_type_id); ajax.setVar("new_address",document.getElementById('emails_'+emails_id+'_'+emails_type_id).value); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=saveEmail_complete; ajax.onError=ajaxError; ajax.runAJAX(); } function saveEmail_complete() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // if the message doesn't contain "error", then the operation was successful // change the stored value in javascript editing_email_stored, and change it back to readonly // but first we have to get some information from the return. It comes in the form // email_id,type_id,success var returnData=removeNL(ajax.response); ajax.reset(); var data=returnData.split(','); // get the original field reference var objField=editing_email_field; // get the old email ID and type ID from this object var oldData=objField.id.split('_'); var oldEmailId=oldData[1]; var oldTypeId=oldData[2]; // change the field ID in case it was updated during the ajax (if we had to create a new email listing) // so that we can reference it later as needed and stay consistent objField.id='emails_'+data[0]+'_'+data[1]; objEditButton=document.getElementById('editButton_email_'+oldEmailId+'_'+oldTypeId); objEditButton.id='editButton_email_'+data[0]+'_'+data[1]; objEditButton.href="javascript: editemail(document.getElementById('"+objEditButton.id+"'))"; objAddButton=document.getElementById('addButton_email_'+oldEmailId+'_'+oldTypeId); objAddButton.id='addButton_email_'+data[0]+'_'+data[1]; objDeleteButton=document.getElementById('deleteButton_email_'+oldEmailId+'_'+oldTypeId); objDeleteButton.id='deleteButton_email_'+data[0]+'_'+data[1]; objDeleteButton.href="javascript: removeEmail(document.getElementById('"+objDeleteButton.id+"',11,11))"; objSaveButton=document.getElementById('saveButton_email_'+oldEmailId+'_'+oldTypeId); objSaveButton.id='saveButton_email_'+data[0]+'_'+data[1]; objSaveButton.href="javascript: saveEmail(document.getElementById('"+objSaveButton.id+"',11,11))"; objCancelButton=document.getElementById('cancelButton_email_'+oldEmailId+'_'+oldTypeId); objCancelButton.id='cancelButton_email_'+data[0]+'_'+data[1]; objCancelButton.href="javascript: cancelEmail(document.getElementById('"+objCancelButton.id+"'))"; objField=document.getElementById('emails_'+data[0]+'_'+data[1]); editing_email_stored=objField.value; cancelEmail(document.getElementById('cancelButton_email_'+data[0]+'_'+data[1])); } } function saveNewEmail(uid, d_uid) { vieweduser=d_uid; var objAddressField=document.getElementById('emails_new_address'); var objTypeField=document.getElementById('emails_new_type'); ajax.setVar("mode","newEmail"); ajax.setVar("uid",uid); ajax.setVar("d-uid",d_uid); ajax.setVar("new_address",objAddressField.value); ajax.setVar("type",objTypeField.value); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=newEmail_complete; ajax.onError=ajaxError; ajax.runAJAX(); } // takes the email_id and email_type_id sent from ajaxResponder and creates a new set of fields for // the newly created email address and inserts the information into it function newEmail_complete() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { var returnData=removeNL(ajax.response); ajax.reset(); var data=returnData.split(','); var objCreateField=document.getElementById('emails_new_address'); if (data[3] == 'old') { var objOldField=document.getElementById('emails_'+data[0]+'_'+data[1]); if (objOldField != null) { objOldField.value=objCreateField.value; } else { alert("Your email address was saved, but an error occured when displaying it on this page. Please refresh this page to update your display"); } } else { // we're going to have to create a new p element above the emails_new_form p element and fill it with the proper data var newP=document.createElement("p"); newP.innerHTML=""; newP.innerHTML+=""; // because this is in response to an edit, we can safely display the links newP.innerHTML+=" edit | "; newP.innerHTML+="add | "; newP.innerHTML+="remove"; newP.innerHTML+="save | "; newP.innerHTML+="cancel"; objCreateBlock=document.getElementById('emails_new_form'); objCreateBlock.parentNode.insertBefore(newP,objCreateBlock); cancelNewEmail(); } } } function removeEmail(objRemoveButton,uid,d_uid) { var referenceData=objRemoveButton.id.split('_'); var emails_id=referenceData[2]; var emails_type_id=referenceData[3]; if (confirm("Are you sure you want to delete this email address?")) { ajax.setVar("d_uid",d_uid); ajax.setVar("uid",uid); ajax.setVar("email_id",emails_id); ajax.setVar("type_id",emails_type_id); ajax.setVar("mode","deleteEmail"); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=removeEmail_complete; ajax.onError=ajaxError; ajax.runAJAX(); } } function removeEmail_complete() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { if (removeNL(ajax.response) == 'notremoved') { alert("You must keep one email address in the system. We could not delete the selected address"); } else { // success. remove it (by setting it to hidden) var returnData=removeNL(ajax.response); ajax.reset(); var data=returnData.split(','); objEmailParent=document.getElementById("emails_"+data[0]+"_"+data[1]).parentNode; objEmailParent.style.display='none'; // this will be completely removed next time the user refreshes, but there are two different // ways to remove a node in FF vs IE so I opted to go with the "out of sight, out of mind" method // because we just removed an email address of a certain type, we should add that type as an option document.getElementById('emails_new_type').innerHTML+=""; } } } var editing_number_stored=null; var editing_number_service_stored=null; function editphone(phones_id, phones_type_id) { objAddButton=document.getElementById('addButton_phone_'+phones_id+'_'+phones_type_id); objSaveButton=document.getElementById('saveButton_phone_'+phones_id+'_'+phones_type_id); objCancelButton=document.getElementById('cancelButton_phone_'+phones_id+'_'+phones_type_id); objRemoveButton=document.getElementById('removeButton_phone_'+phones_id+'_'+phones_type_id); objEditButton=document.getElementById('editButton_phone_'+phones_id+'_'+phones_type_id); objNumField=document.getElementById('contactnums_'+phones_id+'_'+phones_type_id); objNumField.className="contact_nums"; editing_number_stored=objNumField.value; objNumField.readOnly=false; objServiceField=document.getElementById('contactnumsservice_'+phones_id+'_'+phones_type_id); objServiceField.className="contact_nums_type"; editing_number_service_stored=objServiceField.value; objServiceField.readOnly=false; objEditButton.style.display='none'; objAddButton.style.display='none'; objRemoveButton.style.display='none'; objSaveButton.style.display='inline'; objCancelButton.style.display='inline'; } function cancelPhone(phones_id, phones_type_id) { objAddButton=document.getElementById('addButton_phone_'+phones_id+'_'+phones_type_id); objSaveButton=document.getElementById('saveButton_phone_'+phones_id+'_'+phones_type_id); objCancelButton=document.getElementById('cancelButton_phone_'+phones_id+'_'+phones_type_id); objRemoveButton=document.getElementById('removeButton_phone_'+phones_id+'_'+phones_type_id); objEditButton=document.getElementById('editButton_phone_'+phones_id+'_'+phones_type_id); objNumField=document.getElementById('contactnums_'+phones_id+'_'+phones_type_id); objNumField.className="contact_nums_readonly"; objNumField.value=editing_number_stored; objNumField.readOnly=true; objServiceField=document.getElementById('contactnumsservice_'+phones_id+'_'+phones_type_id); objServiceField.className="contact_nums_type_readonly"; objServiceField.value=editing_number_service_stored; objServiceField.readOnly=true; objAddButton.style.display="inline"; objSaveButton.style.display="none"; objCancelButton.style.display="none"; objRemoveButton.style.display="inline"; objEditButton.style.display="inline"; document.getElementById('search_box_dropdown').style.display="none"; } function removePhone(uid, d_uid, numberId, typeId) { ajax.setVar("d_uid",d_uid); ajax.setVar("uid",uid); ajax.setVar("typeId",typeId); ajax.setVar("numberId",numberId); ajax.setVar("mode","remove_phone"); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=removePhone_complete; ajax.onError=ajaxError; ajax.runAJAX(); } function removePhone_complete() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // success. remove it (by setting it to hidden) var returnData=removeNL(ajax.response); ajax.reset(); var data=returnData.split(','); var objInput=document.getElementById('contactnums_'+data[0]+'_'+data[1]); var pToRemove=objInput.parentNode; // we set it to block first to ensure that it has a display so that we can remove it safely pToRemove.style.display='block'; pToRemove.style.display='none'; } } function save_new_phone(uid,d_uid) { ajax.setVar("mode","new_phone"); ajax.setVar("uid",uid); ajax.setVar("d_uid",d_uid); // display user. who's being edited? ajax.setVar("number",document.getElementById('contactnums_').value); ajax.setVar("typeId",document.getElementById('contactnumstype_').value); ajax.setVar("serviceName",document.getElementById('contact_nums_service_type_').value); ajax.setVar("outputType","newRow"); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=new_phone_completion; ajax.runAJAX(); } function new_phone_completion() { if (removeNL(ajax.response).indexOf('error') == -1) { // creates the new p element and inserts it before the "new phone number" p element var newElement=document.createElement("p"); newElement.innerHTML = ajax.response; var objNewPhone=document.getElementById('user_profiles_edit_phone_new'); objNewPhone.parentNode.insertBefore(newElement,objNewPhone); // resets the data within the new phone number p element document.getElementById('contactnums_').value=""; document.getElementById('contact_nums_service_type_').value=""; document.getElementById('contactnumstype_').selectedIndex=0; // hide the new phone number p element document.getElementById('user_profiles_edit_phone_new').style.display="none"; location.reload(true); } else { alert(removeNL(ajax.response)); } ajax.reset(); } function saveEditPhone(uid, d_uid, numberId, typeId) { ajax.setVar("mode","edit_phone"); ajax.setVar("uid",uid); ajax.setVar("d_uid",d_uid); // display user. who's being edited? ajax.setVar("number",document.getElementById('contactnums_'+numberId+'_'+typeId).value); ajax.setVar('numberId',numberId); actingUserId=uid; displayUserId=d_uid; ajax.setVar('typeId',typeId); ajax.setVar('serviceName',document.getElementById('contactnumsservice_'+numberId+'_'+typeId).value); editing_number_stored=numberId; editing_number_service_stored=typeId; ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=edit_phone_completion; ajax.runAJAX(); } var actingUserId=null; var displayUserId=null; function edit_phone_completion() { if (removeNL(ajax.response).indexOf('error') == -1) { var returnData=removeNL(ajax.response); ajax.reset(); var data=returnData.split(','); objNumberField=document.getElementById('contactnums_'+editing_number_stored+'_'+editing_number_service_stored); objServiceField=document.getElementById('contactnumsservice_'+editing_number_stored+'_'+editing_number_service_stored); objNumberField.value=data[2]; var old_phoneId=editing_number_stored; var old_typeId=editing_number_service_stored; objServiceField.value=data[4]; editing_number_stored=data[2]; editing_number_service_stored=data[4]; cancelPhone(old_phoneId,old_typeId); // change over all IDs and actions for each button (wish I could use "this" for those) btnEdit=document.getElementById('editButton_phone_'+old_phoneId+'_'+old_typeId); btnEdit.id='editButton_phone_'+data[0]+'_'+data[1]; btnEdit.href='javascript: editphone('+data[0]+','+data[1]+')'; btnAdd=document.getElementById('addButton_phone_'+old_phoneId+'_'+old_typeId); btnAdd.id='addButton_phone_'+data[0]+'_'+data[1]; btnRemove=document.getElementById('removeButton_phone_'+old_phoneId+'_'+old_typeId); btnRemove.id='removeButton_phone_'+data[0]+'_'+data[1]; btnRemove.href='javascript: removePhone('+actingUserId+','+displayUserId+','+data[0]+','+data[1]+')'; btnSave=document.getElementById('saveButton_phone_'+old_phoneId+'_'+old_typeId); btnSave.id='saveButton_phone_'+data[0]+'_'+data[1]; btnSave.href='javascript: saveEditPhone('+actingUserId+','+displayUserId+','+data[0]+','+data[1]+')'; btnCancel=document.getElementById('cancelButton_phone_'+old_phoneId+'_'+old_typeId); btnCancel.id='cancelButton_phone_'+data[0]+'_'+data[1]; btnCancel.href='javascript: cancelPhone('+data[0]+','+data[1]+')'; // change fields and label //var label=document.getElementById('contactnumstype_'+old_phoneId+'_'+old_typeId); //label.htmlFor='contactnumstype_'+data[0]+'_'+data[1]; var numberField=document.getElementById('contactnums_'+old_phoneId+'_'+old_typeId); numberField.id='contactnums_'+data[0]+'_'+data[1]; numberField.name='contactnums_'+data[0]+'_'+data[1]; var typeField=document.getElementById('contactnumsservice_'+old_phoneId+'_'+old_typeId); typeField.id='contactnumsservice_'+data[0]+'_'+data[1]; typeField.name='contactnumsservice_'+data[0]+'_'+data[1]; location.reload(true); } else { alert(removeNL(ajax.response)); ajax.reset(); } } var storedDob=null; function editDob() { objSaveButton=document.getElementById('saveButton_dob'); objCancelButton=document.getElementById('cancelButton_dob'); objEditButton=document.getElementById('editButton_dob'); objField=document.getElementById('dob_'); storedDob=objField.value; objField.className=""; //objField.readOnly=false; objEditButton.style.display='none'; objSaveButton.style.display='inline'; objCancelButton.style.display='inline'; fPopCalendar("dob_"); } function cancelDob() { objSaveButton=document.getElementById('saveButton_dob'); objCancelButton=document.getElementById('cancelButton_dob'); objEditButton=document.getElementById('editButton_dob'); objField=document.getElementById('dob_'); objField.value=storedDob; objField.className="readonly"; objField.readOnly=true; if (objEditButton != null) { objEditButton.style.display='inline'; } objSaveButton.style.display='none'; if (objCancelButton != null) { objCancelButton.style.display='none'; } closeCalendar(); } function saveDob(uid, d_uid) { ajax.setVar("mode","updateDob"); ajax.setVar("uid",uid); ajax.setVar("d_uid",d_uid); // display user. who's being edited? ajax.setVar("newDob",document.getElementById('dob_').value); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder.php"; ajax.method="POST"; ajax.onCompletion=saveDob_complete; ajax.runAJAX(); } function saveDob_complete() { if (removeNL(ajax.response).indexOf('error') == -1) { storedDob=removeNL(ajax.response); } else { alert(removeNL(ajax.response)); } ajax.reset(); cancelDob(); } function dobShowCalendar() { var objDobField=document.getElementById('dob_'); if (!objDobField.readOnly) { fPopCalendar("dob_"); } } /* function hideUnhideAddressType() { objAddressTypeBox=document.getElementById('addresstype_'); objAddressBuildingStreetStateCityZip=document.getElementById('profileInfoBuildingStreetStateCityZip'); if (objAddressTypeBox.selectedIndex != 0) { objAddressBuildingStreetStateCityZip.style.display='block'; } else { objAddressBuildingStreetStateCityZip.style.display='none'; } } */ //START Gender Functions function hideUnhideGenderUpdate() { document.getElementById('jsHideUnhide_update_gender_').style.display = 'none'; document.getElementById('jsHideUnhide_update_gender_options_').style.display = 'block'; } function hideUnhideGenderCancel() { document.getElementById('jsHideUnhide_update_gender_').style.display = 'block'; document.getElementById('jsHideUnhide_update_gender_options_').style.display = 'none'; } //END Gender Functions //START Ethnicity Functions function otherRace() { if(document.getElementById('ethnicity_').value == 'other_race'){ document.getElementById('enter_other_race').style.display = 'block'; }else { document.getElementById('enter_other_race').style.display = 'none'; } } //END Ethnicity Functions // get the organization type and website based on what the user has (so far) typed in the // organization field ajaxOrg=new sack(); function getInstitutionData(objInstName, newName) { if (!ajaxOrgLock) { if (newName == '') { ajaxOrg.setVar("institution",objInstName.value); } else { ajaxOrg.setVar("institution",newName); } ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_institution.php#get"; ajaxOrg.method="POST"; ajaxOrg.onCompletion=institution_complete; ajaxOrg.onLoading=lockAjaxOrg; ajaxOrg.runAJAX(); } } var ajaxOrgLock=false; function lockAjaxOrg() { ajaxOrgLock=true; } function institution_complete() { if (removeNL(ajaxOrg.response).indexOf('error') == -1) { if (removeNL(ajaxOrg.response).indexOf('nomatch') == -1) { // data will contain the institution type id and web address (if they exist) in that order var data=removeNL(ajaxOrg.response).split(','); // set the needed stuff document.getElementById('organizationwebsite_').value=data[1]; var typeSelect = document.getElementById("institutiontype_"); for (i=0; i < typeSelect.length; i++) { if (typeSelect.options[i].value == data[0]) { typeSelect.selectedIndex = i; break; } } } // if we have the response "nomatch" do nothing } // if we have an error, do nothing ajaxOrgLock=false; ajaxOrg.reset(); } function postClick(objSearchObject, newName) { getInstitutionData(objSearchObject, newName); } var newDegreeFormOpen=false; /* * Sends ajax request to get the "new degree" form */ function openAddDegreeForm(linkObj) { if (newDegreeFormOpen) { closeAddDegreeForm(); } ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_addDegree.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',linkObj.id.replace('addLink_','')); ajaxOrg.onCompletion=function(){openAddDegreeForm_complete(linkObj);}; ajaxOrg.runAJAX(); } // the real magic happens here function openAddDegreeForm_complete(linkObj) { var formElement=document.createElement('div'); formElement.id='jsHideUnhide_add_education_degree'; formElement.setAttribute('class','addDegree'); var elementInner=ajaxOrg.response; ajaxOrg.reset(); formElement.innerHTML=elementInner; linkObj.parentNode.parentNode.insertBefore(formElement,linkObj.parentNode.nextSibling); newDegreeFormOpen=true; } function closeAddDegreeForm() { document.getElementById('jsHideUnhide_add_education_degree').parentNode.removeChild(document.getElementById('jsHideUnhide_add_education_degree')); newDegreeFormOpen=false; } function saveAddDegreeForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/process_new_degree.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('degreeLevelPursuing',document.getElementById('NEWeducationlevelspursuing_'+uniqueId).value); // ID ajaxOrg.setVar('degreeprogramabbr',document.getElementById('NEWeducationlevelsdegreesprogramabbr_'+uniqueId).value); // ID ajaxOrg.setVar('degreeName',document.getElementById('NEWeducationlevelsdegrees_').value); // text ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.setVar('uid','11'); ajaxOrg.setVar('gid',document.getElementById('gid').value); ajaxOrg.onCompletion=complete_saveAddDegreeForm; ajaxOrg.runAJAX(); } function complete_saveAddDegreeForm() { if (ajaxOrg.response.indexOf('error:') == -1) { location.reload(true); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); } function deleteDegree(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_deleteDegree.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_deleteDegree(uniqueId);}; ajaxOrg.runAJAX(); } function complete_deleteDegree(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { var referenceElement=document.getElementById('eduDegree_'+uniqueId); referenceElement.parentNode.removeChild(referenceElement); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); } function openEditDegreeForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_editDegree.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_openEditDegreeForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_openEditDegreeForm(uniqueId) { var refDiv=document.getElementById('eduDegree_'+uniqueId); refDiv.style.display='none'; newElement=document.createElement('div'); newElement.id='editDegreeForm_'+uniqueId; newElement.innerHTML=ajaxOrg.response; refDiv.parentNode.insertBefore(newElement,refDiv); ajaxOrg.reset(); } function closeEditDegreeForm(uniqueId) { var refNode=document.getElementById('editDegreeForm_'+uniqueId); refNode.parentNode.removeChild(refNode); document.getElementById('eduDegree_'+uniqueId).style.display='block'; } function saveEditDegreeForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_saveEditDegree.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.setVar('progress',document.getElementById('NEWeducationlevelspursuing_'+uniqueId).value); // ID ajaxOrg.setVar('type',document.getElementById('NEWeducationlevelsdegreesprogramabbr_'+uniqueId).value); // ID ajaxOrg.setVar('degreeName',document.getElementById('NEWeducationlevelsdegrees_'+uniqueId).value); // text ajaxOrg.onCompletion=function() {complete_saveEditDegreeForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_saveEditDegreeForm(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { location.reload(true); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); } function openEditEduForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_editEduInstitution.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_openEditEduForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_openEditEduForm(uniqueId) { var refObj=document.getElementById('eduInstitution_'+uniqueId); // hide the two divs refObj.style.display='none'; document.getElementById('profileInfoDates_'+uniqueId).style.display='none'; // show the new one var newElement=document.createElement('div'); newElement.id='eduInstitutionEdit_'+uniqueId; newElement.innerHTML=ajaxOrg.response; refObj.parentNode.insertBefore(newElement,refObj); ajaxOrg.reset(); } function cancelEditEduForm(uniqueId) { refObj=document.getElementById('eduInstitutionEdit_'+uniqueId); refObj.parentNode.removeChild(refObj); document.getElementById('eduInstitution_'+uniqueId).style.display='block'; document.getElementById('profileInfoDates_'+uniqueId).style.display='block'; } function saveEditEduForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/process_form_editEdu.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.setVar('institution',document.getElementById('institution_'+uniqueId).value); ajaxOrg.setVar('website',document.getElementById('organizationwebsite_'+uniqueId).value); ajaxOrg.setVar('startDate',document.getElementById('startdate_'+uniqueId).value); ajaxOrg.setVar('endDate',document.getElementById('enddate_'+uniqueId).value); ajaxOrg.setVar('eduType',document.getElementById('eduType_'+uniqueId).value); ajaxOrg.onCompletion=function() {complete_saveEditEduForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_saveEditEduForm(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { location.reload(true); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); } function saveNewEmpForm(uniqueId,viewedUser) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/process_form_newEmp.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.setVar('viewedUser',viewedUser); ajaxOrg.setVar('institutionType',document.getElementById('institutiontype_'+uniqueId).value); // ID ajaxOrg.setVar('institution',document.getElementById('institution_'+uniqueId).value); ajaxOrg.setVar('website',document.getElementById('organizationwebsite_'+uniqueId).value); ajaxOrg.setVar('jobTitle',document.getElementById('jobtitle_'+uniqueId).value); ajaxOrg.setVar('jobClass',document.getElementById('jobClass_'+uniqueId).value); // ID ajaxOrg.setVar('startDate',document.getElementById('startdate_'+uniqueId).value); // date ajaxOrg.onCompletion=function() {complete_saveNewEmpForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_saveNewEmpForm(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { location.reload(true); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); } function openEditEmpForm(uniqueId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_editEmpForm.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_openEditEmpForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_openEditEmpForm(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { var refObj=document.getElementById('eduInstitution_'+uniqueId); refObj.style.display='none'; document.getElementById('empJobData_'+uniqueId).style.display='none'; document.getElementById('profileInfoDates_'+uniqueId).style.display='none'; // show the new one var newElement=document.createElement('div'); newElement.id='empEdit_'+uniqueId; newElement.innerHTML=ajaxOrg.response; refObj.parentNode.insertBefore(newElement,refObj); ajaxOrg.reset(); } else { alert(ajaxOrg.response()); } ajaxOrg.reset(); } function deleteEmp(uniqueId) { if (confirm("Are you sure you want to delete this employment listing?")) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_deleteEmployment.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_deleteEmp(uniqueId);}; ajaxOrg.runAJAX(); } } function complete_deleteEmp(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { document.getElementById('eduInstitution_'+uniqueId).style.display='none'; document.getElementById('empJobData_'+uniqueId).style.display='none'; document.getElementById('profileInfoDates_'+uniqueId).style.display='none'; } else { alert(ajaxOrg.response()); } ajaxOrg.reset(); } function deleteEdu(uniqueId) { if (confirm("Are you sure you want to delete this education listing?")) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/ajaxResponder_deleteEdu.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.onCompletion=function() {complete_deleteEdu(uniqueId);}; ajaxOrg.runAJAX(); } } function complete_deleteEdu(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { document.getElementById('displayEdu_'+uniqueId).style.display='none'; } else { alert(ajaxOrg.response()); } ajaxOrg.reset(); } function cancelNewEmpForm(uniqueId) { var refObj=document.getElementById('eduInstitution_'+uniqueId); refObj.style.display='block'; document.getElementById('empJobData_'+uniqueId).style.display='block'; document.getElementById('profileInfoDates_'+uniqueId).style.display='block'; document.getElementById('empEdit_'+uniqueId).parentNode.removeChild(document.getElementById('empEdit_'+uniqueId)); } function saveEmpEditForm(uniqueId,groupId) { ajaxOrg.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/process_form_editEmpForm.php"; ajaxOrg.method="POST"; ajaxOrg.setVar('uniqueId',uniqueId); ajaxOrg.setVar('gid',groupId); ajaxOrg.setVar('type',document.getElementById('institutiontype_'+uniqueId).value); ajaxOrg.setVar('org',document.getElementById('institution_'+uniqueId).value); ajaxOrg.setVar('website',document.getElementById('organizationwebsite_'+uniqueId).value); ajaxOrg.setVar('title',document.getElementById('jobtitle_'+uniqueId).value); ajaxOrg.setVar('class',document.getElementById('jobClass_'+uniqueId).value); ajaxOrg.setVar('startDate',document.getElementById('startdate_'+uniqueId).value); ajaxOrg.setVar('endDate',document.getElementById('enddate_'+uniqueId).value); ajaxOrg.onCompletion=function() {complete_saveEmpEditForm(uniqueId);}; ajaxOrg.runAJAX(); } function complete_saveEmpEditForm(uniqueId) { if (ajaxOrg.response.indexOf('error:') == -1) { location.reload(true); } else { alert(ajaxOrg.response); } ajaxOrg.reset(); }