var ajax=new sack(); var openAddressForms=new Array(); var resource_id_saved; var ct_saved; var addrPrefix; function jsHideUnhideNewAddress(resource_id,ct,address_prefix) { objContainer=document.getElementById("jsHideUnhide_add_address_"+resource_id); if (!in_array(resource_id, openAddressForms, false)) { // if the form box doesn't have content in it, add it resource_id_saved=resource_id; ct_saved=ct; // append this rid to the openAddressForms array openAddressForms.push(resource_id); // now run the ajax to actually get the data ajax.setVar('rid',resource_id); ajax.setVar('ct',ct); ajax.setVar('addrPrefix',address_prefix); ajax.element="jsHideUnhide_add_address_"+resource_id; ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/address_modify.php"; ajax.method='GET'; ajax.onCompletion=complete_jsHideUnhideNewAddress; ajax.runAJAX(); } else { // if the form box has content, get rid of it objContainer.innerHTML=""; // get the index in the openAddressForms array for the one we're looking at // when we find it, pop that element out of the array and reorder using splice openAddressForms.splice(openAddressForms.indexOf(resource_id),1); } } function complete_jsHideUnhideNewAddress() { // because the ajax operation of this page doesn't pull in the php variables that will set up // for the page originally, we'll change the name and ID here objAddressPrefix=document.getElementById("addressprefix"); objAddressPrefix.id="addressprefix"+ct_saved; objAddressPrefix.name="addressprefix"+ct_saved; // and set the value as needed objAddressPrefix.value='NEW'+ct_saved; } function in_array(needle, haystack, argStrict) { // Checks if the given value exists in the array // // version: 911.718 // discuss at: http://phpjs.org/functions/in_array // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: vlado houba // + input by: Billy // + bugfixed by: Brett Zamir (http://brett-zamir.me) // * example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']); // * returns 1: true // * example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'}); // * returns 2: false // * example 3: in_array(1, ['1', '2', '3']); // * returns 3: true // * example 3: in_array(1, ['1', '2', '3'], false); // * returns 3: true // * example 4: in_array(1, ['1', '2', '3'], true); // * returns 4: false var key = '', strict = !!argStrict; if (strict) { for (key in haystack) { if (haystack[key] === needle) { return true; } } } else { for (key in haystack) { if (haystack[key] == needle) { return true; } } } return false; } var openEditForms=Array(); var savedUniqueId=0; function jsShowEmploymentEditForm(uniqueId) { // only open the form if it's not already open if (!in_array(uniqueId, openEditForms)) { // perform an ajax request to get the form savedUniqueId=uniqueId; ajax.setVar('uniqueId',uniqueId); var arrUniqueId=uniqueId.split("_"); if (arrUniqueId[0] == 0) { ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/employment_modify_ajax.php"; ajax.onCompletion=complete_jsShowEmploymentEditForm; } else { ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/education_modify_ajax.php"; ajax.onCompletion=complete_jsShowEducationEditForm; } ajax.method='POST'; ajax.runAJAX(); } } function complete_jsShowEmploymentEditForm() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // hide the original one var hideElement=document.getElementById('jsHideUnhide_output_job_'+savedUniqueId); hideElement.style.display="none"; // show the new form NEWjsHideUnhide_modify_job_ var newForm=document.createElement('div'); newForm.setAttribute('id','NEWjsHideUnhide_modify_job_'+savedUniqueId); newForm.innerHTML=ajax.response; insertAfter(hideElement, newForm); } } function complete_jsShowEducationEditForm() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // hide the original one var hideElement=document.getElementById('jsHideUnhide_output_education_'+savedUniqueId); hideElement.style.display="none"; // show the new form NEWjsHideUnhide_modify_education_ var newForm=document.createElement('div'); newForm.setAttribute('id','NEWjsHideUnhide_modify_education_'+savedUniqueId); newForm.innerHTML=ajax.response; insertAfter(hideElement, newForm); } } function jsHideEmploymentEditForm(uniqueId) { // remove it from the page var newForm=document.getElementById('NEWjsHideUnhide_modify_job_'+uniqueId); newForm.parentNode.removeChild(newForm); // remove it from the open edit forms array openEditForms.splice(openEditForms.indexOf(uniqueId),1); // show the original form document.getElementById('jsHideUnhide_output_job_'+uniqueId).style.display="block"; } function jsHideEducationEditForm(uniqueId) { // remove it from the page var newForm=document.getElementById('NEWjsHideUnhide_modify_education_'+uniqueId); newForm.parentNode.removeChild(newForm); // remove it from the open edit forms array openEditForms.splice(openEditForms.indexOf(uniqueId),1); // show the original form document.getElementById('jsHideUnhide_output_education_'+uniqueId).style.display="block"; } function insertAfter( referenceNode, newNode ) { referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling ); } function jsShowDegreeEditForm(uniqueId) { // only open the form if it's not already open if (!in_array(uniqueId, openEditForms)) { // perform an ajax request to get the form savedUniqueId=uniqueId; ajax.setVar('uniqueId',uniqueId); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/degree_modify_ajax.php"; ajax.onCompletion=complete_jsShowDegreeEditForm; ajax.method='POST'; ajax.runAJAX(); } } function complete_jsShowDegreeEditForm() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // hide the original one var hideElement=document.getElementById('jsHideUnhide_modify_degree_'+savedUniqueId); hideElement.style.display="none"; // show the new form NEWjsHideUnhide_modify_degree_ var newForm=document.createElement('div'); newForm.setAttribute('id','NEWjsHideUnhide_modify_degree_'+savedUniqueId); newForm.innerHTML=ajax.response; insertAfter(hideElement, newForm); } } function jsHideDegreeEditForm(uniqueId) { // remove it from the page var newForm=document.getElementById('NEWjsHideUnhide_modify_degree_'+uniqueId); newForm.parentNode.removeChild(newForm); // remove it from the open edit forms array openEditForms.splice(openEditForms.indexOf(uniqueId),1); // show the original form document.getElementById('jsHideUnhide_modify_degree_'+uniqueId).style.display="block"; } function jsSaveNewEducation(uniqueId, gid) { ajax.setVar('uniqueId',uniqueId); ajax.setVar('gid',gid); ajax.setVar('institution',document.getElementById('institution_'+uniqueId).value); ajax.setVar('website',document.getElementById('organizationwebsite_'+uniqueId).value); ajax.setVar('progressId',document.getElementById('NEWeducationlevelspursuing_'+uniqueId).value); ajax.setVar('typeAbbr',document.getElementById('NEWeducationlevelsdegreesprogramabbr_'+uniqueId).value); ajax.setVar('degreeName',document.getElementById('educationlevelsdegrees_'+uniqueId).value); ajax.setVar('startdate',document.getElementById('startdate_'+uniqueId).value); ajax.setVar('enddate',document.getElementById('enddate_'+uniqueId).value); ajax.requestFile="http://n4a.solacedev.com/tools/user_profiles/bin/process_form_newEdu.php"; ajax.onCompletion=complete_jsSaveNewEducation; ajax.method='POST'; ajax.runAJAX(); } function complete_jsSaveNewEducation() { if (ajax.response.indexOf('error:') != -1) { alert(ajax.response); } else { // refresh the page location.reload(); } } //Dynamically grabs and gets rid of address form for updating current addresses