var xmlhttp = null; function editMode () { DrElement.hide( $( 'profile_display' ) ); DrElement.show( $( 'profile_edit' ) ); DrElement.hide( $( 'profile_button' ) ); DrElement.showInline( $( 'profile_button_save' ) ); DrElement.showInline( $( 'profile_button_cancel' ) ); } function closeEditProfile() { DrElement.show( $( 'profile_display' ) ); DrElement.hide( $( 'profile_edit' ) ); DrElement.hide( $( 'profile_button_save' ) ); DrElement.hide( $( 'profile_button_cancel' ) ); DrElement.showInline( $( 'profile_button' ) ); } function saveProfile () { var sURL = "user_profile.php"; var oForm = getObj ("profile_form"); var sQS = ""; for (i = 0; i < oForm.elements.length; ++i) { if (oForm.elements[i].name.length) { sQS += "&" + oForm.elements[i].name + "=" + encodeURIComponent (oForm.elements[i].value); } } if (window.XMLHttpRequest) {// code for Mozilla, Safari, etc xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = handleUserProfileResult; xmlhttp.open("POST",sURL,true); xmlhttp.setRequestHeader ("content-type", "application/x-www-form-urlencoded"); xmlhttp.send (sQS); } else if (window.ActiveXObject) {//IE xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); if (xmlhttp) { xmlhttp.onreadystatechange = handleUserProfileResult; xmlhttp.open ("POST", sURL, true); xmlhttp.setRequestHeader ("content-type", "application/x-www-form-urlencoded"); xmlhttp.send (sQS); } } closeEditProfile(); } function handleUserProfileResult () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var oXML; oXML = xmlhttp.responseXML; var oRedirect = oXML.getElementsByTagName ("redirect").item(0); if (oRedirect) { self.location = oRedirect.getAttribute ("url"); } else { var oError = oXML.getElementsByTagName ("e").item(0); if (oError) { alert (oError.getAttribute ("m")); } else { updateProfile (xmlhttp.responseText); } } xmlhttp = null; } } } function updateProfile (sContent) { getObj ("profile_edit").className= "hidden"; var oDisplay = getObj ("profile_display"); oDisplay.innerHTML = sContent; oDisplay.className = "sectionbody"; getObj ("profile_button").value = "Edit"; getObj ("profile_button").onclick = editMode; }